TXLSFormulaEmptyStringMode = (xlfesmClearCell, xlfesmPreserveString); TXLSFormulaUnknownSymbolMode = (xlfusmReject, xlfusmPreserve); TXLSFormulaEntryPolicy = record EmptyStringMode: TXLSFormulaEmptyStringMode; UnknownFunctionMode: TXLSFormulaUnknownSymbolMode; UnknownNameMode: TXLSFormulaUnknownSymbolMode; end; property FormulaEntryPolicy: TXLSFormulaEntryPolicy;
IXLSWorkbook and TXLSWorkbook expose the property together with TXLSXWorkbook; XLSDefaultFormulaEntryPolicy clears empty input and rejects unknown functions and unknown defined names
EArgumentOutOfRangeException without changing the previous policy
function ValidateFormulaEntry(Row, Col: Integer; const Formula: WideString): TXLSFormulaEntryValidationResult; TXLSFormulaEntryValidationResult = record Issue: TXLSFormulaEntryIssue; Action: TXLSFormulaEntryAction; Symbol: WideString; end;
Issue distinguishes no error, unknown function, unknown name, syntax error, target-format limitation and invalid target coordinates
Action selects clear cell, store string, store formula, or reject, while Symbol identifies an unknown function or name when one was recognised
xlfeaClearCell or xlfeaStoreString according to EmptyStringMode="", remains a formula and returns xlfeaStoreFormula when the target format can represent it
Value property now applies this mode directly: the default clears any existing value or formula, while xlfesmPreserveString replaces the cell content with a constant string whose length is zero
Null and Unassigned always clear the cell in either mode, while a real formula such as ="" stays a formula with an independently stored or calculated empty-string result
OnUserFunction or OnUserFunctionEx callbacks count as known during validation without invoking a handler, while unregistered calls keep their function name in SymbolxlfeaReject for unknown functions or names; assigning through the normal cell Formula property rejects before changing the value, formula cache, or dependencies
xlfeiTargetFormatUnsupported when the expression cannot be represented, while XLSX accepts the known modern formula functions its formula model supports
LAMBDA, lexical LET callables, defined names that refer to lambdas, report placeholders, registered external workbook links and valid qualified or unqualified structured references including nested and current-row forms
$1D, the Excel #NAME? error; the same typed error carries through dependent formulas and contextual evaluation
function AuditFormulaSymbols: TXLSFormulaSymbolIssues; overload; function AuditFormulaSymbols( out AStats: TXLSFormulaSymbolAuditStats): TXLSFormulaSymbolIssues; overload; TXLSFormulaSymbolIssueKind = (xlfsiUnknownFunction, xlfsiUnknownName, xlfsiSyntaxError); TXLSFormulaSymbolLocationKind = (xlfslCell, xlfslDefinedName); TXLSFormulaSymbolIssue = record Kind: TXLSFormulaSymbolIssueKind; LocationKind: TXLSFormulaSymbolLocationKind; Sheet: Integer; Row: Integer; Col: Integer; DefinedNameIndex: Integer; DefinedName: WideString; Formula: WideString; Symbol: WideString; end;
TXLSWorkbook and TXLSXWorkbook provide the same bulk-audit overloads; each issue identifies an unknown function, unknown name, or syntax error together with either a worksheet cell location or a defined-name location, the source formula, and the unresolved symbolLocationKind = xlfslCell) or a defined-name location (LocationKind = xlfslDefinedName), the source formula, and the unresolved symbol
EntryCount reports audited formulas, UniqueFormulaCount reports formulas compiled or inspected independently, and CacheHitCount reports repeated entries served by the operation cache
Even where the calling worksheet has no definition with that spelling, version 2.384.520 resolves an explicitly qualified defined name in the target worksheet scope
For example, Auxiliary!LocalOnly, 'Aux input'!LocalOnly and 'Aux''s input'!LocalOnly pick the target-local definition, even if a caller-local or workbook-scoped name shares that spelling
Qualified range-based and chained names work in arithmetic and function arguments; a successful target lookup clears only its abandoned suffix diagnostic, whilst genuine unresolved names remain rejected under the selected entry policy
Formula spelling and defined-name scope survive XLSX saving and reopening; quoted worksheet names that contain an exclamation mark still need a separate lexer repair, so this extension does not cover them
Version 2.384.522 preserves quoted worksheet names containing ! and doubled apostrophes across formula entry, evaluation and saving, covering worksheet-scoped defined names, single cells, ranges and function arguments
The target is decided by the actual separator outside the quoted name, so a newly added worksheet whose name is a longer match cannot redirect an existing quoted reference
For example, 'A!B'!LocalOnly resolves the name on worksheet A!B, whilst 'O''Brien!X'!A2 retains the escaped apostrophe and separator inside its worksheet name
Quoted worksheet pairs also tell single cells apart from rectangular ranges: with worksheet A!B followed by worksheet C, SUM('A!B:C'!A2) sums cell A2 across that sheet interval, whilst SUM('A!B:C'!A1:A2) sums the actual rectangular range
Stored formulas retain their input spelling across saving and reopening, ordinary string literals retain their exclamation marks, and genuine missing names, missing worksheets and malformed extra separators retain strict refusal behaviour
Existing external-workbook syntax controls retain their previous behaviour; these local-reference checks do not establish unrestricted external-link execution
Policy := Workbook.FormulaEntryPolicy;
Policy.UnknownFunctionMode := xlfusmReject;
Policy.UnknownNameMode := xlfusmReject;
Workbook.FormulaEntryPolicy := Policy;
Validation := Sheet.ValidateFormulaEntry(4, 2, FormulaText);
if Validation.Action = xlfeaStoreFormula then
Sheet.Cells[4, 2].Formula := FormulaText;
Issues := Workbook.AuditFormulaSymbols(Stats);
for I := 0 to High(Issues) do
if Issues[I].Kind = xlfsiUnknownFunction then
LogUnknownSymbol(Issues[I].Symbol);