Skip to content
1 min read · 277 words

@nhtio/adk/batteries/media/engines/sheetjs

The SheetJS-backed spreadsheet @nhtio/adk/batteries/media/contracts!MediaEngine: the in-process, cross-environment spreadsheet converter, generator, and structural editor.

Remarks

SheetJS (the xlsx package) reads and writes the widest spreadsheet matrix of any pure-JS library — XLSX/XLSM/XLSB, every XLS BIFF era, ODS/FODS, CSV, SYLK, DIF, DBF, HTML, RTF, Apple NUMBERS — with no binary, no native bindings, in any environment. This engine exposes that matrix three ways:

  • convert: any readable spreadsheet MIME → any writable format token.
  • generate: EMPTY_MIME → any writable token (a blank Sheet1 workbook, written out).
  • edit: the sheet.* structural ops via CSF cell-object surgery. ⚠️ SheetJS Community Edition does NOT model cell styling — fonts, fills, and comments are STRIPPED by any edit or convert that round-trips a styled workbook (styling is a SheetJS Pro feature). For fidelity-preserving edits compose the exceljs engine FIRST in the engines array; this engine's edits are for unstyled/data workbooks and for breadth (it edits ODS, XLS, and every other readable format by normalizing through CSF).

⚠️ Install from the SheetJS CDN, not the npm registry. The registry copy of xlsx is frozen at 0.18.5 (2023) and carries CVE-2023-30533 and CVE-2024-22363; this engine requires >=0.20.2. Install: pnpm add xlsx@https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz (SheetJS recommends vendoring the tarball — see docs.sheetjs.com).

xlsx is an optional peer dependency, lazily imported on first actual use. The NUMBERS write target additionally loads the ZAHL payload (xlsx/dist/xlsx.zahl.mjs, ~110 KB) on first request of that specific target.

Interfaces

InterfaceDescription
SheetjsEngineOptionsOptions for sheetjsEngine.

Functions

FunctionDescription
sheetjsEngineConstruct the SheetJS-backed spreadsheet engine.