spreadsheet
typeScript/javascript spreadsheet parser, with formulas.
git clone https://git.vogt.world/spreadsheet.git
Log | Files | README.md
← All files
name: dist/Sheet.d.ts
-rw-r--r--
3084
  1import { Cell } from "./Cell";
  2/**
  3 * Represents a spreadsheet parser and data-store that act together as a functional spreadsheet.
  4 */
  5declare class Sheet {
  6    private parser;
  7    private dataStore;
  8    constructor();
  9    /**
 10     * Iterate through cells in the data-store, returning the collected cells in the range.
 11     * @param origin
 12     * @param startCell
 13     * @param endCell
 14     * @returns {{index: Array; value: Array}}
 15     */
 16    iterateCells(origin: any, startCell: any, endCell: any): {
 17        index: any[];
 18        value: any[];
 19    };
 20    /**
 21     * Call function with given arguments. Used for calling formulas.
 22     * @param fn
 23     * @param args
 24     * @returns {any}
 25     */
 26    callFunction(fn: any, args: any): any;
 27    /**
 28     * Call variable, which could include calling a function.
 29     * @param args
 30     * @returns {any}
 31     */
 32    callVariable(args: any): any;
 33    /**
 34     * Fetch cell, updating dependencies in process.
 35     * @param origin
 36     * @param cellId
 37     * @returns {Cell}
 38     */
 39    cellValue(origin: any, cellId: any): Cell;
 40    /**
 41     * Get a range of cells.
 42     * @param origin - the cell id in A1 notation from which this range is being referenced.
 43     * @param {string} start - first cell coordinate (in A1 notation) in iteration
 44     * @param {string} end - final cell coordinate (in A1 notation) in iteration
 45     * @returns {Array}
 46     */
 47    cellRangeValue(origin: any, start: string, end: string): any[];
 48    /**
 49     * Get a fixed cell value.
 50     * @param origin
 51     * @param id
 52     * @returns {Cell}
 53     */
 54    fixedCellValue(origin: any, id: any): Cell;
 55    /**
 56     * Get a fixed cell value range.
 57     * @param origin
 58     * @param start
 59     * @param end
 60     * @returns {Array}
 61     */
 62    fixedCellRangeValue(origin: any, start: any, end: any): any[];
 63    /**
 64     * Recalculate dependencies for a cell.
 65     * @param {Cell} cell
 66     */
 67    private recalculateCellDependencies(cell);
 68    /**
 69     * Executes the formula in a cell.
 70     * @param {Cell} cell
 71     * @returns {{error: Error; result: any} | {error: any; result: any}}
 72     */
 73    private calculateCellFormula(cell);
 74    /**
 75     * Add a cell to the data-store, recording and updating dependencies if necessary.
 76     * @param {Cell} cell
 77     */
 78    private registerCellInDataStore(cell);
 79    /**
 80     * Parse a formula for a given cellId. This involves all calculations and look-ups.
 81     * @param formula
 82     * @param cellId
 83     * @returns {any}
 84     */
 85    parse(formula: any, cellId: any): {
 86        error: any;
 87        result: any;
 88    };
 89    /**
 90     * Set a cell's value, by id.
 91     * @param {string} id
 92     * @param {string} value
 93     */
 94    setCell(id: string, value: string): void;
 95    /**
 96     * Get a cell from the data-store, returning null if a cell is undefined.
 97     * @param {string} id
 98     * @returns {Cell}
 99     */
100    getCell(id: string): Cell;
101    /**
102     * Load an a matrix of cells into the data-store.
103     * @param {Array<Array<any>>} input
104     */
105    load(input: Array<Array<any>>): void;
106}
107export { Sheet };