-
Notifications
You must be signed in to change notification settings - Fork 1
Getting Started
ABCrimson edited this page Mar 2, 2026
·
17 revisions
npm install modern-xlsx # or pnpm add modern-xlsx # or yarn add modern-xlsx
Requires a runtime with WASM support: Node.js 24+, Bun, Deno, or modern browsers.
Before any operation, initialize the WASM module once:
import { initWasm } from 'modern-xlsx'; await initWasm();
This loads and compiles the ~870 KB WASM binary. Call it once at application startup.
import { Workbook } from 'modern-xlsx'; const wb = new Workbook(); const ws = wb.addSheet('Sheet1'); // Set values ws.cell('A1').value = 'Name'; ws.cell('B1').value = 'Age'; ws.cell('A2').value = 'Alice'; ws.cell('B2').value = 30;
const headerStyle = wb.createStyle() .font({ bold: true, size: 12, color: '1F4E79' }) .fill({ pattern: 'solid', fgColor: 'D6E4F0' }) .alignment({ horizontal: 'center' }) .build(wb.styles); ws.cell('A1').styleIndex = headerStyle; ws.cell('B1').styleIndex = headerStyle;
// Node.js / Bun / Deno await wb.toFile('output.xlsx'); // Any environment (returns Uint8Array) const buffer = await wb.toBuffer(); // Browser (returns Blob) import { writeBlob } from 'modern-xlsx'; const blob = writeBlob(wb);
import { readFile, readBuffer } from 'modern-xlsx'; // From file path const wb = await readFile('data.xlsx'); // From buffer const wb = await readBuffer(uint8Array); // Access data const ws = wb.getSheet('Sheet1'); console.log(ws?.cell('A1').value);
- Styling Guide — Full styling reference
- API Reference — Complete API docs
- Performance — Optimization tips
modern-xlsx v1.0.0
Getting Started
Guides
- Charts & Visualizations
- Formula Engine
- Table Layout Engine
- Tables & Print Layout
- Encryption
- Feature Comparison
Reference
Migration
Project