Whether this wrapper still refers to a live engine object.
Number of sheets in the workbook.
The active sheet's 0-based index.
The workbook's live selection (active cell, anchor, ranges).
The active sheet.
Whether an undo step is available.
Whether a redo step is available.
Number of workbook-scope defined names.
Number of embedded images across the workbook.
Reference equality is the identity test — prefer a === b. This is retained only for
the rare cross-realm case where two wrappers describe the same handle by value. Reads the
raw index so comparing a stale wrapper never throws.
A readable identity for logs and diagnostics, never [object Object].
Delete the index-th sheet; returns whether it was removed.
Duplicate the index-th sheet; returns the new sheet, or null on failure.
Make the index-th sheet active.
Recalculate every formula (call after a batch of programmatic edits).
Snapshot the current workbook so the next edit can be undone.
Undo one step; returns whether anything changed.
Redo one step; returns whether anything changed.
Begin a find session over the active sheet. flags OR together FindFlag
options (match case, whole cell, regex). Returns a FindSession that navigates
the selection and drives replace.
Register (or overwrite) a workbook-scope defined name pointing at a cell/range.
The index-th defined name and its reference, or null if out of range.
Load TAB/newline-separated text into sheet starting at (row, column) (each field
inferred as number / formula / text). Recalculates afterward.
Load delimited text into the active sheet starting at A1, typing each field the way the
editor would (a leading = is a formula, a numeric field a number, otherwise text). The
delimiter defaults to ,; pass { delimiter: "\t" } or similar for TSV and friends.
Quoted fields, escaped "", and embedded delimiters/newlines inside quotes are honoured.
Existing cells are not cleared first, so load into a freshly opened workbook. Recalculates
afterward and returns this.
Optionaloptions: { delimiter?: string }Replace this workbook's content with an existing .xlsx package read from encoded bytes, mirroring import("./document").Document.importDocx. Unlike rebuilding a workbook cell-by-cell through the authoring API, this preserves every sheet, cell values and formulas, rich text, FULL cell styling (fonts, fills, per-edge + diagonal borders, number formats, alignment), merged ranges, frozen panes, explicit column widths, the theme palette, and workbook-scoped defined names.
Not yet preserved (documented honestly; a cell-by-cell rebuild loses these too): charts, pictures, conditional formatting, data validation, Excel Tables, comments, hyperlinks, sparklines, pivot tables, autofilters, column outline groups, print/page setup, and core document properties.
Requirements: the attached engine MUST be the WebSheets build (this drives the engine's
_ws_* import ops, which no other engine exposes), and a DOM is needed to parse the XML.
globalThis.DOMParser is used — browsers provide it natively; in Node, install a DOMParser
shim onto globalThis first. The SDK never fetches anything. Throws if the engine is not
WebSheets, no DOM is available, or the workbook exceeds the import size budget.
Export the workbook. xlsx works anywhere; pdf needs the GPU renderer.
Close the workbook handle and release its wrappers.
A workbook. Reads are property getters straight off the engine model; navigation returns cached wrappers (
===identity); editing mutators chain and repaint any attached viewport. The PNG path is thumbnail-only — the live view presents through the WebGPU swapchain.