HotXLS Docs

XLSB data validation

The XLSX workbook facade reads, authors, edits and saves represented ordinary XLSB validation rules through the existing worksheet API; binary transport and candidate assessment keep separate validation and resource checks

Ordinary rule profile

Supported kinds cover input-only, whole number, decimal, list, date, time, text length and custom formula, with represented comparison operators and ordered worksheet-local target areas

Rules keep blank handling, prompt and error titles and messages, stop/warning/information alert styles, list dropdown visibility and known IME modes; these UI settings do not stand in for candidate evaluation

Use TXLSXWorksheet.DataValidations to edit or remove an imported rule, or the existing AddDataValidation, AddDecimalValidation, AddListValidation and AddCustomValidation helpers to author one

The complete workbook still passes the ordinary XLSB conversion gate; adding a supported validation rule does not switch on an unrelated unsupported worksheet or package feature

Owner, anchor and candidate context

CheckDataValidation(Row, Col, Candidate, SetIfValid) tests every applicable rule in collection order and returns -1 for a valid candidate or no applicable rule, otherwise the one-based index of the first failing rule

Formula references use the rule's owning worksheet rather than the workbook's active tab; relative coordinates move from the first valid target area's top-left anchor to the cell under test, whilst absolute row and column dimensions stay fixed

Custom predicates observe the proposed candidate through a temporary cell overlay, with ROW() and COLUMN() taking the actual target; a read-only check puts back the previous value and formula-cache state, and SetIfValid=True commits only after every applicable rule passes

Represented ordinary defined names and range-backed lists resolve in that owner context, with sheet-local names taking precedence over workbook-global names; list membership follows the current source values rather than freezing the original item cache

Unresolvable or faulty bounds and custom predicates fail the check; a failed or over-budget list evaluation does not establish membership, and an unevaluated formula is not quietly accepted as proof of a valid input

AllowBlank governs an empty candidate before nonempty rule evaluation; input-only validation imposes no value constraint

Check and save an inactive owner's rules

This example keeps Sources active whilst Rules owns the constraints; B3 takes A3's bounds and the custom predicate reads Rules Z1

uses
  System.SysUtils, lxHandleX;

procedure SaveValidatedWorkbook(const OutputFile: WideString);
var
  Book: TXLSXWorkbook;
  Owner: IXLSXWorkbookOwner;
  Rules, Sources: TXLSXWorksheet;
begin
  Book := TXLSXWorkbook.Create;
  Owner := Book;
  try
    Rules := Book.Sheets.Add('Rules');
    Sources := Book.Sheets.Add('Sources');
    Book.Sheets.ActiveIndex := 1;
    Rules.Cells[2, 1].Value := 2;
    Rules.Cells[3, 1].Value := 4;
    Rules.Cells[1, 26].Value := 1;
    Sources.Cells[1, 26].Value := 100;
    Sources.Cells[1, 1].Value := 'Alpha';
    Sources.Cells[2, 1].Value := 'Beta';
    Book.DefinedNames.Add('ChoiceValues', '=Sources!$A$1:$A$2');

    Rules.AddDecimalValidation('B2:B3', xlsxDvOpBetween,
      '$A2', '$A2+0.5');
    Rules.AddDataValidation('D2:D3', xlsxDvList,
      xlsxDvOpBetween, 'ChoiceValues');
    Rules.AddCustomValidation('E2:E3', '$Z$1=1');

    if Rules.CheckDataValidation(3, 2, 4.25, True) <> -1 then
      raise Exception.Create('The relative decimal value should be valid');
    if Rules.CheckDataValidation(3, 2, 2.25, False) = -1 then
      raise Exception.Create('The value belongs to the wrong target row');
    if Rules.CheckDataValidation(2, 4, 'Alpha', True) <> -1 then
      raise Exception.Create('The named list should contain Alpha');
    if Rules.CheckDataValidation(2, 5, 'Candidate', False) <> -1 then
      raise Exception.Create('The rule must read Rules Z1');

    if Book.SaveAs(OutputFile, xlsxExcelBinaryWorkbook) <> 1 then
      raise Exception.Create('The XLSB output could not be saved');
  finally
    Owner := nil;
  end;
end;

Call SaveAs with xlsxExcelBinaryWorkbook for binary output, then use the ordinary Open path and the same public rule-checking APIs after reopening

Date systems and typed date candidates

A numeric date candidate is already a serial in the workbook's Date1904 system; the checker does not infer an epoch from a number format, nor does it reinterpret an ordinary Double as an OLE Automation date

For a Date validation rule, typed varDate candidates and typed date-valued formula bounds take the same epoch conversion as worksheet date serialisation, so a DATE() bound and the candidate are compared within the same workbook date system

Focused controls cover numeric and typed 2026 dates in both 1900 and 1904 workbooks; the native-inspected 1904 output keeps a date candidate as the number 44562 under bounds DATE(2026,1,1) through DATE(2026,12,31)

Time-only numeric candidates remain fractions of a day, such as 0.375 for 09:00; this qualification does not cover every early-calendar phantom date or general date-arithmetic expression

