HotXLS Docs

TXLSXDataValidation and TXLSXDataValidations classes

TXLSXDataValidations manages Excel input constraints for TXLSXWorksheet.DataValidations and each rule is a TXLSXDataValidation

Declarations

function Add(const ARange: WideString; AType: TXLSXDataValidationType; AOp: TXLSXDvOperator; const AFormula1: WideString): Integer;
function Add(const ARange: WideString; AType: TXLSXDataValidationType; AOp: TXLSXDvOperator; const AFormula1, AFormula2: WideString): Integer;
function AddList(const ARange, AItems: WideString): Integer;
procedure TXLSXDataValidation.SetPrompt(const ATitle, AText: WideString);
procedure TXLSXDataValidation.SetError(const ATitle, AText: WideString; AStyle: TXLSXDvErrorStyle = xlsxDvErrStop);

Rule members

Range and ValidationTypeTarget cells plus the whole number, decimal, list, date, time, text-length or custom validation type
Op, Formula1 and Formula2Comparison operator and one or two criteria expressions
AllowBlankAllows an empty value while retaining the validation rule
PromptTitle and PromptInput message shown when a target cell is selected
ErrorTitle, ErrorMessage and ErrorStyleInvalid-entry alert and its stop, warning or information icon
ShowDropDownControls whether a list validation displays its selection arrow
ImeModeOOXML IME input mode for supported CJK clients

Rule target ranges

As of 2.384.76, worksheet-local targets take single cells, cell rectangles, whole columns such as $B:$D, and whole rows such as $5:$8; reversed endpoints are normalised, and spaces, tabs or line breaks separate multiple areas
Absolute and mixed references retain their original Range text; matching uses rows 1 through 1048576 and columns A through XFD, skips malformed or out-of-grid areas, and leaves valid sibling areas active without raising a new setter exception
Sheet-qualified and external references are not target areas; each rule belongs to its worksheet, and dollar signs may only occur in ordinary A1 reference positions
Rule lookup, cell and range deletion, single-cell validation and stored-cell validation audits use the same target geometry; target parsing leaves list-source formula support unchanged
As of 2.384.77, row and column edits also transform whole-axis rule targets within the worksheet grid; an extent spanning every row or column remains complete when that axis is edited, whilst edits to the other axis move, shrink or remove the target
Range cloning retains the complete-coverage contract: every target area must fit inside the source rectangle before a rule is copied, and partial intersection alone does not copy a rule; whole-axis targets can be cloned from an entire-row or entire-column source when the destination remains within the grid
Whole-axis validation targets remain one rule during edits, with the formula adjusted from its first surviving anchor; this adds nothing to the existing ODS custom-boolean or scalar-formula interoperability support

Example

var Index: Integer;
begin
  Index := Sheet.DataValidations.AddList('D2:D100', 'New,Active,Closed');
  Sheet.DataValidations[Index].SetPrompt('Status', 'Select a permitted status');
  Sheet.DataValidations[Index].SetError('Invalid status', 'Choose a value from the list');
end;

ODS scope

ODS export derives a valid first-cell base address from the first supported target area, including whole rows and columns; malformed leading areas never become base addresses
Custom boolean validation export remains unsupported, and scalar threshold formulas keep their existing formula-syntax limitations; the target-range fix does not establish external interoperability for relative validation formulas

See also