Interface used to access the data in a spreadsheet

The data exposed through the interface may change over time outside of any changes made through the interface. The caller can use the subscribe method to be notified when the data changes. When reading data, the caller must first request a snapshot using getSnapshot. All values returned by gettors are relative to a specified snapshot. The values will be consistent with each other as long as the same snapshot is used.

interface SpreadsheetData<Snapshot> {
    getCellFormat(
        snapshot: Snapshot,
        row: number,
        column: number,
    ): undefined | string;
    getCellValue(snapshot: Snapshot, row: number, column: number): CellValue;
    getColumnCount(snapshot: Snapshot): number;
    getColumnItemOffsetMapping(snapshot: Snapshot): ItemOffsetMapping;
    getRowCount(snapshot: Snapshot): number;
    getRowItemOffsetMapping(snapshot: Snapshot): ItemOffsetMapping;
    getSnapshot(): Snapshot;
    setCellValueAndFormat(
        row: number,
        column: number,
        value: CellValue,
        format: undefined | string,
    ): boolean;
    subscribe(onDataChange: () => void): () => void;
}

Type Parameters

  • Snapshot

    Type of snapshot. Implementations are free to use whatever type makes sense for them.

Hierarchy (View Summary)

Implemented by

Methods

  • Format of specified cell using 0-based row and column indexes

    Parameters

    • snapshot: Snapshot
    • row: number
    • column: number

    Returns undefined | string

  • Set value and format of specified cell

    Parameters

    • row: number
    • column: number
    • value: CellValue
    • format: undefined | string

    Returns boolean

    True if the change was successfully applied

  • Subscribe to data changes

    Parameters

    • onDataChange: () => void

    Returns () => void