Advanced AutoFilter execution
Use the lxHandleX worksheet APIs to inspect, preview or apply ordinary criteria and represented advanced filters without opening Excel
The execution path supports literal display-value selections, calendar date groups, Top/Bottom-n and percentage filters, relative calendar and average filters, effective fill/font colors and supported conditional icons
Entry points
Options := XLSDefaultAutoFilterExecutionOptions; Options.ReferenceDate := EncodeDate(2026, 10, 19); MatchingRows := Sheet.PreviewAutoFilterRows(nil, Options); Sheet.ApplyAutoFilter(True, Options);
TXLSXWorksheet.AutoFilterRowVisible(ARow, Options)evaluates one data rowTXLSXWorksheet.PreviewAutoFilterRows(Callback, Options)returns the matching data-row count and optionally visits the matching rows; a nil callback performs a count-only previewTXLSXWorksheet.ApplyAutoFilter(AResetVisible, Options)prepares all row decisions before publishing visibility changes; True resets matching rows to visible, while False preserves matching rows that were already hidden
The existing overloads use the same default options returned by XLSDefaultAutoFilterExecutionOptions; initialize the whole TXLSXAutoFilterExecutionOptions record with this function before changing individual fields
Preview does not change row visibility; unsupported metadata, cancellation or a resource failure during preparation leaves application visibility unchanged
Values, dates and appearance
Selection-list entries are literal display tokens, including asterisks and question marks; ordinary custom text criteria retain their separate wildcard semantics
Selection tokens use the cell's base number format, including stored style overlays, even when conditional formatting changes its visible number format; color and icon filters evaluate the supported effective conditional appearance
ReferenceDate freezes relative calendar and conditional date rules for an operation; zero selects the current date once at operation start, and numeric dates respect the workbook's date system
Formula cells need a loaded or calculated cache; filtering does not silently recalculate the workbook
Resource limits
| Option | Default | Meaning |
|---|---|---|
| MaxXmlCharacters | 1048576 | Filter metadata text |
| MaxXmlNodes | 16384 | Parsed filter metadata nodes |
| MaxFilterItems | 4096 | Represented filter items |
| MaxExaminedCells | 4000000 | Cell reads during execution |
| MaxEffectiveFormatCells | 1000000 | Effective appearance evaluations |
| MaxPopulationValues | 1000000 | Collected ranking or average values |
| MaxContextBytes | 67108864 | Logical retained context and reserved temporary allocation envelopes |
| MaxConditionalSteps | 16000000 | Shared work for conditional evaluation, observed formatting, population sorting and selection-token comparison/insertion |
These are explicit positive bounds; MaxContextBytes measures logical ownership and reserved temporary envelopes rather than process RSS or cumulative allocator traffic
OnWork is a TXLSXAutoFilterWorkEvent callback with the worksheet as Sender, examined cells as ACompleted and a mutable cancellation flag; ACompleted may stay unchanged while formatting or planning consumes work
The operation holds a workbook read lease while preparing decisions, so callbacks must not mutate that workbook; cancellation and callback exceptions propagate to the caller
Exceptions and current boundaries
EXLSXAutoFilterExecutionreports invalid execution stateEXLSXAutoFilterUnsupportedreports malformed or unsupported filter and appearance metadataEXLSXAutoFilterLimitreports an exceeded resource boundEXLSXAutoFilterCancelledreports work cancellation
Unsupported conditions fail explicitly rather than guessing a matching row set, including unknown filter extensions/calendars, unresolved differential styles or appearance colors, unsupported conditional metadata and external conditional compilation
Linear and path gradient fills do not match solid-color or NoFill criteria, including their gradient-stop colors; an effective conditional solid-fill override still participates in matching; ordinary rich-text font color filters match any nonempty run with a represented RGB, automatic or inherited base color
Color filters use direct cell styles and supported conditional overrides; visual fill and font colors supplied only by built-in or custom table styles do not participate, matching native Excel filtering; icon filters evaluate conditional icons directly
Unknown rich-text structure or color metadata fails explicitly; known non-color metadata such as font family, charset and scheme does not by itself prevent a color-only match
Represented rich-text font colors also support conditional formatting, including rules that change only fill; explicit run colors remain effective, while runs without an explicit color inherit the supported conditional or ordinary base font color
Rich-text scanning reserves bounded scalar storage and reacquires the run count after its reservation work callback, then snapshots only colors and nonempty flags without copying text or font names; source growth beyond that reservation detected when reacquiring the runs raises EXLSXAutoFilterLimit, while later callbacks traverse the owned snapshot
Conditional rich-text row decisions
Native color filtering can reuse a result between equal-text rich and plain cells according to their base style and matching conditional rules, so the visible row set can depend on the order of those cells
HotXLS prepares the complete data range in ascending row order, even for AutoFilterRowVisible, so row inspection, preview and application use the same decisions
A matching conditional-rule path and the same represented base style allow reuse of the most recent result for the exact text; a different style or rule path computes a new result, and a row with no matching conditional rule always uses fresh ordinary matching
Conditional rules with identical resulting colors retain distinct rule identities, while equivalent stored base styles are compared by their represented content rather than their pool indices
The preparation preserves case and every UTF-16 text unit, uses detached scalar decisions and remains bounded by the shared cell, formatting, work and context limits
Non-string values use fresh appearance matching; unknown rich-text colors, unresolved styles and unmodeled conditional metadata retain their explicit rejection behavior
Guarded formatter and calculation consumers
TXLSFormater.CreateObserved(AWork, ABudget) preserves ordinary formatting behavior while exposing work notifications and temporary byte reservations; TXLSFormater.ObservedPendingBytes is valid during the budget callback and resets afterward, and either callback may stop formatting by raising
The observed formatter snapshots the locale fields needed by its date mask before later work callbacks, including owned era metadata where supported; ordinary construction retains its existing behavior
The formatter also reports the color requested by the last formatted value: LastColor returns it in $00BBGGRR layout and HasLastColor stays False when the number format asked for no color; both are valid immediately after GetDisplayValue or FormatDouble returns, and RememberColor maps a #RRGGBB literal, or one of the eight named bracket colors (red, green, blue, cyan, magenta, yellow, white, black), onto that layout
The formatter likewise reports the fill character of the last formatted value: a *x repeat in the number format fills the remaining cell width with x, HasFillCharacter stays False when the format has no fill or the value was formatted as HTML, FillCharacter returns that character, and FillCharacterIndex is the number of characters of the returned text before the place where the repeats go. The returned text carries no copy of the repeats, so only a renderer that knows the cell width can expand them, and width-less output such as the TEXT function or plain display strings simply leaves the fill out; all three are valid immediately after GetDisplayValue returns
StringToHTML escapes ampersands, angle brackets and double quotes into entities and converts CR/LF pairs and lone CR characters into <br>, so previously formatted text can be embedded directly; ISRightHAlign reports True for Boolean, empty, null, integral, floating-point and currency Variants and False for text, matching the natural horizontal alignment Excel uses for those value types
Windows raw varDate conversion retains the platform Variant/OLE path; the FPC branch observes its existing time-only or general date/time conversion
TXLSCalcEvalState.ResourceObserver (handler type TXLSCalcResourceObserver, receiving cumulative reserved allocation bytes and work units as Int64 values) supplies work and allocation reservations for guarded formula consumers, with unchanged ordinary behavior when no observer is assigned; the observer and reference-date hooks do not automatically impose workbook-wide memory limits
TXLSCalcEvalState.ReserveAllocation(ABytes) checks a nonnegative reservation and notifies the observer; False reports an exhausted or cancelled state, and callback exceptions propagate
TXLSCalcEvalState.ReserveValueCopy(AValue) reserves a conservative copy envelope for supported scalar values and one- or two-dimensional arrays; False also reports unsupported by-reference, nested-array or element representations
TXLSCalcEvalState.ResourceReferenceDate sets the stable date used by guarded formula evaluation; configure the evaluation state before assigning the observer and reference date, since Configure resets both hooks
Guarded evaluation drives its budget through the state: BeginFormula and EndFormula bracket a compiled formula's evaluation and track recursion depth, with BeginFormula refusing entry once the depth ceiling is reached, ConsumeStep and ConsumeSteps(ACount) charge work through the observer and answer False for a negative count, an exhausted step budget or a latched limit, IsCancelled reads the shared cancel flag and MarkResourceLimit latches the exhausted state that makes later step or value reservations fail without touching the model
Evaluation caches are addressed by change identifier: TryGetFormulaValue, StoreFormulaValue and ClearFormulaValue handle ordinary compiled formulas, while TryGetArrayValue and StoreArrayValue do the same for array formulas; FormulaCount, ArrayCount and MaxArrayBytes report the live cache sizes and the configured allocation envelope, AllowUnsafeFormulaCallbacks and ProjectBlankResults echo the options that were configured, and ResourceLimitExceeded reports whether the limit has already been latched; Clear resets hooks, observed formulas and cached entries together
Related filter storage is documented under TXLSXAutoFilterColumn and TXLSXAutoFilterColumns