modern-xlsx API Reference - v1.3.0
    Preparing search index...

    Interface EvalContext

    Evaluation context: provides cell value lookup without coupling to the Workbook class. This abstraction enables testing with mock data and future extensibility (e.g. cross-workbook references).

    interface EvalContext {
        currentCell?: { col: number; row: number };
        currentSheet: string;
        dateSystem?: DateSystem;
        functions?: Map<string, FormulaFunction>;
        getBounds?(sheet: string): { maxCol: number; maxRow: number } | undefined;
        getCell(sheet: string, col: number, row: number): CellValue;
    }
    Index
    currentCell?: { col: number; row: number }

    Optional position of the cell that holds the formula, in EvalContext.getCell's coordinates: col is 0-based and row 1-based.

    A multi-cell reference in a scalar position (=A1:A10*2) reads the cell of a single-column reference on this row, or of a single-row reference in this column (Excel's implicit intersection). Without it, such a reference evaluates to #VALUE!.

    currentSheet: string

    The name of the current sheet (used when CellRefNode has no sheet prefix).

    dateSystem?: DateSystem

    Optional date system of the workbook the formula belongs to; absent means 'date1900'. TEXT reads it, so serial numbers render as dates in this system.

    functions?: Map<string, FormulaFunction>

    Optional function registry for formula evaluation.

    • Optional populated extent of a sheet, in EvalContext.getCell's coordinates: maxRow is the last populated 1-based row and maxCol the last populated 0-based column. Return { maxRow: 0, maxCol: -1 } for an empty sheet.

      Ranges are clamped to these bounds (the declared top-left is kept, only the bottom-right shrinks), so whole-column or whole-sheet ranges such as SUM(A1:XFD1048576) read only populated cells. Without bounds (method absent or returning undefined), a range of more than 1,048,576 cells evaluates to #NUM!.

      Parameters

      • sheet: string

      Returns { maxCol: number; maxRow: number } | undefined