SheetXL - v0.3.20
    Preparing search index...

    Represents a formula that can be evaluated.

    interface IFormula {
        evaluate(evalIndex?: number): Promise<Scalar | IRange<Scalar>>;
        getDirectPrecedents(): readonly (FormulaError.Known | IRange.FixableCoords)[];
        getReferences(): readonly (
            string
            | FormulaError.Known
            | IRange.FixableCoords
        )[];
        getTokens(evalIndex?: number): readonly FormulaToken[];
        setReferenceAt(index: number, reference: IRange.FixableCoords): this;
        toText(r1c1?: boolean): string;
    }
    Index

    Methods

    • Return the value for a formula.

      Parameters

      • OptionalevalIndex: number

        Allows for a partial evaluation based on a token index.

      Returns Promise<Scalar | IRange<Scalar>>

      The index is the ICalculation.FormulaToken.evalIndex. If not provided this will return the value of the entire formula.

      ICalculation.FormulaToken.evalIndex

    • Returns the ranges that provide data to a formula.

      Returns readonly (FormulaError.Known | IRange.FixableCoords)[]

      • [] if no precedents are present; either because it has no formula or a formula with no inputs.
      • Precedents are the logical ranges and may different the inputs into the formula.
    • Returns the references that are used in the formula.

      Returns readonly (string | FormulaError.Known | IRange.FixableCoords)[]

      This is different than the direct precedents as it includes references before the range operators. This is useful for indicating to the users the static inputs and allow.

    • Return the formula as an array of tokenized values.

      Parameters

      • OptionalevalIndex: number

        Allows for a partial evaluation based on a token index.

      Returns readonly FormulaToken[]

      These can be used by advanced editors.

      ICalculation.FormulaToken.evalIndex

    • Sets the reference at the given index.

      Parameters

      • index: number

        The index of the reference to set.

      • reference: IRange.FixableCoords

        The reference to set at the index.

      Returns this

      The index must align with the getReferences() array. Will throw an error if the index not with the reference array.

    • Return the formula string.

      Parameters

      • Optionalr1c1: boolean

        If true then the formula will be returned in R1C1 format.

      Returns string