Page tree
Skip to end of metadata
Go to start of metadata

Description

A DataValidation object represents a rule for validating data entered in cells. The rule may be applied to a cell or a set of cells. The Workbook class contains several CreateDataValidation methods for creating DataValidation objects. To apply a DataValidation object to a cell or group of cells, use Area.SetDataValidation or Range.SetDataValidation.

C#
vb.net

Remarks

In Microsoft Excel, data validation rules are created through the Data Validation dialog. To open this dialog, open the Data menu and select Validation.

Examples

C#
vb.net

Properties

Name

Description

AllowedType

Returns the type of value that may be entered in a cell.

Comparison

Returns the type of comparison that will be used to validate a value entered in a cell with a data validation rule.

ErrorAlert

Sets or returns the content of the error alert message displayed when invalid data is entered in a cell.

ErrorAlertStyle

Sets or returns the style of error alert to display if error alerts are enabled.

ErrorAlertTitle

Sets or returns the title of the error alert dialog that is displayed when invalid data is entered in a cell.

IgnoreBlanks

Sets or returns whether the data validation rule should ignore blank cells.

InputMessage

Sets or returns the content of the input message dialog that is displayed when the user selects a cell with a data validation rule.

MinimumValue

Sets or returns the minimum value that may be entered in a cell with a data validation rule.

MaximumValue

Sets or returns the maximum value that may be entered in a cell with a data validation rule.

ShowErrorAlert

Sets or returns whether Excel should display an error alert if invalid data is entered.

ShowInputMessage

Sets or returns whether to show a message when the user selects a cell to which a data validation rule applies.

Title

Sets or returns the title of the input message dialog that is displayed when the user selects a cell with a data validation rule.

UseListDropdown

Sets or returns whether a drop-down list will be used to display valid values.

Methods

Name

Description

Clear()

Sets all properties of the DataValidation object to an uninitialized state.

SetAllowedType(ValidationType, ComparisonType, Object)

Sets the allowed data type, comparison type, and minimum value to use when validating a cell entry.

SetAllowedType(ValidationType, ComparisonType, Object, Object)

Sets the allowed data type, comparison type, and minimum and maximum values to use when validating a cell entry.

SetAllowedType(ValidationType, Object)

Sets the allowed data type and a set of valid values to use when validating a cell entry.

Nested Classes

Name

Description

ComparisonType

The type of comparison that will be used for validating the value of the cell.

ErrorAlertStyleType

Type style of the icon in the error alert message box.

ValidationType

The data type allowed as the cell's value.
  • No labels