Columnar workbook storage, query, transaction, and subscription contract.
Package
@sheetwrite/core
Source
packages/core/src/types/store.ts#L108
Members 17
getWorkbook
getWorkbook(): Workbookinterface Workbook {
sheets: Sheet[];
activeSheet: SheetId;
namedRanges?: NamedRangeSnapshot[];
}interfaceWorkbook {sheets:Sheet[];activeSheet:SheetId;namedRanges?:NamedRangeSnapshot[];}interfaceWorkbook {sheets:Sheet[];activeSheet:SheetId;namedRanges?:NamedRangeSnapshot[];}Live workbook schema containing ordered sheets and the active sheet ID.API reference →;
getCellSingle-cell read for interactions, API reads, and tests.
getCell(addr: CellAddressinterface CellAddress {
sheet: SheetId;
row: number;
col: number;
}interfaceCellAddress {sheet:SheetId;row:number;col:number;}interfaceCellAddress {sheet:SheetId;row:number;col:number;}Zero-based address of one cell on a stable sheet ID.API reference →): ResolvedCellinterface ResolvedCell {
resolved: CellScalar;
style: CellStyle;
}interfaceResolvedCell {resolved:CellScalar;style:CellStyle;}interfaceResolvedCell {resolved:CellScalar;style:CellStyle;}Authoritative source value, evaluated value, style, and load state for a cell.API reference →;
Single-cell read for interactions, API reads, and tests.
NOT for the render hot path — renderers use `getVisibleWindow`.
getFormulaFormula source at addr, or null when the cell is not a formula.
getFormula(addr: CellAddressinterface CellAddress {
sheet: SheetId;
row: number;
col: number;
}interfaceCellAddress {sheet:SheetId;row:number;col:number;}interfaceCellAddress {sheet:SheetId;row:number;col:number;}Zero-based address of one cell on a stable sheet ID.API reference →): string |null;
getRefTargetPlain-reference target at addr, or null when the cell is not a ref.
getRefTarget(addr: CellAddressinterface CellAddress {
sheet: SheetId;
row: number;
col: number;
}interfaceCellAddress {sheet:SheetId;row:number;col:number;}interfaceCellAddress {sheet:SheetId;row:number;col:number;}Zero-based address of one cell on a stable sheet ID.API reference →): CellAddressinterface CellAddress {
sheet: SheetId;
row: number;
col: number;
}interfaceCellAddress {sheet:SheetId;row:number;col:number;}interfaceCellAddress {sheet:SheetId;row:number;col:number;}Zero-based address of one cell on a stable sheet ID.API reference →|null;
recalculateVolatileRecompute volatile formulas (TODAY/NOW) from one captured instant.
recalculateVolatile(now?: Date): void;
Recompute volatile formulas (`TODAY`/`NOW`) from one captured instant.
The supplied Date is interpreted as an absolute UTC instant.
getVisibleWindowBulk read of a visible window; the only read a renderer should use per frame.
getVisibleWindow( sheet: SheetIdtype SheetId = string;typeSheetId=string;typeSheetId=string;Stable identifier used to address a workbook sheet.API reference →, rows: { start: number; end: number }, cols: readonly number[], ): VisibleWindowViewinterface VisibleWindowView {
sheet: SheetId;
rows: { start: number; end: number };
cols: readonly number[];
values: ArrayLike<CellScalar>;
styleIds: Uint32Array;
styles: readonly CellStyle[];
valueKinds?: Uint8Array;
numberValues?: Float64Array;
stringPoolIds?: Uint32Array;
stringLocalIds?: Int32Array;
stringPoolUpdateIds?: Uint32Array;
stringPoolUpdateValues?: readonly string[];
localStrings?: readonly string[];
ffiCalls?: number;
}interfaceVisibleWindowView {sheet:SheetId;rows: { start:number; end:number };cols:readonlynumber[];values:ArrayLike<CellScalar>;styleIds:Uint32Array;styles:readonlyCellStyle[];valueKinds?:Uint8Array;numberValues?:Float64Array;stringPoolIds?:Uint32Array;stringLocalIds?:Int32Array;stringPoolUpdateIds?:Uint32Array;stringPoolUpdateValues?:readonlystring[];localStrings?:readonlystring[];ffiCalls?:number;}interfaceVisibleWindowView {sheet:SheetId;rows: {start:number;end:number;};cols:readonlynumber[];values:ArrayLike<CellScalar>;styleIds:Uint32Array;styles:readonlyCellStyle[];valueKinds?:Uint8Array;numberValues?:Float64Array;stringPoolIds?:Uint32Array;stringLocalIds?:Int32Array;stringPoolUpdateIds?:Uint32Array;stringPoolUpdateValues?:readonlystring[];localStrings?:readonlystring[];ffiCalls?:number;}One rectangular window of resolved cells, returned by Store.getVisibleWindow in a single call. The renderer paints from this view and MUST NOT call Store.getCell per cell. styleIds are view-local indices into this view's compact styles dictionary; on the worker renderer path, styleIds.buffer is transferred during paint, so main-thread code must not read it after paint. Lifetime: valid until the next store mutation or window refresh.API reference →;
getDataWindowOptional packed canonical data-row window used by file export.
getDataWindow?( sheet:SheetIdtype SheetId = string;typeSheetId=string;typeSheetId=string;Stable identifier used to address a workbook sheet.API reference →, rows: { start:number; end:number }, cols:readonlynumber[], ):VisibleWindowViewinterface VisibleWindowView {
sheet: SheetId;
rows: { start: number; end: number };
cols: readonly number[];
values: ArrayLike<CellScalar>;
styleIds: Uint32Array;
styles: readonly CellStyle[];
valueKinds?: Uint8Array;
numberValues?: Float64Array;
stringPoolIds?: Uint32Array;
stringLocalIds?: Int32Array;
stringPoolUpdateIds?: Uint32Array;
stringPoolUpdateValues?: readonly string[];
localStrings?: readonly string[];
ffiCalls?: number;
}interfaceVisibleWindowView {sheet:SheetId;rows: { start:number; end:number };cols:readonlynumber[];values:ArrayLike<CellScalar>;styleIds:Uint32Array;styles:readonlyCellStyle[];valueKinds?:Uint8Array;numberValues?:Float64Array;stringPoolIds?:Uint32Array;stringLocalIds?:Int32Array;stringPoolUpdateIds?:Uint32Array;stringPoolUpdateValues?:readonlystring[];localStrings?:readonlystring[];ffiCalls?:number;}interfaceVisibleWindowView {sheet:SheetId;rows: {start:number;end:number;};cols:readonlynumber[];values:ArrayLike<CellScalar>;styleIds:Uint32Array;styles:readonlyCellStyle[];valueKinds?:Uint8Array;numberValues?:Float64Array;stringPoolIds?:Uint32Array;stringLocalIds?:Int32Array;stringPoolUpdateIds?:Uint32Array;stringPoolUpdateValues?:readonlystring[];localStrings?:readonlystring[];ffiCalls?:number;}One rectangular window of resolved cells, returned by Store.getVisibleWindow in a single call. The renderer paints from this view and MUST NOT call Store.getCell per cell. styleIds are view-local indices into this view's compact styles dictionary; on the worker renderer path, styleIds.buffer is transferred during paint, so main-thread code must not read it after paint. Lifetime: valid until the next store mutation or window refresh.API reference →;
Optional packed canonical data-row window used by file export. Unlike
`getVisibleWindow`, sort/filter state never remaps `rows`.
getClipboardWindowOptional packed clipboard read.
getClipboardWindow?( sheet:SheetIdtype SheetId = string;typeSheetId=string;typeSheetId=string;Stable identifier used to address a workbook sheet.API reference →, viewRows: { start:number; end:number }, cols:readonlynumber[], ):ClipboardWindowView;
Optional packed clipboard read. Custom stores may omit it; the controller
preserves the per-cell Store fallback contract.
ensureColumnsEnsure a sheet can address at least columns.length columns without producing user changes or dirty patches.
ensureColumns(sheet: SheetIdtype SheetId = string;typeSheetId=string;typeSheetId=string;Stable identifier used to address a workbook sheet.API reference →, columns: readonly Columninterface Column {
key: string;
header: string;
width: number;
type: CellFormat;
numberFormat?: string;
numberLocale?: string;
headerStyle?: CellStyle;
cellStyle?: CellStyle;
visible?: boolean;
renderer?: string;
}interfaceColumn {key:string;header:string;width:number;type:CellFormat;numberFormat?:string;numberLocale?:string;headerStyle?:CellStyle;cellStyle?:CellStyle;visible?:boolean;renderer?:string;}interfaceColumn {key:string;header:string;width:number;type:CellFormat;numberFormat?:string;numberLocale?:string;headerStyle?:CellStyle;cellStyle?:CellStyle;visible?:boolean;renderer?:string;}Schema and default presentation for one workbook column.API reference →[]): void;
Ensure a sheet can address at least `columns.length` columns without
producing user changes or dirty patches. Used for presentation padding.
applyTransactionApply a low-level storage transaction.
applyTransaction( tx: Transactioninterface Transaction {
patches: DocumentOp[];
epoch?: number;
}interfaceTransaction {patches:DocumentOp[];epoch?:number;}interfaceTransaction {patches:DocumentOp[];epoch?:number;}Low-level Store transaction. epoch provides optional optimistic concurrency at the storage boundary. Calling Store.applyTransaction bypasses Grid read-only checks and Grid undo/redo history. Host-driven edits should use Grid.applyTransaction.API reference →, options?:TransactionApplicationOptionsinterface TransactionApplicationOptions {
source?: OperationSource;
commitReason?: CommitReason;
}interfaceTransactionApplicationOptions {source?:OperationSource;commitReason?:CommitReason;}interfaceTransactionApplicationOptions {source?:OperationSource;commitReason?:CommitReason;}Source and commit classification used when applying a transaction.API reference →, ): ApplyTransactionResulttype ApplyTransactionResult =
| {
status: "applied";
epoch: number;
transaction: Transaction;
warnings?: MutationIssue[];
rejections?: MutationIssue[];
}
| {
status: "conflict";
expectedEpoch: number;
actualEpoch: number;
}
| { status: "rejected"; epoch: number; issues: MutationIssue[] }
| {
// … 5 more lines — see the API reference
}typeApplyTransactionResult=| {status:"applied";epoch:number;transaction:Transaction;warnings?:MutationIssue[];rejections?:MutationIssue[];}| {status:"conflict";expectedEpoch:number;actualEpoch:number;}| { status:"rejected"; epoch:number; issues:MutationIssue[] }| {// … 5 more lines — see the API reference}typeApplyTransactionResult=| {status:"applied";epoch:number;transaction:Transaction;warnings?:MutationIssue[];rejections?:MutationIssue[];}| {status:"conflict";expectedEpoch:number;actualEpoch:number;}| {status:"rejected";epoch:number;issues:MutationIssue[];}| {// … 8 more lines — see the API reference}Outcome of applying a document transaction, including conflict, rejection, and no-op states.API reference →;
Apply a low-level storage transaction.
This bypasses Grid read-only checks and Grid undo/redo history. Use
Grid.applyTransaction for normal host-driven edits.
Queued and flushed at a barrier — never reentrant.
viewRowCountDisplayed row count after any active sort/filter view.
viewRowCount(sheet: SheetIdtype SheetId = string;typeSheetId=string;typeSheetId=string;Stable identifier used to address a workbook sheet.API reference →): number;
Declaration
View full TypeScript declaration
exportinterfaceStore {
getWorkbook():Workbookinterface Workbook {
sheets: Sheet[];
activeSheet: SheetId;
namedRanges?: NamedRangeSnapshot[];
}interfaceWorkbook {sheets:Sheet[];activeSheet:SheetId;namedRanges?:NamedRangeSnapshot[];}interfaceWorkbook {sheets:Sheet[];activeSheet:SheetId;namedRanges?:NamedRangeSnapshot[];}Live workbook schema containing ordered sheets and the active sheet ID.API reference →;
getCell(addr:CellAddressinterface CellAddress {
sheet: SheetId;
row: number;
col: number;
}interfaceCellAddress {sheet:SheetId;row:number;col:number;}interfaceCellAddress {sheet:SheetId;row:number;col:number;}Zero-based address of one cell on a stable sheet ID.API reference →):ResolvedCellinterface ResolvedCell {
resolved: CellScalar;
style: CellStyle;
}interfaceResolvedCell {resolved:CellScalar;style:CellStyle;}interfaceResolvedCell {resolved:CellScalar;style:CellStyle;}Authoritative source value, evaluated value, style, and load state for a cell.API reference →;
getFormula(addr:CellAddressinterface CellAddress {
sheet: SheetId;
row: number;
col: number;
}interfaceCellAddress {sheet:SheetId;row:number;col:number;}interfaceCellAddress {sheet:SheetId;row:number;col:number;}Zero-based address of one cell on a stable sheet ID.API reference →):string|null;
getRefTarget(addr:CellAddressinterface CellAddress {
sheet: SheetId;
row: number;
col: number;
}interfaceCellAddress {sheet:SheetId;row:number;col:number;}interfaceCellAddress {sheet:SheetId;row:number;col:number;}Zero-based address of one cell on a stable sheet ID.API reference →):CellAddressinterface CellAddress {
sheet: SheetId;
row: number;
col: number;
}interfaceCellAddress {sheet:SheetId;row:number;col:number;}interfaceCellAddress {sheet:SheetId;row:number;col:number;}Zero-based address of one cell on a stable sheet ID.API reference →|null;
recalculateVolatile(now?:Date):void;
getVisibleWindow(
sheet:SheetIdtype SheetId = string;typeSheetId=string;typeSheetId=string;Stable identifier used to address a workbook sheet.API reference →,
rows: {
start:number;
end:number;
},
cols:readonlynumber[],
):VisibleWindowViewinterface VisibleWindowView {
sheet: SheetId;
rows: { start: number; end: number };
cols: readonly number[];
values: ArrayLike<CellScalar>;
styleIds: Uint32Array;
styles: readonly CellStyle[];
valueKinds?: Uint8Array;
numberValues?: Float64Array;
stringPoolIds?: Uint32Array;
stringLocalIds?: Int32Array;
stringPoolUpdateIds?: Uint32Array;
stringPoolUpdateValues?: readonly string[];
localStrings?: readonly string[];
ffiCalls?: number;
}interfaceVisibleWindowView {sheet:SheetId;rows: { start:number; end:number };cols:readonlynumber[];values:ArrayLike<CellScalar>;styleIds:Uint32Array;styles:readonlyCellStyle[];valueKinds?:Uint8Array;numberValues?:Float64Array;stringPoolIds?:Uint32Array;stringLocalIds?:Int32Array;stringPoolUpdateIds?:Uint32Array;stringPoolUpdateValues?:readonlystring[];localStrings?:readonlystring[];ffiCalls?:number;}interfaceVisibleWindowView {sheet:SheetId;rows: {start:number;end:number;};cols:readonlynumber[];values:ArrayLike<CellScalar>;styleIds:Uint32Array;styles:readonlyCellStyle[];valueKinds?:Uint8Array;numberValues?:Float64Array;stringPoolIds?:Uint32Array;stringLocalIds?:Int32Array;stringPoolUpdateIds?:Uint32Array;stringPoolUpdateValues?:readonlystring[];localStrings?:readonlystring[];ffiCalls?:number;}One rectangular window of resolved cells, returned by Store.getVisibleWindow in a single call. The renderer paints from this view and MUST NOT call Store.getCell per cell. styleIds are view-local indices into this view's compact styles dictionary; on the worker renderer path, styleIds.buffer is transferred during paint, so main-thread code must not read it after paint. Lifetime: valid until the next store mutation or window refresh.API reference →;
getDataWindow?(
sheet:SheetIdtype SheetId = string;typeSheetId=string;typeSheetId=string;Stable identifier used to address a workbook sheet.API reference →,
rows: {
start:number;
end:number;
},
cols:readonlynumber[],
):VisibleWindowViewinterface VisibleWindowView {
sheet: SheetId;
rows: { start: number; end: number };
cols: readonly number[];
values: ArrayLike<CellScalar>;
styleIds: Uint32Array;
styles: readonly CellStyle[];
valueKinds?: Uint8Array;
numberValues?: Float64Array;
stringPoolIds?: Uint32Array;
stringLocalIds?: Int32Array;
stringPoolUpdateIds?: Uint32Array;
stringPoolUpdateValues?: readonly string[];
localStrings?: readonly string[];
ffiCalls?: number;
}interfaceVisibleWindowView {sheet:SheetId;rows: { start:number; end:number };cols:readonlynumber[];values:ArrayLike<CellScalar>;styleIds:Uint32Array;styles:readonlyCellStyle[];valueKinds?:Uint8Array;numberValues?:Float64Array;stringPoolIds?:Uint32Array;stringLocalIds?:Int32Array;stringPoolUpdateIds?:Uint32Array;stringPoolUpdateValues?:readonlystring[];localStrings?:readonlystring[];ffiCalls?:number;}interfaceVisibleWindowView {sheet:SheetId;rows: {start:number;end:number;};cols:readonlynumber[];values:ArrayLike<CellScalar>;styleIds:Uint32Array;styles:readonlyCellStyle[];valueKinds?:Uint8Array;numberValues?:Float64Array;stringPoolIds?:Uint32Array;stringLocalIds?:Int32Array;stringPoolUpdateIds?:Uint32Array;stringPoolUpdateValues?:readonlystring[];localStrings?:readonlystring[];ffiCalls?:number;}One rectangular window of resolved cells, returned by Store.getVisibleWindow in a single call. The renderer paints from this view and MUST NOT call Store.getCell per cell. styleIds are view-local indices into this view's compact styles dictionary; on the worker renderer path, styleIds.buffer is transferred during paint, so main-thread code must not read it after paint. Lifetime: valid until the next store mutation or window refresh.API reference →;
getClipboardWindow?(
sheet:SheetIdtype SheetId = string;typeSheetId=string;typeSheetId=string;Stable identifier used to address a workbook sheet.API reference →,
viewRows: {
start:number;
end:number;
},
cols:readonlynumber[],
):ClipboardWindowView;
ensureColumns(sheet:SheetIdtype SheetId = string;typeSheetId=string;typeSheetId=string;Stable identifier used to address a workbook sheet.API reference →, columns:readonlyColumninterface Column {
key: string;
header: string;
width: number;
type: CellFormat;
numberFormat?: string;
numberLocale?: string;
headerStyle?: CellStyle;
cellStyle?: CellStyle;
visible?: boolean;
renderer?: string;
}interfaceColumn {key:string;header:string;width:number;type:CellFormat;numberFormat?:string;numberLocale?:string;headerStyle?:CellStyle;cellStyle?:CellStyle;visible?:boolean;renderer?:string;}interfaceColumn {key:string;header:string;width:number;type:CellFormat;numberFormat?:string;numberLocale?:string;headerStyle?:CellStyle;cellStyle?:CellStyle;visible?:boolean;renderer?:string;}Schema and default presentation for one workbook column.API reference →[]):void;
applyTransaction(
tx:Transactioninterface Transaction {
patches: DocumentOp[];
epoch?: number;
}interfaceTransaction {patches:DocumentOp[];epoch?:number;}interfaceTransaction {patches:DocumentOp[];epoch?:number;}Low-level Store transaction. epoch provides optional optimistic concurrency at the storage boundary. Calling Store.applyTransaction bypasses Grid read-only checks and Grid undo/redo history. Host-driven edits should use Grid.applyTransaction.API reference →,
options?:TransactionApplicationOptionsinterface TransactionApplicationOptions {
source?: OperationSource;
commitReason?: CommitReason;
}interfaceTransactionApplicationOptions {source?:OperationSource;commitReason?:CommitReason;}interfaceTransactionApplicationOptions {source?:OperationSource;commitReason?:CommitReason;}Source and commit classification used when applying a transaction.API reference →,
):ApplyTransactionResulttype ApplyTransactionResult =
| {
status: "applied";
epoch: number;
transaction: Transaction;
warnings?: MutationIssue[];
rejections?: MutationIssue[];
}
| {
status: "conflict";
expectedEpoch: number;
actualEpoch: number;
}
| { status: "rejected"; epoch: number; issues: MutationIssue[] }
| {
// … 5 more lines — see the API reference
}typeApplyTransactionResult=| {status:"applied";epoch:number;transaction:Transaction;warnings?:MutationIssue[];rejections?:MutationIssue[];}| {status:"conflict";expectedEpoch:number;actualEpoch:number;}| { status:"rejected"; epoch:number; issues:MutationIssue[] }| {// … 5 more lines — see the API reference}typeApplyTransactionResult=| {status:"applied";epoch:number;transaction:Transaction;warnings?:MutationIssue[];rejections?:MutationIssue[];}| {status:"conflict";expectedEpoch:number;actualEpoch:number;}| {status:"rejected";epoch:number;issues:MutationIssue[];}| {// … 8 more lines — see the API reference}Outcome of applying a document transaction, including conflict, rejection, and no-op states.API reference →;
viewRowCount(sheet:SheetIdtype SheetId = string;typeSheetId=string;typeSheetId=string;Stable identifier used to address a workbook sheet.API reference →):number;