API Reference

ExcelJS

Library to read and write XLSX workbooks with styling, formulas, streams and cell formatting.

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

Installation

npmnpm install exceljs
pnpmpnpm add exceljs
yarnyarn add exceljs

Methods

Overview

ExcelJS reads and writes XLSX spreadsheets from Node.js, covering formatting, formulas, merged cells and streaming for both input and output. It targets the modern Office Open XML format.

Core Methods

Create a Workbook, add Worksheets, then add rows. Reading uses readFile or a stream, and writing uses writeFile, writeBuffer or write to a stream. Cells expose value and style.

Usage Notes

For large exports write to a response stream instead of building the whole workbook in memory. Style headers once and reuse the worksheet columns for widths and formats.

Common Pitfalls

ExcelJS does not calculate formulas, so cells show empty until Excel recalculates. Buffering a huge workbook can exhaust memory, so stream when row counts are high. Styling every cell individually is slow.

Errors

The following points are quoted verbatim from the official documentation. 来源:https://cdn.jsdelivr.net/gh/exceljs/exceljs@latest/README.md · 取证方式:HTTP GET 官方 README/文档页(HTML 去标签) · 抓取时间:2026-11-07T13:49:30.791Z. Any error type, throw condition or recovery step not stated there is left unspecified; this page does not infer exception classes or return values.

Security notes

Quoted verbatim from the official documentation; this is not a complete threat model. 来源:https://cdn.jsdelivr.net/gh/exceljs/exceljs@latest/README.md · 取证方式:HTTP GET 官方 README/文档页(HTML 去标签) · 抓取时间:2026-11-07T13:49:30.791Z.

FAQ

How do I read an existing file?
Use workbook.xlsx.readFile(path) or read a stream, then iterate worksheets and rows. readFile is convenient for local files while streams avoid loading everything into memory.
Can I apply styles?
Yes. Rows, columns and cells expose style objects for fonts, fills, borders and number formats. Styling is applied per cell, so set it on ranges rather than individual cells where possible.
How are formulas handled?
Set a cell value to an object such as { formula: "SUM(A1:A3)" }. The formula is stored; ExcelJS does not evaluate it, so cached results come from Excel when the file is reopened.