-
Notifications
You must be signed in to change notification settings - Fork 1
Migration from ExcelJS
ABCrimson edited this page Mar 3, 2026
·
3 revisions
This guide maps common ExcelJS API calls to their modern-xlsx equivalents.
- npm install exceljs
+ npm install modern-xlsx// ExcelJS — no init needed
import ExcelJS from 'exceljs';
// modern-xlsx — init WASM once
import { initWasm } from 'modern-xlsx';
await initWasm();// ExcelJS
const wb = new ExcelJS.Workbook();
// modern-xlsx
const wb = new Workbook();// ExcelJS
const ws = wb.addWorksheet('Sales');
// modern-xlsx
const ws = wb.addSheet('Sales');// ExcelJS
ws.getCell('A1').value = 'Hello';
ws.getCell('A2').value = 42;
// modern-xlsx
ws.cell('A1').value = 'Hello';
ws.cell('A2').value = 42;// ExcelJS
ws.getCell('A4').value = { formula: 'SUM(A1:A3)', result: 42 };
// modern-xlsx
ws.cell('A4').formula = 'SUM(A1:A3)';// ExcelJS — per-cell style objects
ws.getCell('A1').font = { bold: true, color: { argb: 'FFFF0000' } };
ws.getCell('A1').fill = {
type: 'pattern',
pattern: 'solid',
fgColor: { argb: 'FFFFFF00' },
};
// modern-xlsx — shared style table
const style = wb.createStyle()
.font({ bold: true, color: 'FF0000' })
.fill({ pattern: 'solid', fgColor: 'FFFF00' })
.build(wb.styles);
ws.cell('A1').styleIndex = style;// ExcelJS
ws.mergeCells('A1:C1');
// modern-xlsx
ws.addMergeCell('A1:C1');// ExcelJS
ws.getColumn('A').width = 20;
ws.getRow(1).height = 30;
// modern-xlsx
ws.setColumnWidth(1, 20);
ws.setRowHeight(1, 30);// ExcelJS
ws.views = [{ state: 'frozen', xSplit: 0, ySplit: 1 }];
// modern-xlsx
ws.frozenPane = { rows: 1, cols: 0 };// ExcelJS
ws.getCell('A1').dataValidation = {
type: 'list',
formulae: ['"Yes,No,Maybe"'],
};
// modern-xlsx
ws.addValidation('A1', {
validationType: 'list',
formula1: '"Yes,No,Maybe"',
showDropDown: true,
});// ExcelJS
const wb = new ExcelJS.Workbook();
await wb.xlsx.readFile('data.xlsx');
await wb.xlsx.load(buffer);
// modern-xlsx
import { readFile, readBuffer } from 'modern-xlsx';
const wb = await readFile('data.xlsx');
const wb = await readBuffer(new Uint8Array(buffer));// ExcelJS
await wb.xlsx.writeFile('output.xlsx');
const buffer = await wb.xlsx.writeBuffer();
// modern-xlsx
await wb.toFile('output.xlsx');
const buffer = await wb.toBuffer();| Feature | ExcelJS | modern-xlsx |
|---|---|---|
| Runtime | Pure JS (streaming) | Rust WASM |
| Styles | Per-cell objects | Shared style table + index |
| Cell access | ws.getCell('A1') |
ws.cell('A1') |
| Merge cells | ws.mergeCells(range) |
ws.addMergeCell(range) |
| Sheet creation | wb.addWorksheet(name) |
wb.addSheet(name) |
| Dependencies | 14+ | 0 (WASM bundled) |
| Bundle size | ~2 MB | ~994 KB |
modern-xlsx v1.0.0
Getting Started
Guides
- Charts & Visualizations
- Formula Engine
- Table Layout Engine
- Tables & Print Layout
- Encryption
- Feature Comparison
Reference
Migration
Project