XlsValidation module
- class XlsValidation.XlsValidation
Bases:
IDataValidation,IExcelApplication,IOptimizedUpdate,ICloneParentRepresents a data validation rule in an Excel worksheet.
This class provides functionality for creating and managing data validation rules that restrict the type of data or values users can enter into a cell or range. It implements IDataValidation, IExcelApplication, IOptimizedUpdate, and ICloneParent interfaces.
- AddRange
Adds the range from another validation object to this validation.
This method combines the range of cells from another validation object with the range of cells in this validation.
- Parameters:
dv (XlsValidation) – The validation object whose range to add.
- property AlertStyle: AlertStyleType
Gets or sets the style of the error alert.
Determines the icon and buttons displayed in the error message box when invalid data is entered.
- Returns:
The style of the error alert.
- Return type:
AlertStyleType
- property AllowType: CellDataType
Gets or sets the data type allowed in the cell or range.
This property determines what type of data is valid for the cells with validation.
- Returns:
The data type allowed for validation.
- Return type:
CellDataType
- BeginUpdate()
Begins a batch update operation on the validation rule.
Call this method before making multiple changes to the validation rule to improve performance. Call EndUpdate when finished.
- Clone(parent: SpireObject) SpireObject
Creates a copy of this validation rule with the specified parent object.
- Parameters:
parent (SpireObject) – The parent object for the cloned validation rule.
- Returns:
The cloned validation rule.
- Return type:
SpireObject
- property CompareOperator: ValidationComparisonOperator
Gets or sets the comparison operator for the data validation.
This property determines how the cell’s value is compared against the validation criteria.
- Returns:
The comparison operator for validation.
- Return type:
ValidationComparisonOperator
- ContainsCell(lCellIndex: int) bool
Determines whether the validation rule applies to a specific cell.
- Parameters:
lCellIndex (int) – The index of the cell to check.
- Returns:
True if the validation rule applies to the specified cell; otherwise, False.
- Return type:
bool
- property DataRange: IXLSRange
Gets or sets the cell range to which the data validation applies.
This property specifies the range of cells that will have this validation rule applied.
- Returns:
The cell range with this validation rule.
- Return type:
IXLSRange
- property DateTime1: DateTime
Gets or sets the first date/time value for the data validation.
Used when validating date or time values, typically as the minimum value.
- Returns:
The first date/time value for validation.
- Return type:
DateTime
- property DateTime2: DateTime
Gets or sets the second date/time value for the data validation.
Used when validating date or time values with a range, typically as the maximum value.
- Returns:
The second date/time value for validation.
- Return type:
DateTime
- EndUpdate()
Ends a batch update operation on the validation rule.
Call this method after calling BeginUpdate and making multiple changes to the validation rule.
- property ErrorMessage: str
Gets or sets the message of the error message box.
The error message appears when a user enters invalid data in a cell with validation.
- Returns:
The message content of the error message box.
- Return type:
str
- property ErrorTitle: str
Gets or sets the title of the error message box.
The error message appears when a user enters invalid data in a cell with validation.
- Returns:
The title of the error message box.
- Return type:
str
- property Formula1: str
Gets or sets the first formula or value for the data validation.
For most validation types, this property sets the minimum value or the only value used for validation.
- Returns:
The first formula or value for validation.
- Return type:
str
- property Formula2: str
Gets or sets the second formula or value for the data validation.
For validation types that require a range (like between or not between), this property sets the maximum value.
- Returns:
The second formula or value for validation.
- Return type:
str
- property IgnoreBlank: bool
Gets or sets whether blank values are allowed in the validated range.
When True, empty cells are considered valid regardless of the validation criteria.
- Returns:
True if blank values are allowed; otherwise, False.
- Return type:
bool
- property InputMessage: str
Gets or sets the message of the input message box.
The input message appears when a user selects a cell with data validation.
- Returns:
The message content of the input message box.
- Return type:
str
- property InputTitle: str
Gets or sets the title of the input message box.
The input message appears when a user selects a cell with data validation.
- Returns:
The title of the input message box.
- Return type:
str
- property IsInputPositionFixed: bool
Gets or sets whether the input message box position is fixed.
When True, the input message box appears at the position specified by PromptBoxHPosition and PromptBoxVPosition. When False, the position is determined automatically.
- Returns:
True if the input message box position is fixed; otherwise, False.
- Return type:
bool
- property IsInputVisible: bool
Gets or sets whether the input message box is visible.
Controls the visibility of the input message box independently of ShowInput.
- Returns:
True if the input message box is visible; otherwise, False.
- Return type:
bool
- property IsListInFormula: bool
Gets or sets whether the validation list is in a formula.
When True, the Formula1 property contains a formula that evaluates to a list. When False, Formula1 contains a comma-separated list of values.
- Returns:
True if the validation list is in a formula; otherwise, False.
- Return type:
bool
- property IsSuppressDropDownArrow: bool
Gets or sets whether to suppress the dropdown arrow for list validation.
When True, the dropdown arrow for list-type validation is not displayed.
- Returns:
True if the dropdown arrow is suppressed; otherwise, False.
- Return type:
bool
- property Parent: SpireObject
Gets the parent object of this validation rule.
- Returns:
The parent object of this validation rule.
- Return type:
SpireObject
- property ParentCollection: XlsDataValidationCollection
Gets or sets the collection that contains this validation rule.
- Returns:
The collection containing this validation rule.
- Return type:
XlsDataValidationCollection
- property PromptBoxHPosition: int
Gets or sets the horizontal position of the input message box.
Specifies the horizontal offset in pixels for the input message box.
- Returns:
The horizontal position in pixels.
- Return type:
int
- property PromptBoxVPosition: int
Gets or sets the vertical position of the input message box.
Specifies the vertical offset in pixels for the input message box.
- Returns:
The vertical position in pixels.
- Return type:
int
- RemoveRange
Removes a range of cells from this validation.
This method excludes the specified range of cells from this validation rule.
- Parameters:
range (XlsRange) – The range of cells to remove from this validation.
- property ShapesCount: int
Gets the count of shapes associated with this validation.
- Returns:
The number of shapes associated with this validation.
- Return type:
int
- property ShowError: bool
Gets or sets whether to display an error message when invalid data is entered.
When True, the error message (specified by ErrorTitle and ErrorMessage) is displayed when the user enters invalid data in a cell with this validation.
- Returns:
True if the error message is displayed; otherwise, False.
- Return type:
bool
- property ShowInput: bool
Gets or sets whether to display the input message when a cell is selected.
When True, the input message (specified by InputTitle and InputMessage) is displayed when the user selects a cell with this validation.
- Returns:
True if the input message is displayed; otherwise, False.
- Return type:
bool
- property Values: List[str]
Gets or sets the list of valid values for list-type validation.
For list-type validation, this property contains the list of values that are considered valid.
- Returns:
The list of valid values.
- Return type:
List[str]
- property Worksheet: XlsWorksheet
Gets the worksheet that contains this validation rule.
- Returns:
The worksheet containing this validation rule.
- Return type:
