Skip to content
Sheetwrite

Sheetwrite / Documentation

Grid@sheetwrite/vue

Imperative grid handle for document commands, events, rendering, and teardown.

Imperative grid handle for document commands, events, rendering, and teardown.

Members 81

store
readonly store: Store;
actions Imperative action surface for binding custom toolbars/menus.
readonly actions: GridActions;
setActiveSheet
setActiveSheet(id: SheetId): void;
scrollToCell
scrollToCell(addr: CellAddress): void;
getCellAtPoint Resolve browser viewport coordinates to an active-sheet cell for host-owned menus and interactions.
getCellAtPoint(clientX: number, clientY: number): CellAddress | null;

Resolve browser viewport coordinates to an active-sheet cell for host-owned menus and interactions. Returns null outside the cell body.

getActiveSheet Id of the currently visible sheet.
getActiveSheet(): SheetId;
getCellInput Editable snapshot of the cell at a view position on the active sheet, or null when out of bounds.
getCellInput(row: number, col: number): CellInputSnapshot | null;

Editable snapshot of the cell at a view position on the active sheet, or null when out of bounds. See CellInputSnapshot.

getSelection
getSelection(): Selection | null;
setSelection
setSelection(sel: Selection | null): void;
setTheme Imperative patch: merge theme into the accumulated base theme.
setTheme(theme: Partial<Theme>): void;
replaceTheme Option-level replacement: re-run construction-time resolution (DEFAULTTHEME < CSS custom properties < theme) with the new partial.
replaceTheme(theme: Partial<Theme> | undefined): void;

Option-level replacement: re-run construction-time resolution (`DEFAULT_THEME < CSS custom properties < theme`) with the new partial. `undefined` restores the CSS-variable/default resolution. Adapters call this for their declarative `theme` prop; imperative patching stays on setTheme.

getEffectiveTheme The effective (post-zoom) theme the renderer is currently painting with.
getEffectiveTheme(): Theme;
setReadOnly Update editability without replacing the Grid or clearing session state.
setReadOnly(readOnly: boolean): void;
setConfig Reconfigure built-in chrome and keyboard handling without replacing the Grid or clearing selection/history.
setConfig(config: GridConfig | undefined): void;

Reconfigure built-in chrome and keyboard handling without replacing the Grid or clearing selection/history. Construction-bound GridOptions are not accepted here.

applyTransaction Apply arbitrary patches as one undoable Grid commit.
applyTransaction(transaction: GridTransaction): ApplyTransactionResult;

Apply arbitrary patches as one undoable Grid commit. No-op when read-only. Use `Store.applyTransaction` only for low-level writes that intentionally bypass Grid history and policy.

exportSnapshot Deterministically export the complete authoritative workbook document.
exportSnapshot(): WorkbookSnapshot;
applyRemoteOperations Apply host-supplied operations without undo history or outgoing dirty state.
applyRemoteOperations(operations: readonly DocumentOp[], options?: RemoteOperationOptions): ApplyTransactionResult;

Apply host-supplied operations without undo history or outgoing dirty state. The resulting change event has `source: "remote"`.

defineCellRenderer
defineCellRenderer(name: string, renderer: CellRenderer): void;
aggregate Column aggregate over the active sheet's data.
aggregate(col: number, op: AggregateOp): number;
sortBy Sort the displayed rows by a column (does not mutate stored data).
sortBy(col: number, ascending?: boolean): void;
sortByMulti Multi-key sort of the displayed rows (first key primary; stable).
sortByMulti(keys: readonly SortKey[]): void;
filterBy Filter the displayed rows to those whose column text contains needle.
filterBy(col: number, needle: string): void;
setColumnFilter Set or clear (null) one column's filter.
setColumnFilter(col: number, filter: ColumnFilter | null): void;

Set or clear (null) one column's filter. All column filters AND together and compose with the active sort and hidden rows.

setSort Persisted multi-key sort of the active sheet.
setSort(keys: readonly SortKey[]): ApplyTransactionResult;
getColumnFilters Active column filters on the active sheet, keyed by column index.
getColumnFilters(): ReadonlyMap<number, ColumnFilter>;
distinctValues Distinct resolved values of a column (Rust scan), capped at limit (default 1000) — the data source for a filter-by-values UI.
distinctValues(col: number, limit?: number): CellScalar[];
hideRows Hide the given data rows (composes with filters/sort).
hideRows(rows: readonly number[]): void;
showRows Show the given data rows again, or every hidden row when omitted.
showRows(rows?: readonly number[]): void;
hiddenRows Currently hidden data rows on the active sheet.
hiddenRows(): readonly number[];
hideColumns Hide columns through one bulk-safe metadata transaction.
hideColumns(cols?: readonly number[]): void;
showColumns Show columns through one bulk-safe metadata transaction.
showColumns(cols?: readonly number[]): void;
hiddenColumns Currently hidden columns on the active sheet.
hiddenColumns(): readonly number[];
groupRows Define a collapsible row group over a data-row range (end-inclusive).
groupRows(start: number, end: number): void;
ungroupRows Remove a row group (rows become visible if the group was collapsed).
ungroupRows(start: number, end: number): void;
setGroupCollapsed Collapse/expand a row group; collapsing hides its rows.
setGroupCollapsed(start: number, collapsed: boolean): void;
rowGroups Row groups on the active sheet.
rowGroups(): readonly RowGroup[];
clearView Clear any active sort/filter view.
clearView(): void;
undo Undo the last recorded cell edit.
undo(): void;
redo Redo the last undone cell edit.
redo(): void;
exportCsv
exportCsv(filename: string): void;
exportXlsx
exportXlsx(filename: string): Promise<void>;
findNext Move the active match to the next match and scroll it into view.
findNext(): SearchResult;
findPrev Move the active match to the previous match and scroll it into view.
findPrev(): SearchResult;
replaceCurrent Replace the active match with replacement, then advance to the next match (re-scanning against the new data).
replaceCurrent(replacement: string): SearchResult;

Replace the active match with `replacement`, then advance to the next match (re-scanning against the new data). Only literal text/number cells are eligible; formula and ref cells are skipped (formula source is never rewritten). Honors the active SearchOptions (matchCase; `wholeCell` swaps the entire cell). The write flows through the grid's commit path as one undoable step. No-op when read-only or when there is no active match.

replaceAll Replace every current match in a single undoable transaction (one undo() restores them all), then re-scan.
replaceAll(replacement: string): ReplaceResult;

Replace every current match in a single undoable transaction (one `undo()` restores them all), then re-scan. Formula/ref cells are skipped and not counted. No-op when read-only.

insertRows
insertRows(at: number, count?: number): void;
removeRows
removeRows(at: number, count?: number): void;
insertColumns
insertColumns(at: number, count?: number): void;
removeColumns
removeColumns(at: number, count?: number): void;
addSheet Add a sheet with a stable ID and make it available to the tab bar.
addSheet(input: AddSheetInput): SheetId;
removeSheet Remove a sheet; at least one sheet always remains.
removeSheet(id: SheetId): void;
renameSheet
renameSheet(id: SheetId, name: string): void;
moveSheet
moveSheet(id: SheetId, toIndex: number): void;
setConditionalFormats
setConditionalFormats(rules: readonly ConditionalFormatRule[]): void;
setValidationRule
setValidationRule(rule: DataValidationRule): ApplyTransactionResult;
removeValidationRule
removeValidationRule(id: string): ApplyTransactionResult;
setProtectedRange
setProtectedRange(protectedRange: ProtectedRange): ApplyTransactionResult;
removeProtectedRange
removeProtectedRange(id: string): ApplyTransactionResult;
setProtectionResolver
setProtectionResolver(resolver: ProtectionResolver | undefined, mode?: MutationPolicyMode): void;
setNote
setNote(addr: CellAddress, text: string | null): ApplyTransactionResult;
getNote
getNote(addr: CellAddress): string | null;
setOverscan Live-update the render window overscan (rows/cols painted beyond the viewport); undefined restores the default.
setOverscan(overscan?: number): void;
setMinColumns Live-update the minimum rendered column count.
setMinColumns(minColumns?: number): void;

Live-update the minimum rendered column count. Increasing the minimum silently extends presentation padding; `undefined` restores the default.

highlightCells Highlight arbitrary cell ranges (null clears).
highlightCells(ranges: readonly HighlightRange[] | null, color?: string): void;

Highlight arbitrary cell ranges (null clears). Per-range `color` wins over the call color.

setPresenceOverlays Replace ephemeral remote-presence overlays; null clears every collaborator.
setPresenceOverlays(overlays: readonly PresenceOverlay[] | null): void;
styleRange Merge style into every cell of range (null clears cell styles) as one undoable transaction.
styleRange(range: Range, style: Partial<CellStyle> | null): void;

Merge `style` into every cell of `range` (null clears cell styles) as one undoable transaction. Styles land in the store and paint in the canvas — unlike highlightCells, which draws a translucent overlay above it.

beginEdit Open the cell editor at a view cell, optionally seeding text / selecting all.
beginEdit(row: number, col: number, initial?: string, selectAll?: boolean): void;
dataEdge Ctrl+Arrow-style jump target: the data-run edge from (row, col) on the moved axis (row for vertical moves, col for horizontal), or null when the store is not columnar.
dataEdge(row: number, col: number, dRow: number, dCol: number): number | null;

Ctrl+Arrow-style jump target: the data-run edge from (row, col) on the moved axis (row for vertical moves, col for horizontal), or null when the store is not columnar. Under an active sort/filter view, `row` is a view position and vertical moves return view positions. For hosts building their own keymaps (`config.keyboard`).

setRowHeight Set one row's persistent display height through document history.
setRowHeight(row: number, height: number): void;
setColumnWidth Set one column's width via an undoable setColumn patch.
setColumnWidth(col: number, width: number): void;
autoFitRows Explicitly resize rows to fit wrapped content; never runs during paint.
autoFitRows(range?: Range): void;
autoFitColumns Explicitly resize columns from a bulk worksheet read.
autoFitColumns(cols?: readonly number[]): void;
setFrozen Pin the first rows view rows and cols columns; they stay visible while the body scrolls (0 = unfreeze that axis).
setFrozen(rows: number, cols?: number): void;

