Skills2026年5月16日·1 分钟阅读

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.

Agent 就绪

Agent 可直接安装

这个资产可安装;Agent 先选择当前运行时、检查安装计划,再运行匹配命令。

Native · 98/100策略:允许
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
ExcelJS Overview
直接安装命令
npx -y tokrepo@latest install cc9ce2fb-50fe-11f1-9bc6-00163e2b0d79 --target codex

先 dry-run 确认安装计划,再运行此命令。

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

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产