ReadonlyisFor runtime type checking.
ReadonlyisFor runtime type checking.
ReadonlyisFor runtime type checking.
Add Listeners.
Optionaloptions: IListener.OptionsAttempt Excel-style Formula AutoCorrect on an invalid formula.
A corrected, DETACHED formula (not committed anywhere — the same shape
ICalculation.createFormula returns, anchored at this formula's cell), or
null when this formula is already valid or no safe correction exists.
Currently ONE deliberately narrow rule: append the missing trailing closers (], ), }) —
=SUM(A1:A2 → =SUM(A1:A2), =SUM(Sales[Amount → =SUM(Sales[Amount]) — and only when the
repaired text parses clean. Excel closes parens and braces but not a structured reference's
brackets. A repair that
would still be invalid (=SUM( → =SUM() fails arity) is never returned, nor is anything
attempted for over-closed / interleaved brackets or an unterminated string. Never mutates
this formula. Interactive hosts call this at commit; programmatic writes (setValue, file
load) never auto-correct.
Batches all 'transactional' changes until they have all be committed or rolled back.
Optionaloptions: string | ITransaction.OperationOptions
Description of the operation or additional options. Used for tracking undo/redo and history. Default Value User Operation.
Any changes that are made to this object will be reflected in the local record but not committed to the transactional store until the batch is popped.
Useful for operations that are longer running but generally not recommended as it keeps a transaction open. doBatch is the preferred option.
Close the record and cleans resources. Can't be undone.
Removes this named formula from its collection.
Provides a mechanism to perform a set of operations in a batch.
A callback that performs multiple operations all within the same transaction.
Optionaloptions: string | ITransaction.OperationOptions
Description of the operation or additional options. Used for tracking undo/redo and history. Default Value User Operation.
Return the value for a formula.
Optionaloptions: number | EvaluateOptionsThe cell this formula is anchored at — the cell its relative references are written from.
A1 in a formula anchored at B1 means "the cell to my left"; the same text anchored at
B6 means "five rows up and one left". The anchor is what makes that text unambiguous, and
a caller re-siting a formula (shift) needs it to know where it is starting from.
null for a formula with no cell of its own — a temporary formula created without coords,
which evaluates in a virtual space.
Returns the status.
Pending for a formula the engine has not compiled yet (see isCompiled).
The comment, or null if none has been set.
The transitive downstream of this name — everything that would recalculate if its expression changed, cells and names both.
getDirectDependents walked to exhaustion across BOTH graphs (the symbol edges names
ride on, and the ordinary cell graph between them), and the same distinction the cell family
draws (ICell.getDependents). Direct is the blast radius of DELETING the name (those
dependents go #NAME?); this is the blast radius of REDEFINING it.
With Outer = Mid*3 and Mid = Base*2, Base reports Mid and Outer as name nodes plus
every cell downstream of either. A cycle terminates and reports the names on it, this one
included.
What references this SYMBOL — cells and names, one answer; null when nothing does. Asked of
the engine, as ICell.getDirectPrecedents is.
Symbol-level, not target-level. =SUM(Revenue) is a dependent of Revenue;
=SUM(Sales!$B$2:$B$100) is not, even where that is exactly what Revenue designates. So
named.getRanges()?.getDirectDependents() is not a substitute — it answers the address
question, and for a name holding an expression (TaxRate = 0.21) there are no ranges to ask
at all.
A dependent NAME rides in the same collection as an INamedRange node: with
Doubled = Base*2, Doubled is a dependent of Base as surely as any cell that names it —
delete Base and every cell reading Doubled goes #NAME? too, without ever having
mentioned Base. Such a member carries the isINamedRange brand; its coords are the name's
ANCHOR (its defining cell), never a target, so lead with getName() when displaying one.
This is the "is it safe to redefine or delete this name?" primitive: these are precisely the
dependents that go #NAME? if the name is removed — an answer with no members at all
(null) is the only genuinely-unused reading. The engine already tracks both edges — a name
compiles into its own grid, and every formula that mentions one carries its id — so this is
a door onto existing bookkeeping.
Cells are reduced to regions rather than listed per cell, exactly as ICell.getDirectDependents does: a column of 400 formulas reading the name comes back as one range. Name nodes lead, cells follow.
What this name's body reads — cells and names, one hop, one answer; null when it reads
nothing.
The precedent half of the same four graph methods ICell exposes, resolved at the DEFINING anchor (the cell the body was authored from) — the same answer the Name Manager gives, since a name with relative references has no one answer until applied somewhere.
A name the body reads rides in the collection as an INamedRange node, exactly as in
getDirectDependents — Doubled = Base*2 reports the Base node plus whatever
cells the body reads directly. Contrast IFormula.getReferences: that is the ordered,
index-aligned reference list (the setReferenceAt currency, #REF! slots included); this
is the graph answer.
Return the formula's expression — the text WITHOUT a leading =.
Optionaloptions: FormulaTextOptions
Options for converting the formula to text.
One shape for every kind of formula, a cell's and a defined name's alike. It is the STORED
shape, which is what OOXML <f> and <definedName> hold and what setExpression
takes back, so read/modify/write needs no adjusting in between.
The form with the leading = — what Excel's API answers (Range.Formula) and what a cell
is entered with — is ICell.getFormulaText.
The text is the storage form (English names, , separators) whatever language or locale is
active. For the form a person reads or edits, pass { target: 'display' }.
A unique stable id.
OptionalgetA reference to a part of this item that the given coords designate exactly, or null.
The coords to match, sheet-qualified (scope) and in row-first order.
Optionalhome: CellCoords | null
The cell of the formula the reference is for, when there is one. A reference can be
written relative to it: Sales[@Amount] for a table cell in the formula's own row, and from
inside the table [@Amount] and [Amount].
Backs INamedCollection.getByRanges with includeParts. Some named things address
regions that are not themselves names: a table's column is written Sales[Amount], its header
row Sales[#Headers]. Those are structured references, not entries in the collection — there
is no INamed to return for one, which is why this returns text rather than an item.
Implemented by whatever owns the parts (a table), so the collection stays out of the business of knowing what kinds of items have insides.
Everything upstream of this name — getDirectPrecedents walked to exhaustion.
The walk unions the body's cell-graph precedents with every name the body reaches through
the symbol graph, each contributing its own body's walk; a cycle terminates and reports the
names on it. One hop it deliberately does not flatten: a name referenced by an UPSTREAM
CELL (X = A1*2, A1 = SomeName) is that cell's precedent, not this answer's — a tree
walk crosses it through the cell's own ICell.getDirectPrecedents.
The ranges this name designates, or null when it holds an expression.
Required here — every named formula answers (with null unless
IFormula.isReferenceOnly holds), unlike the broader INamed.
Returns an ordered list of ranges referenced in this formula.
The sheet name this formula is scoped to, or null for global scope.
Return the formula as an array of tokenized values.
OptionalevalIndex: number
Allows for a partial evaluation based on a token index.
The underlying item that is being referenced.
Immutable
What T is depends on getType, and for the common case it is text. A defined name
(type 'formula') is an ICalculation.INamedFormula, so this is its refers-to
EXPRESSION as a string with no leading = — Sheet1!$B$4, or 0.21 for a name holding a
constant. A table's is the ITable. It is never the target: the string Sheet1!$B$4 is
what the name says, not the cells it designates and not what they contain.
The two questions this is mistaken for have their own calls:
null for a name holding an expression.ICalculation.IFormula.evaluate(), which every named
formula has. Returns a Scalar for a value name and an IRange for a reference one, so
there is no parse-the-text-and-re-query hop. Note that a name written with relative
references evaluates per calling CELL, so its one anchored answer is not the answer every
dependent sees.Every committed update gives the record a new, strictly increasing version id.
Used with getId to uniquely identify a version of the record.
The id is an identity, not a per-record count: ids are drawn from a single store-wide sequence bumped once per commit, so all records written in the same commit share an id and a given record's ids increase but are not sequential.
Records are immutable so a restore/revert doesn't change them — it repoints, and the version id reported is the one for the snapshot the store is currently at. Version ids are never reused: a write after an undo receives an id higher than any previously issued, so a stale reader can always detect the change.
Whether any reference in this formula is unresolvable — #REF!.
Asks the compiled references, not the text: a "#REF!" STRING literal in the formula is
not a reference error. A reference degrades to one when its target is deleted, or when a
shift pushes a relative reference above or left of the sheet.
Returns true if no more operations are allowed.
Whether the calculation engine has compiled this formula.
A formula is model state: it is stored, and reads back, the moment it is set - in every
engine state, a stopped or never-started one included. The COMPILED body arrives when the
engine gets to it. Until then this is false; getExpression answers from the text as
written, getTokens is empty, getReferences is null, a reference edit
throws, and evaluate waits for a Starting engine and rejects on an Off one rather
than starting it. The handle heals: it reads the engine's block the first time one exists, so
one taken cold is fully functional once the engine has compiled the cell.
A formula created detached (ICalculation.createFormula) or a defined name is
compiled on creation and is always true.
If the model unable to be modified.
If true the name is not shown in the UI. This does not affect resolution in formulas.
If the model unable to be modified.
Returns true if the formula consists entirely of cell or range references and
range operators (:, , #, etc.) with no function calls or computed expressions.
Whether the formula text parsed without error. false for an in-progress / malformed formula
(=SUM(, =A1:, =1+) — the parser recovered a best-effort token stream but the input isn't a
complete expression. This is a PARSE concern only: a well-formed formula that evaluates to an error
(=1/0) is still valid. Lets an editor flag "more input expected" without re-parsing.
Returns true if this formula contains one or more volatile functions
(e.g. NOW, RAND, OFFSET, INDIRECT).
isVolatile() is true should not be used as
navigation targets even if isReferenceOnly() returns true, since their
resolved range may differ by context.false
while the engine is Off.Selects the current item.
Optionaloptions: ITypes.SelectOptionsAn async INamed.
The comment for the defined name.
Optionaloptions: ITransaction.OperationOptionsRedefines the expression this name is bound to.
Optionaloptions: ITransaction.OperationOptionsOptionaloptions: ITransaction.OperationOptionsRequired here — every named formula supports hiding, unlike the broader INamed.
Replaces a specific reference in the formula with a new one.
The zero-based index of the reference to be updated (from getReferences()).
The new address or range to occupy that position.
Optionaloptions: string | ITransaction.OperationOptions
Optional transaction or operation options.
Cycles the absolute/relative ($) style of the reference at the specified index.
The zero-based index of the reference to be cycled (from getReferences()).
Optionalside: ReferenceSide
Which part of the reference to cycle (relative to a range operator :):
'self' (default) — the reference has no range operator (a single cell); cycles the whole
reference as a unit, keeping it a single cell.'left' — the left operand of a range (the "start" corner).'right' — the right operand of a range (the "end" corner).
A single-cell range (e.g. A1:A1) is still a range — it has a 'left' and a 'right', so
it is NOT 'self'. That distinction only survives in the tokens (see FormulaToken.refSide).Optionalmode: number
Optional target mode. If omitted, cycles to the next mode in the sequence.
Optionaloptions: string | ITransaction.OperationOptions
Optional transaction or operation options.
This formula as it would read at target: a DETACHED copy, filled.
The cell the copy is anchored at.
The filled copy, or null when this formula has no compiler behind it to mint one.
Excel's fill/copy, not its move: relative references follow the formula to its new home
and absolute ($) ones stay put, so the copy means at target what this one means at its
own anchor. A1*2 anchored at B1, shifted to B6, is A6*2.
The distinction matters and is easy to invert. Re-compiling getExpression's text at another cell keeps the TEXT and changes the meaning — that is a move, and a formula that meant "myself" starts meaning "some cells up". This keeps the meaning and changes the text.
Nothing is committed; the copy is anchored at target whether or not anything lives there.
A defined name owned by the calculation engine.
Remarks
Extends INamed so calc's items can flow through the aggregating
INamedCollectionwithout an adapter — an adapter would carry a second copy of each name's state, which is the duplication defined-name ownership exists to remove.It is both: a name (
getName,getScope,isHidden) and the formula that name is bound to (getText,getReferences,evaluate).INamed.getRangesarrives fromINamedand is meaningful exactly when IFormula.isReferenceOnly holds.