Pin the first `rows` view rows and `cols` columns; they stay visible while the body scrolls (0 = unfreeze that axis). Persisted on the active sheet.

setZoom Content zoom factor (0.5–2): scales row/column geometry and fonts.
setZoom(zoom: number): void;
getZoom
getZoom(): number;
rendererKind Which renderer is actually active: "worker" when the OffscreenCanvas worker constructed successfully, "canvas" otherwise (including after a renderer-fallback).
rendererKind(): "canvas" | "worker";
on
on<E extends keyof GridEvents>(evt: E, fn: (e: GridEvents[E]) => void): () => void;
refresh
refresh(): void;
destroy
destroy(): void;

Declaration

View full TypeScript declaration
export interface Grid {
readonly store: Store;
readonly actions: GridActions;
setActiveSheet(id: SheetId): void;
scrollToCell(addr: CellAddress): void;
getCellAtPoint(clientX: number, clientY: number): CellAddress | null;
getActiveSheet(): SheetId;
getCellInput(row: number, col: number): CellInputSnapshot | null;
getSelection(): Selection | null;
setSelection(sel: Selection | null): void;
setTheme(theme: Partial<Theme>): void;
replaceTheme(theme: Partial<Theme> | undefined): void;
getEffectiveTheme(): Theme;
setReadOnly(readOnly: boolean): void;
setConfig(config: GridConfig | undefined): void;
applyTransaction(transaction: GridTransaction): ApplyTransactionResult;
exportSnapshot(): WorkbookSnapshot;
applyRemoteOperations(
operations: readonly DocumentOp[],
options?: RemoteOperationOptions,
): ApplyTransactionResult;
defineCellRenderer(name: string, renderer: CellRenderer): void;
aggregate(col: number, op: AggregateOp): number;
sortBy(col: number, ascending?: boolean): void;
sortByMulti(keys: readonly SortKey[]): void;
filterBy(col: number, needle: string): void;
setColumnFilter(col: number, filter: ColumnFilter | null): void;
setSort(keys: readonly SortKey[]): ApplyTransactionResult;
getColumnFilters(): ReadonlyMap<number, ColumnFilter>;
distinctValues(col: number, limit?: number): CellScalar[];
hideRows(rows: readonly number[]): void;
showRows(rows?: readonly number[]): void;
hiddenRows(): readonly number[];
hideColumns(cols?: readonly number[]): void;
showColumns(cols?: readonly number[]): void;
hiddenColumns(): readonly number[];
groupRows(start: number, end: number): void;
ungroupRows(start: number, end: number): void;
setGroupCollapsed(start: number, collapsed: boolean): void;
rowGroups(): readonly RowGroup[];
clearView(): void;
undo(): void;
redo(): void;
exportCsv(filename: string): void;
exportXlsx(filename: string): Promise<void>;
search(query: string, opts?: SearchOptions): SearchResult;
findNext(): SearchResult;
findPrev(): SearchResult;
clearSearch(): void;
replaceCurrent(replacement: string): SearchResult;
replaceAll(replacement: string): ReplaceResult;
insertRows(at: number, count?: number): void;
removeRows(at: number, count?: number): void;
insertColumns(at: number, count?: number): void;
removeColumns(at: number, count?: number): void;
addSheet(input: AddSheetInput): SheetId;
removeSheet(id: SheetId): void;
renameSheet(id: SheetId, name: string): void;
moveSheet(id: SheetId, toIndex: number): void;
setConditionalFormats(rules: readonly ConditionalFormatRule[]): void;
setValidationRule(rule: DataValidationRule): ApplyTransactionResult;
removeValidationRule(id: string): ApplyTransactionResult;
setProtectedRange(protectedRange: ProtectedRange): ApplyTransactionResult;
removeProtectedRange(id: string): ApplyTransactionResult;
setProtectionResolver(
resolver: ProtectionResolver | undefined,
mode?: MutationPolicyMode,
): void;
setNote(addr: CellAddress, text: string | null): ApplyTransactionResult;
getNote(addr: CellAddress): string | null;
setOverscan(overscan?: number): void;
setMinColumns(minColumns?: number): void;
highlightCells(
ranges: readonly HighlightRange[] | null,
color?: string,
): void;
setPresenceOverlays(overlays: readonly PresenceOverlay[] | null): void;
styleRange(range: Range, style: Partial<CellStyle> | null): void;
beginEdit(
row: number,
col: number,
initial?: string,
selectAll?: boolean,
): void;
dataEdge(
row: number,
col: number,
dRow: number,
dCol: number,
): number | null;
setRowHeight(row: number, height: number): void;
setColumnWidth(col: number, width: number): void;
autoFitRows(range?: Range): void;
autoFitColumns(cols?: readonly number[]): void;
setFrozen(rows: number, cols?: number): void;
setZoom(zoom: number): void;
getZoom(): number;
rendererKind(): "canvas" | "worker";
on<E extends keyof GridEvents>(
evt: E,
fn: (e: GridEvents[E]) => void,
): () => void;
refresh(): void;
destroy(): void;
}