@squareys/webdecks-sdk - v0.0.0
    Preparing search index...

    Class Spreadsheet

    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.

    Hierarchy (View Summary)

    Index
    • get isValid(): boolean

      Whether this wrapper still refers to a live engine object.

      Returns boolean

    • set _index(value: number): void

      Parameters

      • value: number

      Returns void

    • get sheetCount(): number

      Number of sheets in the workbook.

      Returns number

    • get activeSheetIndex(): number

      The active sheet's 0-based index.

      Returns number

    • get selection(): SheetSelection

      The workbook's live selection (active cell, anchor, ranges).

      Returns SheetSelection

    • get activeSheet(): Sheet

      The active sheet.

      Returns Sheet

    • get canUndo(): boolean

      Whether an undo step is available.

      Returns boolean

    • get canRedo(): boolean

      Whether a redo step is available.

      Returns boolean

    • get definedNameCount(): number

      Number of workbook-scope defined names.

      Returns number

    • get imageCount(): number

      Number of embedded images across the workbook.

      Returns number

    • 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.

      Parameters

      • other: Handle<unknown> | null

      Returns boolean

    • A readable identity for logs and diagnostics, never [object Object].

      Returns string

    • The index-th sheet, or null if out of range.

      Parameters

      • index: number

      Returns Sheet | null

    • Collect the sheets into out (or a fresh array).

      Parameters

      Returns Sheet[]

    • Append a sheet (optionally named); returns its wrapper.

      Parameters

      • name: string = ""

      Returns Sheet

    • Delete the index-th sheet; returns whether it was removed.

      Parameters

      • index: number

      Returns boolean

    • Duplicate the index-th sheet; returns the new sheet, or null on failure.

      Parameters

      • index: number

      Returns Sheet | null

    • Make the index-th sheet active.

      Parameters

      • index: number

      Returns this

    • Recalculate every formula (call after a batch of programmatic edits).

      Returns this

    • Snapshot the current workbook so the next edit can be undone.

      Returns this

    • Undo one step; returns whether anything changed.

      Returns boolean

    • Redo one step; returns whether anything changed.

      Returns boolean

    • 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.

      Parameters

      • query: string
      • flags: number = 0

      Returns FindSession

    • Register (or overwrite) a workbook-scope defined name pointing at a cell/range.

      Parameters

      • name: string
      • reference: string

      Returns this

    • The index-th defined name and its reference, or null if out of range.

      Parameters

      • index: number

      Returns DefinedName | null

    • Load TAB/newline-separated text into sheet starting at (row, column) (each field inferred as number / formula / text). Recalculates afterward.

      Parameters

      • text: string
      • sheet: number = 0
      • row: number = 0
      • column: number = 0

      Returns this

    • 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.

      Parameters

      • text: string
      • Optionaloptions: { delimiter?: string }

      Returns Promise<Spreadsheet>

    • 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.

      Parameters

      Returns Promise<Spreadsheet>

    • Export the workbook. xlsx works anywhere; pdf needs the GPU renderer.

      Parameters

      Returns Promise<Uint8Array<ArrayBufferLike>>

    • Render one sheet offscreen and return it as a PNG Blob. Uses the export/capture path (the browser encodes the PNG), never the live view. Needs the GPU renderer.

      Parameters

      • sheet: number
      • width: number
      • height: number
      • scale: number = 1

      Returns Promise<Blob>

    • Close the workbook handle and release its wrappers.

      Returns void