[]
Represents data validation for a worksheet range.
Use Validation to obtain an IValidation instance for a range and
define the allowed data type, comparison rules, formulas, input messages, error messages, and
drop-down behavior for that range. A cell can have only one validation rule applied at a time.
public interface IValidation
Public Interface IValidation
worksheet.Range["A1:A3"].Value = new object[,] {{"Low"}, {"Medium"}, {"High"}};
IValidation validation = worksheet.Range["B2:B5"].Validation;
validation.Add(ValidationType.List, ValidationAlertStyle.Stop, ValidationOperator.Between, "=$A$1:$A$3", null);
validation.InCellDropdown = true;
| Name | Description |
|---|---|
| AlertStyle | Gets or sets the ValidationAlertStyle value that specifies the data validation alert style. This property specifies which icon is shown in the validation error message box when invalid data is entered for the range. |
| ErrorMessage | Gets or sets the data validation error message. Use this property to get or configure the message associated with the validation rule for the range. |
| ErrorTitle | Gets or sets the title of the data-validation error dialog box. This title is shown in the error alert when a user enters invalid data and error alerts are enabled. |
| Formula1 | Gets or sets the value or expression associated with the conditional format or data validation. The returned object represents the first part of the validation criteria and can be a constant value, a string value, a cell reference, or a formula. |
| Formula2 | Gets or sets the value or expression associated with the second part of a conditional format or data validation. The returned object represents the second comparison value for rules that use two operands, such as data validation rules that use Between or NotBetween. It can be a constant value, a string value, a cell reference, or a formula. |
| IMEMode | Gets or sets the input method editor (IME) mode for the data validation rule. This value describes the Japanese input rules applied to validated cells. |
| IgnoreBlank | Gets or sets whether blank values are permitted by the data range validation.
When this property returns |
| InCellDropdown | Gets or sets whether data validation displays a drop-down list that contains acceptable values. Use this property to determine whether the validation rule shows an in-cell list for selecting allowed values. This setting is typically used with list validation. |
| InputMessage | Gets or sets the data validation input message. The input message is displayed when the user selects a cell in the validated range if input messages are enabled for the validation. |
| InputTitle | Gets or sets the title of the data-validation input dialog box. Use this property to retrieve or configure the title for the input prompt of a validated cell or range. |
| Operator | Gets or sets the operator for the conditional format or data validation. This property determines how the validation compares the cell value with Formula1 and, when applicable, Formula2. |
| ShowError | Gets or sets whether the data validation error message will be displayed whenever the user enters invalid data. Use this property to control whether invalid input displays the validation error alert for the range. |
| ShowInputMessage | Gets or sets whether the data validation input message is displayed whenever the user selects a cell in the data validation range. Use this property to control whether the input message is shown for cells covered by this validation. |
| Type | Gets or sets the data type validation for a range.
This property returns the current |
| Value | Gets whether all the validation criteria are met (that is, if the range contains valid data).
This property returns |
| Name | Description |
|---|---|
| Add(ValidationType, ValidationAlertStyle, ValidationOperator, object, object) | Adds data validation to the specified range.
Uses the specified ValidationType, ValidationAlertStyle, and
ValidationOperator to define the validation rule for the range associated
with this |
| Delete() | Deletes the object. Removes the existing data validation rule applied to the associated cell or range. |
| FromJson(string) | Generates the data validation from the JSON string. Calling this method clears the existing data validation in the current range and then applies the data validation defined by the specified JSON string. If both the current API call and the JSON content provide range information, the current range is applied and the range information in the JSON string is ignored. |
| ToJson() | Generates a JSON string from the data validation. Use the returned JSON string to serialize the current validation settings for reuse with FromJson(string). |