-
Notifications
You must be signed in to change notification settings - Fork 1
Migration from SheetJS
ABCrimson edited this page Mar 2, 2026
·
2 revisions
This guide maps common SheetJS (xlsx/XLSX) API calls to their modern-xlsx equivalents.
// SheetJS — no init needed
import * as XLSX from 'xlsx';
// modern-xlsx — init WASM once
import { initWasm } from 'modern-xlsx';
await initWasm();// SheetJS
const wb = XLSX.readFile('data.xlsx');
const wb = XLSX.read(buffer, { type: 'buffer' });
// modern-xlsx
import { readFile, readBuffer } from 'modern-xlsx';
const wb = await readFile('data.xlsx');
const wb = await readBuffer(uint8Array);// SheetJS
XLSX.writeFile(wb, 'output.xlsx');
const buf = XLSX.write(wb, { type: 'buffer', bookType: 'xlsx' });
// modern-xlsx
await wb.toFile('output.xlsx');
const buf = await wb.toBuffer();// SheetJS
const ws = wb.Sheets['Sheet1'];
const names = wb.SheetNames;
// modern-xlsx
const ws = wb.getSheet('Sheet1');
const names = wb.sheetNames;// SheetJS
const cell = ws['A1'];
const value = cell?.v;
// modern-xlsx
const cell = ws.cell('A1');
const value = cell.value;// SheetJS
const ws = XLSX.utils.aoa_to_sheet(data);
const aoa = XLSX.utils.sheet_to_json(ws, { header: 1 });
// modern-xlsx
import { aoaToSheet, sheetToJson } from 'modern-xlsx';
const ws = aoaToSheet(data);
const json = sheetToJson(ws);// SheetJS
const data = XLSX.utils.sheet_to_json(ws);
const csv = XLSX.utils.sheet_to_csv(ws);
// modern-xlsx
import { sheetToJson, sheetToCsv } from 'modern-xlsx';
const data = sheetToJson(ws);
const csv = sheetToCsv(ws);// SheetJS Pro (paid)
ws['A1'].s = {
font: { bold: true, color: { rgb: 'FF0000' } },
fill: { fgColor: { rgb: 'FFFF00' } },
};
// modern-xlsx (free)
const style = wb.createStyle()
.font({ bold: true, color: 'FF0000' })
.fill({ pattern: 'solid', fgColor: 'FFFF00' })
.build(wb.styles);
ws.cell('A1').styleIndex = style;| Aspect | SheetJS | modern-xlsx |
|---|---|---|
| Module format | CJS + global | ESM only |
| Types |
@types/xlsx (partial) |
Built-in, strict |
| Styling | Pro only (paid) | Free |
| Cell access | ws['A1'] |
ws.cell('A1') |
| I/O | Synchronous | Async (WASM) |
| Date handling |
dateNF option |
dateToSerial() + format |
| npm availability | CDN only | npm registry |
| Bundle format | Single large file | Tree-shakable ESM |
modern-xlsx v1.0.0
Getting Started
Guides
- Charts & Visualizations
- Formula Engine
- Table Layout Engine
- Tables & Print Layout
- Encryption
- Feature Comparison
Reference
Migration
Project