v1.3.0 What's new: the changelog

Excel files,
handled right.

Read, write, style and encrypt Excel .xlsx files in JavaScript and TypeScript, with a Rust core compiled to WebAssembly.

npm install modern-xlsx
0
Runtime dependencies
MIT
License
TS
Type definitions bundled
5
Runtimes tested in CI

Features

What the library reads and writes, all under the MIT license.

Cell styling

Fonts, fills, borders, alignment, text rotation, shrink-to-fit. Fluent builder API produces style indices for any cell.

Number formats

Built-in Excel format codes plus custom formats. formatCell() turns a value and a format code into display text for dates, currency, percentages and scientific notation.

Data validation

List, whole number, decimal, date, time, text length and custom formula rules, with input prompts and error messages.

Conditional formatting

Color scales, data bars, icon sets and formula-based rules, read and written.

Charts

Ten chart types (bar, column, line, pie, doughnut, scatter, area, radar, bubble and stock) built with the fluent ChartBuilder. Other chart XML is kept verbatim.

Images and barcodes

addImage embeds PNG, JPEG and GIF images; addBarcode draws QR, Code 128, EAN-13, UPC-A, Code 39, ITF-14 and GS1-128 symbols into the sheet.

Pivot tables

Read and write pivot tables. PivotTableBuilder builds the definition; Excel computes the table's values when it opens the file.

Formula engine

Evaluate formulas in memory with 54 built-in Excel functions, following Excel's semantics for type coercion, error propagation and operators.

Streaming writer

StreamingXlsxWriter writes rows one at a time without building a Workbook first. It holds the compressed output in memory until finish() returns it.

Frozen panes

Freeze rows, columns or both with frozenPane, or set split panes with splitPane.

Hyperlinks

Internal sheet links, external URLs and mailto links, with display text and tooltips.

Comments and notes

Add, read and remove cell comments with an author. Threaded comments are read and written too.

Sheet protection

Protect a worksheet through its sheetProtection settings, and lock the workbook structure or windows through Workbook.protection.

Encryption

Open and save password-protected .xlsx files (full build). Writes ECMA-376 Agile Encryption with AES-256, SHA-512 and 100,000 spin rounds; reads Agile and Standard Encryption.

Page setup

Paper size, orientation, print scale, margins, headers and footers, and page breaks.

Dates and Temporal

dateToSerial() takes a Date or a TemporalLike: a Temporal.PlainDate, a Temporal.PlainDateTime or any object with year, month and day. serialToDate() returns a Date.

Rust and WebAssembly core

The Rust core, compiled to WebAssembly, does the ZIP compression and decompression and the SAX-style XML parsing. The modern-xlsx/lite build leaves encryption out for a smaller binary.

Tree-shakable ESM

The modern-xlsx and modern-xlsx/lite entries are ES modules with "sideEffects": false and no runtime dependencies, so bundlers can drop unused JavaScript exports. The WASM binary is loaded whole.

Quick start

Create a styled spreadsheet, save it and read it back in Node.js.

example.mjs (Node)
import { initWasm, Workbook, readFile } from 'modern-xlsx';

await initWasm();

// Create a new workbook
const wb = new Workbook();
const ws = wb.addSheet('Sales');

ws.cell('A1').value = 'Product';
ws.cell('B1').value = 'Revenue';
ws.cell('A2').value = 'Widget';
ws.cell('B2').value = 9999.99;

// Style headers
const header = wb.createStyle()
  .font({ bold: true, size: 14, color: '1F4E79' })
  .fill({ pattern: 'solid', fgColor: 'D6E4F0' })
  .alignment({ horizontal: 'center' })
  .build(wb.styles);

ws.cell('A1').styleIndex = header;
ws.cell('B1').styleIndex = header;

// Currency format
const currency = wb.createStyle()
  .numberFormat('$#,##0.00')
  .build(wb.styles);
ws.cell('B2').styleIndex = currency;

await wb.toFile('sales.xlsx');

// Read the file back
const saved = await readFile('sales.xlsx');
console.log(saved.getSheet('Sales')?.cell('A1').value); // 'Product'