Represented calculation context

The binary bridge preserves the public CalcMode values manual, auto and autoNoTable, together with CalcCompleted and CalcOnSave, in both directions

This takes in the independent native validation fixture's manual mode with both flags false; validation checking does not manufacture a calculation-engine revision, and CalcId keeps its existing signed public-model boundary

Iteration, reduced precision, alternate reference mode, explicit thread settings and the other unrepresented calculation options keep their conversion gates

Without an explicit user thread setting, the writer normalises the unused binary thread-count field to its specified value of 1; the older unused zero stays readable, and whole-record byte identity is not promised

Short literal-list compatibility

The independently authored ordinary short literal list is stored as a lone PtgStr holding comma-separated UTF-16 text, without NUL substitution or ancillary formula data

The published DVParsedFormula list-root rule requires a non-VALUE root, while the observed native PtgStr is a VALUE root; this backend makes an explicit, bounded compatibility exception for that short literal form

The exception does not accept arbitrary VALUE expressions as list sources and does not qualify long-list alternate content, embedded-comma item escaping or NUL-separated list encodings

The observed ordinary unused bit does not act as the sole discriminator for accepting a literal list

Identity annotations and unknown content

The recognised ordinary UID alternate-content envelope carries a 16-byte rule annotation and establishes no public consumer identity, relationship or stable identifier; that source UID is not promised to survive output

Direct binary conversion turns away unknown alternate-content envelopes or records, repeated identity records, DVal14, BrtDValList record 681, unknown IME modes and nondefault collection-level prompt flags or coordinates; checked saving refuses unsupported rules still represented in the public model

The older generic OOXML parser still skips unrecognised validation type tokens; this increment does not keep every unknown XML rule for later checked-save diagnosis, and a rule already absent from the model cannot be reconstructed by output preflight

Explicit and default input-only none rules are kept with their prompts instead of being dropped on import

Conversion and execution bounds

Ordinary conversion allows at most 65534 rules and 8191 target rectangles per rule, subject to the existing worksheet grid and source-part limits

Validation metadata carries a charged 16 MiB ceiling; encoded formula tokens are limited to 16384 bytes, formula text to 8192 characters and the validation expression stack to 1024 entries

Prompt and error titles carry a 32 UTF-16 code-unit limit, the error message a 225 code-unit limit and the input prompt a 255 code-unit limit; short string tokens are limited to 255 UTF-16 code units

Formula execution uses the default bounded evaluation options and the workbook's unsafe-callback setting with external resolution switched off; list results must be scalar or one/two dimensional and inspect at most 1048576 entries, with no hard total-memory or wall-clock ceiling promised for arbitrary caller callbacks

Unsupported or malformed selected binary content refuses through the existing preflight and private package-staging path; it gains no direct write path that bypasses destination protection

Representative qualification

Representative Delphi Win64 qualification takes in 590 public lifecycle assertions, the unchanged nine-context counterexample driver, five date controls, 25 bounded/refusal checks, eleven name checks and 57 independent wire checks

Five public outputs, comprising preserved XLSB and XLSX files plus edited, authored and deleted-rule workbooks, pass the owned Excel acceptance with 663 checks, 131 candidate judgements and 34 observed rules

The separate 1904-date XLSB output passes its own native acceptance with 33 checks, four candidate judgements and one rule; these results come on top of the five-file ordinary qualification

The named-list qualification inspects the definition's actual binary reference class, target worksheet and range bounds, since normalising a value-class name to the same formula text in a self round trip did not establish native execution

These checks qualify the represented ordinary profile on the tested Windows path and establish neither untested platforms nor every validation extension

Remaining worksheet-feature scope

Future/UDF calls, external-book dependencies, spill or implicit-intersection operators, array constants and unrepresented validation control or ancillary token forms sit outside this ordinary profile; name references do not authorise unsupported dependency forms

Data validation belongs to the broader finite XLSB worksheet profiles; rich text, Notes, conditional formatting, advanced filters and table calculations and custom styles have their own qualified subsets and documented conversion boundaries

Ordinary rule support does not establish every native extension, every platform or the completion of the full worksheet-feature scope

Long literal lists load beyond the 255-character authoring limit: the binary token length is bounded only by its u16 field, matching a native 419-character single-token list; Excel itself refuses to reopen xlsx literal lists longer than 255 characters, so the long xlsx form is verified library-side whilst the binary form carries the native round-trip

Extension data validations (for instance lists referencing another worksheet) parse into the typed DataValidations model flagged IsExtension: their cross-sheet formula and range survive edits, saves and reopens, and the writer re-emits them as the x14 extension in its schema position; replayed extension fragments also declare every namespace prefix they use upon the worksheet root

Extension validation formula bounds

Typed x14 whole-number, decimal, text-length, date and time validations keep both formulas for between and notBetween rules through saving and reopening, including represented cross-sheet formula references; this is persistence in the existing extension profile and adds no new validation evaluator

A dataValidation with an unrecognised type token loads as an untyped rule with one warning diagnostic instead of being dropped, and resaves in the bare-element form native Excel itself rewrites such rules into