Use @sheetwrite/core when the host owns DOM lifetime directly. Call initSheetwrite() on the client, pass an existing element to createGrid, and retain the returned Grid for events and commands.
} from "@sheetwrite/core" ;
export async function mountSheetwrite (
A datasource-backed grid may use dense storage or allocation-lazy paged storage. Full-sheet operations can throw IncompleteDataError until every required page is loaded. Worker rendering automatically falls back to the main-thread canvas when capabilities or startup fail; observe renderer-fallback if the host needs to report that transition.
function createGrid(host: HTMLElement, opts: GridOptions): Grid function createGrid (
host : HTMLElement ,
opts : GridOptions ,
) : Grid function createGrid (
host : HTMLElement ,
opts : GridOptions ,
) : Grid Creates and mounts an imperative Grid in the supplied host element. @example import { createGrid, initSheetwrite } from "@sheetwrite/core"; await initSheetwrite(); const host = document.createElement("div"); host.style.height = "400px"; document.body.append(host); const grid = createGrid(host, { workbook: { activeSheet: "sales", sheets: [{ id: "sales", name: "Sales", rowCount: 2, columns: [{ key: "amount", header: "Amount", type: "number", width: 120 }] }], }, data: { rowCount: 2, columns: { amount: [12, 18] } }, }); grid.scrollToCell({ sheet: "sales", row: 1, col: 0 }); // Call when the host view is removed. grid.destroy();@see Grid *@see GridOptionsAPI reference → function initSheetwrite(source?: BufferSource | URL | string | Request | WebAssembly.Module, engine?: SheetwriteEngine): Promise<void> function initSheetwrite (
source ?:
BufferSource | URL | string | Request | WebAssembly . Module ,
engine ?: SheetwriteEngine ,
) : Promise < void > function initSheetwrite (
source ?:
| BufferSource
| URL
| string
| Request
| WebAssembly . Module ,
engine ?: SheetwriteEngine ,
) : Promise < void > Load one WASM engine before createGrid. The default is @sheetwrite/wasm. Pass the @sheetwrite/formulas module as the second argument to select the full engine. @example import { initSheetwrite } from "@sheetwrite/core"; import * as formulas from "@sheetwrite/formulas"; await initSheetwrite(undefined, formulas);@see /docs/guides/formulas/@see createGridAPI reference → interface ChangeEvent interface ChangeEvent interface ChangeEvent Payload of the change event; flows OUT for API submission/reconcile. API reference → interface ColumnarData interface ColumnarData interface ColumnarData Eager column-oriented values used to initialize a sheet. API reference → interface Workbook interface Workbook interface Workbook Live workbook schema containing ordered sheets and the active sheet ID. API reference → function mountSheetwrite(host: HTMLElement, workbook: Workbook, data: ColumnarData, persistChange: (event: ChangeEvent) => void): Promise<() => void> function mountSheetwrite (
host : HTMLElement ,
workbook : Workbook ,
data : ColumnarData ,
persistChange : ( event : ChangeEvent ) => void ,
) : Promise <() => void > function mountSheetwrite (
host : HTMLElement ,
workbook : Workbook ,
data : ColumnarData ,
persistChange : (
event : ChangeEvent ,
) => void ,
) : Promise <() => void > interface HTMLElement interface HTMLElement interface HTMLElement The HTMLElement interface represents any HTML element. MDN Reference workbook: Workbook let workbook : Workbook let workbook : Workbook Live workbook schema adopted by the store and updated by document operations. API reference → data: ColumnarData let data : ColumnarData let data : ColumnarData Eager column-major values loaded into workbook.activeSheet; use instead of datasource. API reference → const grid: Grid const grid : Grid const grid : Grid The imperative core grid this controller owns. API reference → host: HTMLElement let host : HTMLElement let host : HTMLElement GridOptions.workbook: Workbook interface GridOptions {
workbook : Workbook ;
} interface GridOptions {
workbook : Workbook ;
} Live workbook schema adopted by the store and updated by document operations. API reference → GridOptions.data?: ColumnarData | undefined interface GridOptions {
data ?: ColumnarData | undefined ;
} interface GridOptions {
data ?: ColumnarData | undefined ;
} Eager column-major values loaded into workbook.activeSheet; use instead of datasource. API reference → const off: () => void const off : () => void const off : () => void Grid.on<"change">(evt: "change", fn: (e: ChangeEvent) => void): () => void Grid. on < "change" >(evt: "change" , fn: ( e : ChangeEvent ) => void ): () => void Grid. on < "change" >(evt: "change" , fn: ( e : ChangeEvent ) => void ): () => void persistChange: (event: ChangeEvent) => void let persistChange : ( event : ChangeEvent ) => void let persistChange : (
event : ChangeEvent ,
) => void API reference → Grid.destroy(): void Grid. destroy (): void Grid. destroy (): void Runs immediately before a retained element is removed or replaced. API reference →