Cette page est affichée en anglais. Une traduction française est en cours.
ScriptsMay 16, 2026·3 min de lecture

ExcelJS — Read, Write, and Stream Excel Spreadsheets in Node.js

A full-featured library for creating, reading, and manipulating XLSX and CSV files in Node.js with streaming support for large datasets.

Prêt pour agents

Cet actif peut être lu et installé directement par les agents

TokRepo expose une commande CLI universelle, un contrat d'installation, le metadata JSON, un plan selon l'adaptateur et le contenu raw pour aider les agents à juger l'adaptation, le risque et les prochaines actions.

Native · 98/100Policy : autoriser
Surface agent
Tout agent MCP/CLI
Type
Skill
Installation
Single
Confiance
Confiance : Established
Point d'entrée
ExcelJS Overview
Commande CLI universelle
npx tokrepo install cc9ce2fb-50fe-11f1-9bc6-00163e2b0d79

Introduction

ExcelJS provides a complete API for generating and parsing Excel files in Node.js without requiring Microsoft Office. It supports rich formatting, formulas, images, charts metadata, and streaming — making it suitable for server-side report generation and ETL pipelines that handle millions of rows.

What ExcelJS Does

  • Creates XLSX workbooks with multiple sheets, cell styles, merged cells, and conditional formatting
  • Reads existing XLSX files preserving formulas, data validations, and defined names
  • Streams rows to disk or HTTP responses for memory-efficient export of large datasets
  • Supports CSV reading and writing with configurable delimiters and encoding
  • Handles rich cell types including dates, hyperlinks, rich text, and images

Architecture Overview

ExcelJS models workbooks as in-memory object graphs of worksheets, rows, and cells. The XLSX serializer uses a streaming XML writer (SAX-style) that flushes sheet data in chunks, preventing memory exhaustion on large exports. For reading, it provides both a full-parse mode (entire workbook in memory) and a streaming reader that emits row events, suitable for processing files that exceed available RAM.

Self-Hosting & Configuration

  • Install from npm — pure JavaScript, no native bindings required
  • Use workbook.xlsx.writeFile(path) for disk output or workbook.xlsx.write(stream) for HTTP responses
  • Enable streaming writes via new ExcelJS.stream.xlsx.WorkbookWriter({ stream }) for constant-memory exports
  • Configure default column widths, row heights, and page setup (orientation, margins) per worksheet
  • Set number formats, fonts, borders, and fills at the cell or column level

Key Features

  • Streaming writer keeps memory flat regardless of row count — tested with 1M+ rows
  • Full style support: fonts, fills, borders, alignment, number formats, and conditional formatting
  • Data validation rules (dropdowns, numeric ranges) embedded directly in cells
  • Auto-filter and freeze-pane support for user-friendly spreadsheets
  • Over 15,000 GitHub stars and 4 million weekly npm downloads

Comparison with Similar Tools

  • SheetJS (xlsx) — broader format support (XLS, ODS); ExcelJS offers richer styling and streaming writes
  • openpyxl (Python) — Python equivalent; ExcelJS is the Node.js counterpart with similar capabilities
  • Apache POI (Java) — enterprise-grade but JVM-only; ExcelJS runs anywhere Node.js does
  • csv-parser — CSV-only streaming reader; ExcelJS handles both XLSX and CSV in one library
  • json2csv — converts JSON to CSV; ExcelJS produces formatted Excel files with charts and styles

FAQ

Q: Can ExcelJS handle files with 100K+ rows? A: Yes. Use the streaming WorkbookWriter for writing and the streaming reader for parsing to maintain constant memory usage.

Q: Does it support Excel formulas? A: Yes. You can set formula strings on cells. Results are calculated by Excel when the file is opened, not by ExcelJS itself.

Q: Can I add images to spreadsheets? A: Yes. Use worksheet.addImage() with a buffer or file path. Supported formats include PNG, JPEG, and GIF.

Q: Is it compatible with LibreOffice and Google Sheets? A: The generated XLSX files conform to the Open XML standard and open correctly in LibreOffice Calc and Google Sheets.

Sources

Fil de discussion

Connectez-vous pour rejoindre la discussion.
Aucun commentaire pour l'instant. Soyez le premier à partager votre avis.

Actifs similaires