Formula engine
This document describes how ORIX Sheet turns formula text into a value: the parser, the abstract syntax tree (AST), the printer and its locale syntax, the evaluator, the function registry, structured references and defined names. How formulas are scheduled and recalculated is the subject of calculation-graph.md; number semantics are in ../mathematics/numerical-precision.md; the function catalogue is in ../compatibility/formulas.md.
Everything below was read in the source files named in each section. Behaviours quoted as
"formula → result" were obtained by evaluating the formula with CalcEngine.evaluate in a throw-away
executable linked against Packages/SheetEngine on 2026-11-21 (debug build); they are observations of the
current code, not statements about Excel unless Excel is named.
Where the code lives
| Piece | File | Lines |
|---|---|---|
AST (Expr, RangeExpr, StructuredRef, FormulaSyntax, ParseError) |
Packages/SheetCore/Sources/SheetCore/Formula/AST.swift |
156 |
Parser (FormulaParser) |
Packages/SheetCore/Sources/SheetCore/Formula/Parser.swift |
471 |
Printer (FormulaPrinter, Expr.formulaText) |
Packages/SheetCore/Sources/SheetCore/Formula/Printer.swift |
128 |
Evaluator (EvalContext) |
Packages/SheetCore/Sources/SheetCore/Engine/Evaluator.swift |
567 |
Registry (Operand, ParamKind, FunctionSpec, FunctionRegistry) |
Packages/SheetCore/Sources/SheetCore/Engine/Registry.swift |
111 |
Core built-ins (24 functions, CompensatedSum) |
Packages/SheetCore/Sources/SheetCore/Engine/Builtins.swift |
186 |
Values (Value, ArrayValue, LambdaValue, CellError, compareValues) |
Packages/SheetCore/Sources/SheetCore/Model/Value.swift |
290 |
Typed input (InputParser) |
Packages/SheetCore/Sources/SheetCore/Engine/InputParser.swift |
189 |
Reference rewriting (RefTransform) |
Packages/SheetCore/Sources/SheetCore/Engine/RefRewrite.swift |
149 |
Library bootstrap (ORIXEngine) |
Packages/SheetEngine/Sources/SheetEngine/Bootstrap.swift |
37 |
Source: wc -l on the files, 2026-11-21.
SheetCore has no package dependency. The function libraries (FunctionsNumeric, FunctionsText,
FunctionsLookup) depend on SheetCore (and FunctionsText on SheetFormat); SheetEngine depends on all
of them and only contains the bootstrap and the orix-bench executable (see the Package.swift files).
Pipeline
flowchart TD
T["Typed text<br/>(cell editor, formula bar, paste)"] --> IP["InputParser<br/>number, date, boolean, text or formula?"]
F["Formula text from a file<br/>(canonical syntax)"] --> P
IP -->|starts with = + or -| P["FormulaParser<br/>UTF-8 bytes, precedence climbing"]
P --> AST["Expr (immutable AST)<br/>stored in Formula.expr"]
AST --> PR["FormulaPrinter<br/>canonical or locale syntax"]
AST --> REG["CalcEngine.register<br/>precedents, volatility"]
AST --> EV["EvalContext.evaluate<br/>returns an Operand"]
EV --> FN["FunctionRegistry<br/>465 specs + 8 special forms"]
EV --> V["Value stored in Formula.value<br/>(arrays spill)"]
SVG fallback:
There is no separate lexer and no token array: FormulaParser is a single struct that walks the UTF-8 bytes
of the formula (private let s: [UInt8], cursor i) and builds the tree directly. There is also no
intermediate bytecode: the evaluator interprets the Expr tree.
Parser
FormulaParser.parse(_ text:syntax:) accepts the text with or without the leading = and throws a
ParseError (message + UTF-8 offset) on failure. Whitespace (space, tab, CR, LF) is skipped between tokens.
Operator precedence
| Level (low → high) | Operators | Associativity | Where |
|---|---|---|---|
| 1 | = <> < <= > >= |
left | binaryOp() precedence 1 |
| 2 | & (concatenation) |
left | precedence 2 |
| 3 | + - |
left | precedence 3 |
| 4 | * / |
left | precedence 4 |
| 5 | ^ |
left | precedence 5 |
| prefix | unary -, unary +, @ (implicit intersection) |
right (stackable: +-+3) |
parseUnary() |
| postfix | %, # (spill reference, only directly after a cell reference), : (generic range operator), (…) (invoke a lambda-valued expression) |
left | parsePostfix() |
| primary | literals, references, names, function calls, ( ), { } |
parsePrimary() |
Source: Packages/SheetCore/Sources/SheetCore/Formula/Parser.swift (binaryOp, parseBinary, parseUnary, parsePostfix).
Two consequences of this table reproduce documented Excel quirks and are deliberate (the header comment of
Parser.swift states them):
- Unary minus binds tighter than
^.parseBinaryfirst callsparseUnary, so the left operand of^already includes its sign.=-2^2→ 4,=0-2^2→ -4,=-2^-2→ 0.25. ^is left-associative. The right operand of every binary operator is parsed withprec + 1, so=2^3^2→ 64 (that is, (2^3)^2), not 512.
Comparison operators chain left to right like the others: =1=1=1 → FALSE (TRUE=1 is FALSE because
booleans and numbers never compare equal, see numerical-precision.md).
Percent is a postfix operator and can repeat: =10%% → 0.001. =5 % parses (whitespace is skipped before a
postfix operator) and prints back as 5%.
Nesting is limited to 64 levels (maxDepth); deeper formulas fail with "Formula is nested too deeply".
The counter is incremented by every parseBinary and unary-operator recursion, so parentheses, function
arguments and prefix signs all count.
Literals
- Numbers: digits, an optional decimal part and an optional exponent (
1E3,1e+20,.5,5.). The text is handed to Swift'sDouble(String); a literal that overflows (=1E400) parses to infinity and evaluates to#NUM!. There are no negative number literals outside array constants:-3is unary minus applied to 3. - Text:
"…"with""as the escaped quote. - Booleans: the bare words
TRUE/FALSEin any case.TRUE()andFALSE()are ordinary registered functions. - Errors: any
CellErrorraw value, matched case-insensitively:#NULL!,#DIV/0!,#VALUE!,#REF!,#NAME?,#NUM!,#N/A,#SPILL!,#CALC!and the ORIX extension#CIRC!. - Array constants:
{1,2;3,4}— values only (numbers with an optional sign, text, booleans, errors); rows must have the same length; an expression inside braces is a parse error.
References
| Form | Example | AST node |
|---|---|---|
Cell, with optional $ markers |
B7, $B$7 |
.cell(sheet:, CellAddr) |
| Cell range | A1:C10 |
.range(RangeExpr kind .cells) |
| Whole columns | A:C, $A:$C |
.range(kind .columns) — stored as rows 0…1 048 575 |
| Whole rows | 1:3, $1:$3 |
.range(kind .rows) — stored as columns 0…16 383 |
| Sheet-qualified | Sheet2!A1, 'My Sheet'!A1:B2 |
same nodes with sheet set |
| Generic range operator | A1:INDEX(B:B,3) |
.binary(.range, lhs, rhs) — the union rectangle of two references on the same sheet, else #REF! |
| Spill reference | F1# |
.spill(.cell) |
| Implicit intersection | @A1:A10 |
.implicit(…) |
| Structured reference | Table1[Qty], Table1[[#Headers],[Qty]:[Price]], [@Qty] |
.structured(StructuredRef) |
| Name | Rate, Sheet1!LocalName |
.name(String, sheet:) |
Source: Packages/SheetCore/Sources/SheetCore/Formula/AST.swift, Parser.swift (tryReference, scanRefPart, parseStructured, parsePostfix).
Details that matter:
- Coordinates are stored absolute and zero-based; the
$flags only record the markers and drive copy/fill adjustments (CellAddr). - The grid limits are those of OOXML: 1 048 576 rows × 16 384 columns (
Limits). A token that looks like a reference but is outside the grid is not a reference:=XFE1and=A1048577parse as names and evaluate to#NAME?. - Reversed whole-row / whole-column ranges are normalized at parse time:
=B:Aprints back asA:B,=SUM(2:1)asSUM(1:2). - A quoted sheet name uses
''for an embedded apostrophe. The printer quotes a sheet name unless it is a plain identifier that could not be mistaken for a cell reference (FormulaPrinter.quoteSheet). - Function names are uppercased and the OOXML prefixes
_xlfn._xlws.,_xlfn.,_xlws.and_xll.are stripped at parse time (canonicalFunctionName), so the AST never contains them. Whether they are written back on XLSX export is a SheetIO matter (see ../compatibility/excel.md). - An omitted argument is kept as
.missing(PMT(a,b,,d),IF(1,,5), also a trailingSUM(A1:A3,,)).
Not parsed
These constructs are not implemented in the parser; they produce a ParseError (and
CalcEngine.evaluate(text) then returns #NAME?, setFormula returns false):
| Construct | Example | Observed |
|---|---|---|
| Intersection operator (space) | =A1:B2 B2:C3 |
parse error "Unexpected 'B'" |
| Union operator (comma inside parentheses) | =SUM((A1,B2)) |
parse error |
| 3-D references | =Sheet1:Sheet3!A1 |
parse error |
| External workbook references | =[Book1.xlsx]Sheet1!A1 |
parse error (the bracket is read as a structured reference) |
| R1C1 notation | =R1C1 |
parsed as a name → #NAME?; INDIRECT(text, FALSE) → #REF! |
| OpenFormula range dot | =A1.A3 |
parse error |
Source: probe run on 2026-11-21; Parser.swift has no code path for these forms and Builtins.swift rejects R1C1 in INDIRECT.
Because there is no union operator, AREAS always returns 1 and INDEX accepts but ignores an area_num
argument (see ../compatibility/formulas.md).
AST
Expr is an indirect enum, Sendable and Hashable, with 18 cases: number, text, bool, error,
missing, array, cell, range, name, structured, unary, percent, binary, call, invoke,
spill, implicit, paren. Parentheses are kept as a node so that the printer reproduces what the user
typed. Two helpers exist: walk (pre-order visit) and map (bottom-up rebuild), plus functionNames.
The tree is immutable and locale independent. A cell holds a Formula object (Model/Workbook.swift) with
the expr, the last computed value, the current spill area and the scheduling state. Rewriting a formula
(row insertion, fill, paste) always creates a new Formula object, which keeps undo snapshots valid.
Printer and locale syntax
Expr.formulaText(syntax:) produces the text without the leading =. Binary operators are written without
spaces, function names in upper case, numbers that are integers below 1e15 without a decimal point and other
numbers with Swift's shortest round-trip description (e replaced by E). The original spacing and the case
of function names are not preserved (=sum( A1 , 2 ) prints as SUM(A1,2)); the case of names is.
FormulaSyntax carries four separators. Two presets exist:
| Preset | Argument separator | Decimal separator | Array column separator | Array row separator | Example |
|---|---|---|---|---|---|
.canonical |
, |
. |
, |
; |
=SUM(1.5,2) |
.semicolon |
; |
, |
. |
; |
=SUM(1,5;2) |
Source: Packages/SheetCore/Sources/SheetCore/Formula/AST.swift (FormulaSyntax).
FormulaSyntax.forLocale selects .semicolon when the locale's decimal separator is a comma, .canonical
otherwise. The canonical form is the one stored in files and used internally (defined-name formulas,
conditional-format and validation formulas, INDIRECT text are always parsed with it). The session parses
what the user types and prints what the formula bar shows with the syntax of its locale
(WorkbookSession.syntax), so the same stored formula reads =SUM(1.5,2) or =SUM(1,5;2).
Limits of the locale layer, stated plainly:
- Function names are not translated.
SOMMEis notSUM; names are English in every locale. - Only the separators change.
InputParseradditionally acceptsVRAI/FAUXas typed boolean values, but inside a formula onlyTRUE/FALSEare booleans. - The text and date functions are registered once with the en-US format locale
(
ORIXEngine.bootstrapcallsTextFunctions.register()whose default islocale: .enUS), independently of the interface language.
Typed input
InputParser.parse decides what a typed string is, in this order: empty → blank; leading apostrophe → text;
leading = (and more than one character) → formula, a syntax error is thrown to the editor; leading + or
- that is not a number and parses as a formula that is not a plain name → formula; TRUE/VRAI,
FALSE/FAUX → boolean; an error literal → error value; a number (grouping, currency symbol, percent,
parentheses, exponent) → number with a suggested number format; a date or time → serial number with a
suggested format; anything else → text. This path is only used for interactive typing and text paste; file
importers have their own rules (see ../compatibility/formats.md and
../security.md for formula injection from CSV).
Evaluator
EvalContext holds the state of one evaluation thread: the workbook, the registry, the sheet and cell of the
formula being evaluated, the now timestamp shared by every NOW()/TODAY() of one pass, the lexical
environment of LET/LAMBDA (env), recursion counters and small caches (sheet-name index, parsed defined
names). It is documented as not thread-safe: one context per thread.
Operands
evaluate(_:) returns an Operand, not a value:
| Operand | Meaning |
|---|---|
.value(Value) |
a scalar, an array (ArrayValue, row-major, never nested) or a lambda |
.ref(AreaRef) |
a rectangle on a sheet — not yet read |
.missing |
an omitted argument |
Source: Packages/SheetCore/Sources/SheetCore/Engine/Registry.swift.
Keeping references unread until a function asks for them is what makes whole-column arguments cheap and
lets INDEX, OFFSET, INDIRECT, XLOOKUP, IF, CHOOSE, IFERROR and LET return references. A
reference is turned into a value by one of the context helpers:
| Helper | Behaviour |
|---|---|
deref |
single cell → its value; multi-cell range → array (1×1 collapses to a scalar) |
scalar |
top-left value |
array |
dense matrix; whole rows/columns are clamped to the used range of the sheet (effectiveRange); more than 20 000 000 cells → #CALC! (maxMaterializedCells) |
forEachValue |
visits only the stored, non-blank cells (order unspecified) |
forEachNumber |
the aggregate rule of SUM/AVERAGE: in references and arrays only numbers count (text and booleans ignored); direct arguments are coerced (TRUE → 1, "3" → 3, other text → #VALUE!); errors propagate |
Source: Packages/SheetCore/Sources/SheetCore/Engine/Evaluator.swift.
Every helper that reads cells first calls the engine hook ensureClean(area), which computes any formula in
that area that is still dirty (see calculation-graph.md).
Operators, lifting and broadcasting
Unary minus, percent and all binary operators except : dereference their operands and are applied
element-wise:
lift1maps a unary operation over an array; an error element stays that error.lift2broadcasts a binary operation. Two arrays produce an array ofmax(rows) × max(cols); a dimension of size 1 is repeated; positions outside a larger-than-1 dimension give#N/A(pick). An error in either operand wins, left operand first:=#N/A+#DIV/0!→#N/A.- Arithmetic coerces with
Value.num()(blank → 0, TRUE → 1, numeric text → number, other text →#VALUE!), concatenation withValue.str(), comparisons usecompareValues. The exact rules are in numerical-precision.md. - Division by zero is
#DIV/0!;0^0is#NUM!;0^negativeis#DIV/0!; any non-finite result is#NUM!(Value.num(_:)).
A formula whose result is an array of more than one element spills; there is no legacy
"implicit intersection unless array-entered" mode and no {=…} array-formula entry. @ is available to
request intersection explicitly: for a one-column range it picks the row of the formula's cell, for a
one-row range its column, otherwise #VALUE!; applied to an array value it takes the top-left element.
Function calls and argument lifting
evalCall resolves a call in this order:
- the eight special forms (below), matched by name before anything else;
- a
LET/LAMBDAvariable of that name holding a lambda (env); - a registered function (
registry.lookup); - a defined name of that name that evaluates to a lambda;
- otherwise
#NAME?.
For a registered function the argument count is checked against minArgs…maxArgs (#VALUE! when outside —
a wrong argument count is not a parse error), each argument is evaluated with evaluateArg (a thrown
CellError becomes an error value), then apply(spec, operands) runs. apply implements automatic
lifting, driven by the declared kind of each parameter:
ParamKind |
Treatment before the implementation is called |
|---|---|
.scalar |
dereferenced; an error short-circuits the whole call; an array or multi-cell range triggers lifting |
.scalarOrError |
like .scalar but error values are passed to the function |
.any |
passed untouched (reference, array, value or missing) |
Source: Packages/SheetCore/Sources/SheetCore/Engine/Registry.swift, Evaluator.swift (apply).
When at least one scalar parameter received an array, the implementation is called once per element of the
broadcast shape and the results are assembled into an array (errors per element). This is why
=LEN(A1:A3) returns three lengths and spills, without LEN knowing about arrays. FunctionRegistry.scalar
registers an all-scalar function in one line; FunctionRegistry.raw registers a function that receives the
operands as they are (aggregates, lookups, anything that needs a reference).
Special forms
Eight names are evaluated by the evaluator itself because they need lazy evaluation or bind names. They are
not in the registry (ORIXEngine.specialForms).
| Form | Behaviour implemented |
|---|---|
IF(cond, then, [else]) |
Scalar condition: only the chosen branch is evaluated, and a reference result stays a reference. Missing else → FALSE; an empty placeholder (IF(1,,5)) → 0. Array condition: both branches are evaluated and the result is built element-wise (blank elements become 0). |
IFERROR(value, alt) / IFNA(value, alt) |
alt is evaluated only when needed. Array value: element-wise replacement. A reference that is not an error is returned as a reference. |
IFS(c1, v1, …) |
Pairs evaluated in order, first true condition wins; none → #N/A; odd argument count → #VALUE!. Conditions are taken as scalars (top-left). |
SWITCH(expr, v1, r1, …, [default]) |
Compares with compareValues (text case-insensitive); an error subject propagates; no match and no default → #N/A. |
CHOOSE(index, v1, …) |
Scalar index: only the chosen argument is evaluated (references survive). Array index: every option is evaluated and the result is element-wise. Out of range → #VALUE!. |
LET(name1, value1, …, result) |
Names are bound in order in env (later values see earlier names); the environment is restored afterwards. Argument count must be odd and ≥ 3. |
LAMBDA(p1, …, body) |
Returns a LambdaValue capturing the current environment (a closure). |
Source: Packages/SheetCore/Sources/SheetCore/Engine/Evaluator.swift (evalCall); IF(1,,5) → 0, IF(0,1) → FALSE, LET(x,1,y,x+1,y*2) → 4 observed on 2026-11-21.
AND, OR, XOR, NOT are ordinary registered functions: all their arguments are evaluated (no
short-circuit).
Lambdas
- A lambda is a value (
Value.lambda), compared by identity. Parameter names are stored uppercased. - It can be invoked immediately (
=LAMBDA(x,x+1)(5)→ 6, the.invokenode), through aLETname, through a defined name (Twice(4)withTwicedefined asLAMBDA(x,x*2)→ 8), or by the lambda helper functions ofFunctionsLookup(MAP,REDUCE,SCAN,BYROW,BYCOL,MAKEARRAY). - Passing more arguments than parameters is
#VALUE!. Passing fewer is allowed: the missing parameters are bound to.missing(=LAMBDA(a,b,a+b)(1)→ 1);ISOMITTEDtests for it. - Nested lambda calls are limited to 400 (
lambdaDepth), beyond which the call returns#NUM!. Recursion through a defined name therefore terminates with#NUM!rather than a crash. - A formula whose final result is a lambda displays
#CALC!(CalcEngine.store).TYPEof a lambda is 128.
Function registry
FunctionRegistry is a lock-protected dictionary from upper-case name to FunctionSpec. A spec carries the
name, the argument-count bounds (variadic = 255), the parameter kinds, the volatility flag, a
FunctionCategory, a signature string (for example PMT(rate, nper, pv, [fv], [type])), a one-line summary
and the implementation closure (EvalContext, [Operand]) throws -> Operand.
FunctionRegistry.standard is created with the 24 core built-ins that the engine itself needs (aggregates,
logical functions, reference functions, NOW/TODAY/RAND). ORIXEngine.bootstrap() — to be called before
the first CalcEngine is created — registers the libraries once per process:
| Library | Entry point | Functions registered |
|---|---|---|
SheetCore |
CoreBuiltins.register(into:) |
24 |
FunctionsNumeric |
NumericFunctions.register(into:) |
296 |
FunctionsText |
TextFunctions.register(into:locale:) |
64 |
FunctionsLookup |
LookupFunctions.register(into:) + FinancialFunctions.register(into:) |
81 |
| Registry total | 465 | |
| Special forms (evaluator) | ORIXEngine.specialForms |
8 |
ORIXEngine.functionCount |
473 |
Source: docs/compatibility/function-registry.json, produced on 2026-11-21 by registering each library into a fresh FunctionRegistry; no name is registered by two libraries.
Registering a name twice replaces the earlier spec (dictionary assignment), so registration is idempotent. Signatures and summaries are the data behind function help in the UI and behind the generated catalogue in ../compatibility/formulas.md, which also gives the counts per category.
Extension point. A package adds worksheet functions by calling FunctionRegistry.standard.scalar(…) or
.raw(…) at start-up; nothing else in the engine has to change. Volatility is declared with
volatile: true. A function that depends on something the dependency graph cannot see (row visibility, the
clock, external state) must either be volatile or be handled like SUBTOTAL/AGGREGATE (see
calculation-graph.md).
Errors inside an implementation are raised by throwing a CellError; the evaluator converts it into an
error value at the argument or cell boundary. Any other Swift error inside a lifted element becomes #VALUE!.
Structured references
A StructuredRef stores the optional table name, the item keywords (#ALL, #DATA, #HEADERS,
#TOTALS, uppercased), the this-row flag (@ or [#This Row]) and an optional first and last column name.
' escapes special characters inside a column name. EvalContext.resolveStructured turns it into an
AreaRef:
| Reference | Rows selected | Failure |
|---|---|---|
Table1[Qty], Table1[[#Data],[Qty]], Table1 (as a name) |
data rows | #REF! when the table has no data rows |
Table1[#All] |
header, data and totals rows | |
Table1[#Headers] |
header row | #REF! when the table has no header |
Table1[#Totals] |
totals row | #REF! when the table has no totals row |
several items ([[#Headers],[#Data]]) |
the covering row span | |
[@Qty], Table1[@Qty], Table1[[#This Row],[Qty]] |
the row of the formula's cell | #VALUE! when the cell is on another sheet or outside the data rows |
[Qty]:[Price] |
columns from the first to the last named column | #REF! for an unknown column |
| no table name | the table that contains the formula's cell | #REF! when the cell is in no table |
Source: Packages/SheetCore/Sources/SheetCore/Engine/Evaluator.swift (resolveStructured).
Table names are matched case-insensitively across all sheets (Workbook.table(named:)). A structured
reference is registered in the dependency graph as the rectangle it resolves to at registration time
(collectPrecedents); the registration is refreshed whenever the graph is rebuilt (every structural edit).
RefTransform rewrites cell references, ranges and sheet-qualified names; structured-reference nodes are
left untouched because they follow the table definition, which is transformed with the sheet metadata.
Defined names
DefinedName holds a name, a formula text without = in canonical syntax (for example
Sheet1!$A$1:$B$5, 0.05 or LAMBDA(x,x*2)), an optional sheet scope, a comment and a hidden flag. Lookup
is case-insensitive; a sheet-scoped name shadows the workbook-scoped one for formulas on that sheet
(Workbook.definedName(_:sheetID:)).
Resolution of a bare name (resolveName), in order:
- a
LET/LAMBDAbinding of that name (only when the name is not sheet-qualified); - a defined name visible from the sheet — its formula is parsed (the parse is cached per context) and
evaluated in the context of the calling cell. Because AST coordinates are absolute, a reference without
$inside a name still designates a fixed cell: names relative to the calling cell are not supported; - a table of that name → its data range;
- otherwise
#NAME?.
Names may refer to other names up to 64 levels; deeper (or circular) chains give #CIRC!. When precedents
are collected for the dependency graph, names are expanded up to 16 levels.
Defining or deleting a name is a structural edit (CalcEngine.setDefinedName → structural), which
rebuilds the whole dependency graph; see calculation-graph.md for the cost.
Reference rewriting
Formulas are never edited as text. Structural operations build a RefTransform (insertRows, deleteRows,
insertCols, deleteCols, renameSheet, move, shift) and map it over the AST of each formula, creating
new Formula objects. A reference whose target is deleted becomes a #REF! literal in the tree; a range
that partly survives is shrunk (RefTransform.span). shift moves only the relative parts of references and
is what copy, paste and fill use. The same transform is applied to sheet metadata (merges, tables,
conditional-format ranges, row and column sizes) and offered to feature packages through
CalcEngine.structuralObservers so that they can remap references they store in their own payloads.
Errors
| Error | Raised by the engine when |
|---|---|
#NULL! |
never raised by the core (no intersection operator); can be typed or imported |
#DIV/0! |
division by zero, 0^negative, AVERAGE without numbers |
#VALUE! |
text that is not a number in arithmetic, wrong argument count, bad implicit intersection, too many lambda arguments |
#REF! |
unknown sheet or table, invalid structured reference, : between different sheets, deleted reference, out-of-grid OFFSET |
#NAME? |
unknown function or name; CalcEngine.evaluate(text) on text that does not parse |
#NUM! |
non-finite result, 0^0, lambda recursion deeper than 400 |
#N/A |
NA(), IFS/SWITCH without match, broadcasting past the end of an array |
#SPILL! |
spill area blocked or outside the grid |
#CALC! |
a lambda as cell result, materializing more than 20 000 000 cells |
#CIRC! |
circular reference (ORIX extension; Excel shows a warning and 0) |
Source: Packages/SheetCore/Sources/SheetCore/Model/Value.swift, Engine/Evaluator.swift, Engine/CalcEngine.swift, Engine/Builtins.swift.
ERROR.TYPE returns Excel's codes 1–7, and 9 for #SPILL!, 14 for #CALC!, 15 for #CIRC!
(CellError.typeCode).
What is not implemented
- Intersection and union operators, 3-D references, external workbook references, R1C1 notation (see "Not parsed").
- Legacy array formulas (
{=…}entered with Ctrl+Shift+Enter) as a distinct concept: every array result spills. - Translated function names and locale-specific list separators beyond the two presets.
- A compiled or vectorized evaluation path: the tree is interpreted per cell.
- A cross-cell cache for repeated lookups (stated in
Packages/FunctionsLookup/COMPATIBILITY.md). - Stale comment to be aware of:
Builtins.swiftsays the other functions live "in the SheetFunctions library"; no package of that name exists — they are inFunctionsNumeric,FunctionsTextandFunctionsLookup.