Skip to content

Quick start

Install with npm install @agent-sheet/wasm and use Node.js 22 or newer. Create a workbook, save it, then read it back:

quickstart.js
const XLSX = require("@agent-sheet/wasm");
const ws = XLSX.utils.aoa_to_sheet([["Item", "Price"], ["abc", 1.23], ["def", 4.56]]);
XLSX.utils.sheet_set_range_style(ws, "A1:B1", { bold: true });
XLSX.utils.sheet_set_range_style(ws, "B2:B3", { z: "0.00" });
const wb = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(wb, ws, "Prices");
XLSX.writeFile(wb, "quickstart.xlsx", { cellStyles: true });
const back = XLSX.readFile("quickstart.xlsx", { cellStyles: true });
console.log(back.SheetNames, back.Sheets.Prices.A1.s.bold);
Output
[ 'Prices' ] 1

A workbook is a plain object. It has SheetNames and Sheets. A worksheet maps cell addresses such as A1 to cell objects. Keys that start with ! hold sheet-level data such as !ref (the used range).

const XLSX = require("@agent-sheet/wasm");
const wb = XLSX.read("a,b\n1,2", { type: "string" });
const ws = wb.Sheets[wb.SheetNames[0]];
console.log(wb.SheetNames);
console.log(ws["!ref"]);
console.log(ws.A1, ws.A2);
Output
[ 'Sheet1' ]
A1:B2
{ w: 'a', t: 's', v: 'a' } { w: '1', t: 'n', v: 1 }

A cell has a type t (n number, s string, b boolean, d date, e error, z blank), a raw value v, a formatted text w and optionally a formula f, a number format z and a style s.