/** * Cell formula types and CT_CellFormula parse/serialize (text only). * * Citations: * - ECMA-376-1 §18.3.1.40 `f`; §18.18.6 ST_CellFormulaType * - transitional sml.xsd CT_CellFormula / ST_CellFormulaType * - docs/specs/cell-formulas.md; docs/ooxml-mapping/cell-formulas.md * * Never evaluates formulas. Never resolves external workbook links. */ /** * SpreadsheetML `ST_CellFormulaType` values. * * Citation: transitional sml.xsd ST_CellFormulaType enumerations. * * @private */ export declare type CellFormulaType = 'normal' | 'array' | 'dataTable' | 'shared'; /** * Full formula view including shared/array metadata. Prefer public * {@link Cell.formula} for normal expression text. * * @private */ export interface CellFormula { /** * Expression text as stored in `f` character content. * Excel stores the expression without a mandatory leading `=`. */ readonly expression: string; /** Formula type; default/omitted on wire is `normal`. */ readonly type: CellFormulaType; /** Array/shared master range (`f@ref`) when present. */ readonly ref?: string; /** Shared formula group index (`f@si`) when present. */ readonly si?: number; /** * Other `f` attributes preserved for round-trip * (aca, ca, bx, dt2D, dtr, del1, del2, r1, r2, and unknowns). */ readonly extraAttributes?: Readonly>; } /** * Options for internal {@link Cell.setFormula}. * * @private */ export interface SetFormulaOptions { /** Formula type; default `normal`. */ readonly type?: CellFormulaType; /** Array/shared master range. */ readonly ref?: string; /** Shared formula group index. */ readonly si?: number; /** * When true (default), clear the cached calculated value so Excel recalculates. * When false, leave any existing `v` / type payload unchanged. */ readonly clearCachedValue?: boolean; /** * Extra `f` attributes to emit. Prefer typed `type` / `ref` / `si` * for those fields. */ readonly extraAttributes?: Readonly>; } /** * Options for internal {@link Cell.clearFormula}. * * @private */ export interface ClearFormulaOptions { /** * When true, also clear the cached value payload. * Default false — leave `v` if present. */ readonly clearCachedValue?: boolean; } /** * Internal mutable formula state on {@link CellModel}. * * @private */ export interface CellFormulaState { expression: string; type: CellFormulaType; ref: string | undefined; si: number | undefined; /** Preserved non-primary attributes (local name → value). */ extraAttributes: Record; /** True when authored/mutated via API this session. */ dirty: boolean; } /** * Whether `value` is a known ST_CellFormulaType. * * @private */ export declare function isCellFormulaType(value: string): value is CellFormulaType; /** * Convert internal state to the public readonly view. * * @private */ export declare function formulaStateToPublic(state: CellFormulaState): CellFormula; /** * Parse a full `…` (or self-closing) element into structured state. * Does not evaluate. Shared/array slaves may have empty expression. * * @private */ export declare function parseFormulaXml(fXml: string): CellFormulaState; /** * Serialize structured formula state to a `…` element string. * Omits default `t="normal"`. Expression is XML-escaped. * * Citation: CT_CellFormula attribute order in transitional sml.xsd. * * @private */ export declare function serializeFormulaXml(state: CellFormulaState): string; /** * Build state from setFormula arguments (caller validates expression/type). * * @private */ export declare function createFormulaState(expression: string, options?: SetFormulaOptions): CellFormulaState; /** * Strip a single leading `=` convenience prefix from caller text. * Does not strip `+`/`-`/`@` — those remain part of the expression. * * @private */ export declare function normalizeFormulaExpression(expression: string): string;