Class XlsxDataValidation
- Namespace
- DocWright.Spreadsheet
- Assembly
- DocWright.Spreadsheet.dll
One data validation rule of a sheet (Phase 201): what it checks, the cells it covers, and what Excel shows. The object is live, as Excel's Data Validation dialog is: its setters change the rule in the workbook.
public sealed class XlsxDataValidation
- Inheritance
-
XlsxDataValidation
- Inherited Members
Remarks
The rule is found again after an edit that moves it (an insert, a sort) by its place in the sheet's list; once it is removed, reading it throws. A rule's criteria are changed by adding a new rule over the same cells, which replaces it, as Excel's dialog does.
Fields
- MaxErrorMessageLength
The longest error message Excel's dialog takes (measured: 226 characters refused).
- MaxInputMessageLength
The longest input message Excel's dialog takes (measured: 255 characters refused).
- MaxTitleLength
The longest title Excel's dialog takes (measured: 33 characters refused).
Properties
- AllowBlank
Gets or sets whether a blank cell is accepted (Excel's Ignore blank).
- ErrorMessage
Gets or sets the error message; null for Excel's own. At most 225 characters; a line break is kept.
- ErrorStyle
Gets or sets what Excel does with a refused value.
- ErrorTitle
Gets or sets the error message's title; null for none. At most 32 characters.
- Exists
Gets whether the sheet still has the rule.
- Formula1
Gets the first formula as the file writes it, without its
=: a bound (10,$Z$1), the custom formula, or a list's source ("North,South,East"with its quotes,Lists!$A$1:$A$3,Choices); null for none. A date is its serial number and a time a fraction of a day, as Excel stores them.
- Formula2
Gets the second formula (the upper bound of Between and NotBetween), as the file writes it; null for none.
- InCellDropdown
Gets or sets whether a list shows its dropdown in the cell (Excel's In-cell dropdown). The file stores the opposite:
showDropDown="1"hides it (measured).
- InputMessage
Gets or sets the input message; null for none. At most 254 characters; a line break is kept.
- InputTitle
Gets or sets the input message's title; null for none. At most 32 characters.
- ListValues
Gets the items of a list given in the rule itself, in order; null for any other rule, a list given by a range or a name included.
- Ranges
Gets the cells the rule covers, as the file lists them.
- ShowErrorMessage
Gets or sets whether the error message is shown when a value is refused. With it off, Excel takes any value.
- ShowInputMessage
Gets or sets whether the input message is shown when the cell is selected.
- Type
Gets what the rule checks.
Methods
- Accepts(XlsxCellValue)
Returns whether the rule would accept a value, as Excel judges a value typed into one of its cells (measured with Excel's
Validation.Value). A blank cell is accepted when the rule allows blanks; an error never is. A number, a date and a time are compared as numbers and a boolean compares above every number; text is refused by those types. A list compares the value's own text with its items, case counting, and a number with an item that is the same number. A text length is the length of the value's own text, not as its number format shows it.
- ToString()
Returns the rule as Excel's dialog would summarise it, such as
B2:B9 whole between 1 and 10.