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 recognized
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 removes 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 ="" remains 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 retain their function name in Symbol
xlfeaReject 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 known modern formula functions supported by its formula model
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 propagates 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 (LocationKind = 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
Version 2.384.520 resolves an explicitly qualified defined name in the target worksheet scope even when the calling worksheet has no definition with that spelling
For example, Auxiliary!LocalOnly, 'Aux input'!LocalOnly and 'Aux''s input'!LocalOnly select the target-local definition, including when a caller-local or workbook-scoped name has the same spelling
Qualified range-based and chained names work in arithmetic and function arguments; a successful target lookup clears only its abandoned suffix diagnostic, while genuine unresolved names remain rejected under the selected entry policy
Formula spelling and defined-name scope remain intact through XLSX saving and reopening; quoted worksheet names containing an exclamation mark still require a separate lexer repair and are not included in this extension
Version 2.384.522 preserves quoted worksheet names containing ! and doubled apostrophes through formula entry, evaluation and saving, including worksheet-scoped defined names, individual cells, ranges and function arguments
The actual separator outside the quoted name determines the target, so adding a worksheet with a longer matching name cannot redirect an existing quoted reference
For example, 'A!B'!LocalOnly resolves the name on worksheet A!B, while 'O''Brien!X'!A2 retains the escaped apostrophe and separator inside its worksheet name
Quoted worksheet pairs also distinguish single cells from rectangular ranges: with worksheet A!B followed by worksheet C, SUM('A!B:C'!A2) sums cell A2 across that sheet interval, while 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 behavior
Existing external-workbook syntax controls retain their previous behavior; 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);