SheetXL - v0.8.0-beta.9+sites.210.e2d420901
    Preparing search index...

    Interface ICalculation

    Calculation is the process of computing formulas and then displaying the results as values in the cells that contain the formulas.

    interface ICalculation {
        isICalculation: true;
        isIModel: true;
        start: () => Promise<void>;
        stop: () => Promise<void>;
        addListeners(
            listeners: ICalculation.IListeners,
            options?: IListener.Options,
        ): Remove;
        beginCommit(options?: string | ITransaction.OperationOptions): ITransaction;
        calculate(
            options?: boolean | CalculateOptions,
        ): Promise<ICalculation.Status>;
        close(): void;
        createFormula(
            expression: string,
            coords?: Partial<CellCoords>,
            options?: CreateFormulaOptions,
        ): IFormula;
        delete?(options?: ITransaction.OperationOptions): void;
        doBatch<R = any>(
            callback: (commit: ICommit) => R | Promise<R>,
            options?: string | ITransaction.OperationOptions,
        ): R | Promise<R>;
        evaluate(
            expression: string,
            options?:
                | number
                | EvaluateOptions & Partial<CellCoords> & CreateFormulaOptions,
        ): Promise<Scalar | IRange<Scalar>>;
        getCalculationMode(): ICalculation.CalculationMode;
        getCalculationState(): ICalculation.CalculationState;
        getExternalBooks(): IExternalBookCollection;
        getFunctions(): IFunctionCollection;
        getId(): string;
        getIterativeCalculation(): IterativeCalculation;
        getNamedFormulas(): INamedFormulasCollection;
        getRuntime(): IRuntime;
        getStatus(): ICalculation.Status;
        getType(): string;
        getVersionId(): number;
        isCalculationRequired(): boolean;
        isClosed(): boolean;
        isDeleted(): boolean;
        isReadOnly(): boolean;
        ready(options?: CalculateOptions): Promise<ICalculation.Status>;
        setCalculationMode(mode: ICalculation.CalculationMode): this;
        setIterativeCalculation(
            options: boolean | Partial<IterativeCalculation>,
        ): this;
        toJSON(): ICalculation.JSON;
    }

    Hierarchy

    • IModel
      • ICalculation
    Index
    isICalculation: true

    For runtime type checking.

    isIModel: true

    For runtime type checking.

    start: () => Promise<void>

    Starts the ICalculation engine.

    • This is required to be called before any calculations can be performed.
    • This will initialize the calculation engine and prepare it for use.
    • Will fire events and return a promise when the calculation is started. (or errors);
    stop: () => Promise<void>

    Stops the ICalculation engine.

    • Batches all 'transactional' changes until they have all be committed or rolled back.

      Parameters

      • Optionaloptions: string | ITransaction.OperationOptions

        Description of the operation or additional options. Used for tracking undo/redo and history. Default Value User Operation.

      Returns ITransaction

      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.

    • Execute a calculate on the Graph.

      Parameters

      • Optionaloptions: boolean | CalculateOptions

        The options or a boolean. If `true' a full calculation will be done.

      Returns Promise<ICalculation.Status>

      A promise that will be resolved when the calculation is completed.

      For async functions this will return before they are completed.

    • Close the record and cleans resources. Can't be undone.

      Returns void

    • Parses a formula expression and returns a transient formula object.

      Parameters

      • expression: string

        The formula expression, with or without a leading =.

      • Optionalcoords: Partial<CellCoords>

        Optional anchor coordinates.

      • Optionaloptions: CreateFormulaOptions

        Optional parse options.

      Returns IFormula

      • This does not register the formula in the workbook or dependency graph.
      • The expression is read as storage text (English function names, , separators) unless options.target is 'display' — text a user typed in their language and locale.
      • Use it for:
        • interactive editing (tooltips, watches, function help)
        • condition / validation expressions
        • ad-hoc “what-if” evaluations
      calculation.createFormula('SUM(A1,1.5)');
      // With a German language pack active:
      calculation.createFormula('SUMME(A1;1,5)', undefined, { target: 'display' });
    • Provides a mechanism to perform a set of operations in a batch.

      Type Parameters

      • R = any

      Parameters

      • callback: (commit: ICommit) => R | Promise<R>

        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.

      Returns R | Promise<R>

      Writes are tracked automatically: a batch that performs no state updates (a read-only batch) is elided — the commit id is unchanged, no events fire, and nothing is added to the undo stack or commit log.

    • Evaluates a expression in the context of the sheet and returns the resulting value.

      Parameters

      Returns Promise<Scalar | IRange<Scalar>>

      This is similar convenience method for getCalculation().createFormula(expression).evaluate(options). The expression is read as storage text unless options.target is 'display'.

    • The workbook's external books — the [n] a formula cites — in position order.

      Returns IExternalBookCollection

      Owned by the engine, as defined names are: a book is a symbol formulas bind into, and which formulas cite a book is the engine's index. Also reachable as IWorkbook.getExternalBooks().

    • A unique identifier for the record. This will never change.

      Returns string

      This enables the record to be identified across transactions and users in a collaborative environment. The id is store-issued (IStore.create); the store keys all state by it.

    • Returns IRuntime

    • Returns an immutable type string.

      Returns string

    • Every committed update gives the record a new, strictly increasing version id.

      Returns number

      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 formula is out of date — Excel's Calculate indicator in the status bar.

      Returns boolean

      Meaningful in manual mode, where edits accumulate until calculate. In automatic mode it is true only between an edit and the pass it schedules.

    • Returns true if no more operations are allowed.

      Returns boolean

    • If the model unable to be modified.

      Returns boolean

    • If the model unable to be modified.

      Returns boolean

    • Enables, disables or configures iterative calculation.

      Parameters

      • options: boolean | Partial<IterativeCalculation>

        true/false toggles enabled alone; an object updates the fields given and keeps the rest.

      Returns this

      Every cell in a cycle is recalculated when this changes: turning iteration on resolves the cycles the workbook shows as unresolved, turning it off writes 0 to them again.

    • The calculation settings as JSON — what an xlsx carries in calcPr.

      Returns ICalculation.JSON

      Sparse: a setting at its default is omitted. Settings a file carried that this engine does not act on (calcOnSave, fullCalcOnLoad, fullPrecision, …) are kept and written back.