API Reference

SheetJS

Spreadsheet toolkit that reads and writes XLSX, CSV and other formats and converts between them.

Official Documentation ↗
CompatibilityThis documentation covers version SheetJS Community v0.18.x / Node 18 LTS. Check the official docs for the latest API surface.

Installation

npmnpm install xlsx
pnpmpnpm add xlsx
yarnyarn add xlsx

Methods

Overview

SheetJS parses and generates spreadsheet files across many formats, treating workbooks as a uniform object model. The same code can read an XLSX and emit a CSV, which is convenient for data pipelines.

Core Methods

read and readFile produce a WorkBook with a Sheets map and SheetNames list. sheet_to_json converts a sheet to rows, and writeFile or write serializes back to a chosen format.

Usage Notes

Normalize via sheet_to_json with defval and header options so downstream code gets predictable objects. Use cellDates on read to avoid manual serial-number math.

Common Pitfalls

Choosing the wrong type option corrupts parsing silently. Blank cells vanish unless defval is set, which changes row shapes. Very large sheets should be streamed or processed in chunks to control memory.

FAQ

How do I choose the input type?
Pass type "buffer" for Node buffers, "array" for typed arrays, "binary" for binary strings, and "file" when reading directly from a path. Using the wrong type yields corrupt results.
How are dates represented?
Dates are stored as serial numbers by default. Use cellDates: true on read so date cells become JavaScript Date objects, and set a date format when writing to keep them readable.
Can I convert CSV to XLSX?
Yes. Read the CSV with the right type, then write with an .xlsx filename. The format is chosen by the output filename extension.