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;
    isValidCellValueAndFormat(
        row: number,
        column: number,
        value: CellValue,
        format: undefined | string,
    ): Result<void, ValidationError>;
    setCellValueAndFormat(
        row: number,
        column: number,
        value: CellValue,
        format: undefined | string,
    ): Result<void, SpreadsheetDataError>;
    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