API overview

Full documentation: the package README and the generated API reference.

CategoryFunctions and classes
Core initWasm() · Workbook · Worksheet · Cell
I/O readFile() · readBuffer() · wb.toFile() · wb.toBuffer() · writeBlob()
Styles StyleBuilder — .font() .fill() .border() .alignment() .numberFormat() .build()
Conversions aoaToSheet() · jsonToSheet() · sheetToJson() · sheetToCsv() · sheetToHtml()
Dates dateToSerial() · serialToDate() · isDateFormatId()
Formatting formatCell() · getBuiltinFormat()
Cell references encodeCellRef() · decodeCellRef() · encodeRange() · decodeRange()
Rich text RichTextBuilder — .text() .bold() .italic() .styled() .build()

Architecture

A TypeScript API over a Rust core compiled to WebAssembly.

Architecture of modern-xlsx in three layers: the TypeScript API (the modern-xlsx package), the WASM boundary built with wasm-bindgen, and the Rust core (the modern-xlsx-core crate). Read path: readBuffer, or readFile which loads the bytes and calls readBuffer, passes the bytes to the WASM read(data, limits). The Rust core detects whether the file is ZIP or OLE2, unzips it within the ZIP limits, SAX-parses each part with quick-xml and streams a JSON string of at most maxJsonLength bytes back across the boundary, where JSON.parse turns it into a Workbook. Write path: Workbook.toBuffer() passes JSON.stringify output to the WASM write(json); the Rust core decodes it with serde_json into WorkbookData, writes the parts with the shared string table built inline, zips them with Deflate at level 6 and returns a Uint8Array. Encryption is a Cargo feature in the full build only, not in /lite: it gates the WASM exports readWithPassword and writeWithPassword, which decrypt and encrypt as listed.

Workbook data crosses the WASM boundary as JSON strings. The Rust core handles ZIP compression and decompression, SAX-style XML parsing and the shared string table (SST). On write it collects every shared-string cell into the SST first, then replaces each one's text with its SST index while it writes each sheet's XML, without cloning the worksheet. Inline-string cells stay inline.

Comparison

modern-xlsx next to SheetJS Community Edition 0.20.3 and SheetJS Pro. Competitor facts as of 2026-11-11, from docs.sheetjs.com, sheetjs.com/pro, the npm registry and the SheetJS CDN. The longer comparison is in FEATURE-COMPARISON.md.

Featuremodern-xlsxSheetJS CESheetJS Pro
Read and write .xlsxYesYesNot stated
Cell styles on writeYesPartial: row and column styling metadata
Number formats rendered to textYesYes
Conditional formatting on writeYes
Data validationYesNot documented
Charts on writeYes
Images on writeYes
Pivot tables on writeYes
Cell commentsYesYes
Threaded commentsYesYesNot stated
Sheet protection on writeYesYesNot stated
Open password-encrypted filesYes (Agile and Standard)Partial: XOR-encrypted XLS only
Encrypt on writeYes (Agile, AES-256)
Streaming writeYes (StreamingXlsxWriter)Partial: CSV, HTML, JSON and SpreadsheetML 2003 streams; no XLSX stream writerNot stated
Browser, Node.js, DenoYesYesNot stated
BunYesPartial: documented as experimentalNot stated
Cloudflare WorkersYesNot documented (a Deno Deploy demo exists)Not stated
Bundled TypeScript typesYesYesNot stated
Current release on npmYesNo: npm stops at 0.18.5 (2022); 0.20.3 is on cdn.sheetjs.comNo: sold by inquiry
Runtime dependencies00 (0.20.3)Not stated
LicenseMITApache-2.0

— in the SheetJS Pro column means sheetjs.com/pro does not state it (checked 2026-11-11).

modern-xlsx runtime rows: CI runs the tests on Node 24 and 26 and in Chromium, and runs the examples under Bun, Deno and a local Cloudflare Worker (wrangler dev --local). Encryption needs the full build, not modern-xlsx/lite.