HotXLS Docs

Formula Tracing and Auditing

Overview

Debugging formula networks in large Delphi models means tracing how cell values flow from input variables to summary aggregations; HotXLS offers auditing APIs to trace formula precedents and dependents step by step

Formula Tracing API

TXLSFormulaTracer reduces a formula from its innermost expressions and records source spans, substituted expressions, intermediate values, step kinds and exact operand-stack state before and after each step

TXLSFormulaStepKind = (stPush, stReduce, stFunction);

TXLSFormulaStep = record
  Depth: Integer;
  Source: WideString;
  Expression: WideString;
  Value: Variant;
  StepKind: TXLSFormulaStepKind;
  StackBefore: WideString;
  StackAfter: WideString;
  TokenStart: Integer;
  TokenEnd: Integer;
end;
        

Source is the original sub-expression text, Expression substitutes already-evaluated operands with their values, and Value is the step result; StackBefore / StackAfter are comma-separated operand-stack snapshots and TokenStart / TokenEnd pin the step to a 1-based character span in the source formula

Trace and TraceReversed hand back the immutable steps as a TXLSFormulaStepArray, a dynamic array of TXLSFormulaStep records; TraceReversed presents the same data in reverse evaluation order for step-back interfaces

Interactive Debugger

TXLSFormulaDebugger builds a complete parsed-node model and then records actual execution without evaluating the lazy branches that go unselected

TXLSFormulaDebugNodeKind = (fdnNumber, fdnString, fdnBoolean, fdnReference,
  fdnRange, fdnParentheses, fdnUnary, fdnPercent, fdnBinary, fdnFunction);
TXLSFormulaDebugState = (fdsPending, fdsEvaluated, fdsSkipped, fdsError);
TXLSFormulaDebugBranch = (fdbNone, fdbIfTrue, fdbIfFalse, fdbIfErrorValue,
  fdbIfErrorFallback, fdbChoose, fdbIfs, fdbSwitch);
TXLSFormulaDependencyKind = (fdkCell, fdkRange, fdkDefinedName);
        

The returned session exposes operands, intermediate values, source spans, static dependencies, evaluation order, branch choices, skipped nodes, standard formula errors and propagated error origins. Each TXLSFormulaDebugNode reports its tree position (NodeId, ParentNodeId, Depth), Kind and State, source span, operand node ids and values, the taken Branch, and the recorded error triplet (ErrorCode, ErrorText, ErrorOriginNodeId); each TXLSFormulaDependency reports Kind plus the resolved sheet, reference text, bounds and evaluation state of one precedent

Cursor methods let an application move forward or backward through the session, or seek a single node without recalculating the formula

Auditing Features

Check the key interfaces for formula auditing below