# @ayocore/exceljs 中文文档

规范地址：https://npmcn.com/package/%40ayocore/exceljs/

版本：5\.0\.4
npm 元数据更新时间：2026-03-29T10:35:30.730Z
中文译文更新时间：2026-11-07T15:17:48.315Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40ayocore/exceljs
原文对照：https://npmcn.com/package/%40ayocore/exceljs/?lang=original
项目主页：https://github.com/ayocore/exceljs#readme
源码仓库：https://github.com/ayocore/exceljs

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：606 kB，178 个文件
- 模块格式：CommonJS
- TypeScript 类型：包内自带
- Node.js 要求：\>=22\.0\.0
- 运行依赖：6 个
- 首次发布：2026-03-28T11:59:00.973Z
- 最新版本发布：2026-03-29T10:35:30.591Z
- 近 30 天下载量：10048（2026-10-08 至 2026-11-06，npm 官方下载统计）
- 已发布版本数：5（近 12 个月 5 个）

## 中文简介

用于服务器侧XLSX生成的 EscelJS 的轻量级节点.js-只叉.

## 安装

```sh
npm install @ayocore/exceljs
```

也可以使用：`pnpm add @ayocore/exceljs`、`yarn add @ayocore/exceljs`、`bun add @ayocore/exceljs`

## README

# @ayocore/exceljs (英语)

轻量级节点.js-只叉 [特长](https://github.com/exceljs/exceljs) 用于服务器侧 XLSX 报告生成.

## 这是什么?

一个被剥去,安全加固的ExcelJS叉被优化后端使用. 在Node.js 20+上读取,操纵并写入XLSX电子表格.

## 上游的精英有什么变化?

### 删除

-   **浏览器支持** -- 没有浏览器捆绑, 没有多填装, 没有 UMD 包装
-   **CSV 支持** - 说吧 `workbook.csv` 完全删除( e)`fast-csv` 抚养关系消失)
-   **构建步骤** - 没有格伦特,没有巴别尔,没有浏览器,没有建筑,没有terser。 代码运行在 20+ 节点上
-   **`readable-stream` 多边填充** - 替换为本地 `require('stream')`
-   **`dayjs`** -- 未使用,已删除
-   **`core-js`, (中文(简体) ), `regenerator-runtime`** - 现代节点不需要.js

### 升级

-   **`archiver`** 5 -- > 7 -- -- 已删除 `glob@7` 财务报告和审定财务报表 `inflight` 从中转道岔
-   **`unzipper`** 0.10 - > 0.12 -- -- 已删除 `fstream` 财务报告和审定财务报表 `rimraf@2` 从中转道岔
-   **流线读取器修正** -- 固定共享字符串种族条件, 当工作表条目在zip中共享字符串到达之前( 补发 # 1328)

### 警卫

| 度量衡 | 上游优势 4.4.0 | @ayocore/exceljs 5.0.2 (中文(简体) ) |
| --- | --- | --- |
| `npm audit` 共计 | 第48条 | 3(只保留mocha) |
| 关键 | 3个 | 0 个 |
| 高级 | 29个 | 2 (只保留) |
| 运行时间 vulns | 1个 | 0 个 |

### 更轻

| 度量衡 | 上游优势 4.4.0 | @ayocore/exceljs 5.0.2 (中文(简体) ) |
| --- | --- | --- |
| 运行时间依赖关系 | 第9条 | 6个 |
| 软件包大小 | ~2.5 甲基溴 | ~1 MB 键 |
| 节点-模块树 | 1320个包裹 | ~600 个包 |

### 运行时间依赖关系

`archiver`, (中文(简体) ), `jszip`, (中文(简体) ), `saxes`, (中文(简体) ), `tmp`, (中文(简体) ), `unzipper`, (中文(简体) ), `uuid`

## 所需资源

-   **节点.js 20**
-   仅限服务器侧. 不供浏览器使用 .

## 安装

```shell
npm install @ayocore/exceljs
```

## 快开始

```js
const ExcelJS = require('@ayocore/exceljs');

// Create a workbook
const wb = new ExcelJS.Workbook();
wb.creator = 'My Server';

// Add a worksheet
const ws = wb.addWorksheet('Report');

ws.columns = [
  {header: 'ID', key: 'id', width: 8},
  {header: 'Name', key: 'name', width: 25},
  {header: 'Amount', key: 'amount', width: 15},
];

ws.getRow(1).font = {bold: true};

ws.addRow({id: 1, name: 'Item A', amount: 100});
ws.addRow({id: 2, name: 'Item B', amount: 250});

ws.getColumn('amount').numFmt = '$#,##0.00';

// Write to file
await wb.xlsx.writeFile('/tmp/report.xlsx');

// Or write to buffer
const buffer = await wb.xlsx.writeBuffer();
```

## 流线

```js
const ExcelJS = require('@ayocore/exceljs');

// Streaming writer (low memory)
const wb = new ExcelJS.stream.xlsx.WorkbookWriter({
  filename: '/tmp/large-report.xlsx',
});

const ws = wb.addWorksheet('Data');
ws.columns = [{header: 'Row', key: 'row'}];

for (let i = 0; i < 1_000_000; i++) {
  ws.addRow({row: i}).commit();
}

ws.commit();
await wb.commit();
```

## API 密码

API 和 [特长](https://github.com/exceljs/exceljs) 但下列情况除外:

-   `workbook.csv` -- 删除( 需要时使用专用 CSV 库)
-   浏览器特性 -- -- 删除
-   ES5/dist 建筑 -- -- 已拆除

API文件全文见 [上游文档](https://github.com/exceljs/exceljs#contents)。 。 。 .

## 端口上游修正

此分叉包括来自原始 open PR 的错误修正和改进 [特长](https://github.com/exceljs/exceljs) 上游尚未合并的仓库.

### 错误修正

| 公关 | 说明 | 作者 |
| --- | --- | --- |
| [2915号](https://github.com/exceljs/exceljs/pull/2915) | 修正工作簿阅读器种族条件——单元格值读取为共享结构索引而不是实际值 | [@ 阿内查斯](https://github.com/AnechaS) |
| [2807号](https://github.com/exceljs/exceljs/pull/2807) | 修复页面设置 Pr/outlinePr 命令在工作表Pr 中——破损的 xlsx 输出 | [@strelok372 (英语)](https://github.com/strelok372) |
| [2851号](https://github.com/exceljs/exceljs/pull/2851) | 修补布尔属性解析 - `<strike val="0"/>` 被读作真实 | [@Jason33汪](https://github.com/Jason33Wang) |
| [#2803 (英语)](https://github.com/exceljs/exceljs/pull/2803) | 在溪流刻录器中将有条件格式化和超链接合并时修复已损坏的文件 | [@ TheAsda (英语)](https://github.com/TheAsda) |
| [2956号](https://github.com/exceljs/exceljs/pull/2956) | 固定日期 Toexcel () 返回非数字值的 NaN | [@ davepuchyr (英语)](https://github.com/davepuchyr) |
| [2737号](https://github.com/exceljs/exceljs/pull/2737) | 不要渲染出空的丰富文本下字符串——Excel无法打开文件 | [@ 布莱克霍尔3](https://github.com/Blackhol3) |
| [#2781号](https://github.com/exceljs/exceljs/pull/2781) | 修复单元格样式变异——在一个单元格上设置样式不再腐蚀其他共享样式对象 | [@gmahomarf (英语)](https://github.com/gmahomarf) |
| [#2973号](https://github.com/exceljs/exceljs/pull/2973) | 用动态Filter节点解析 Excel 表格时修复崩溃 | [@johnyushika (英语)](https://github.com/johnnyoshika) |
| [2996号](https://github.com/exceljs/exceljs/pull/2996) | 将 XML 特殊字符和空值固定在关键表格中 | [@ protobi-pieter (原始内容存档于2019-09-21) (英语)](https://github.com/protobi-pieter) |
| [2962号](https://github.com/exceljs/exceljs/pull/2962) | 处理缺失 `r` 属性在行/单元格元素中——改善与非标准Excel生成器的兼容性 | [@迪卢卡](https://github.com/Diluka) |
| [2920号](https://github.com/exceljs/exceljs/pull/2920) | 优化合并单元格重叠检查 — O( N) 扫描替换为每个单元格 isMerged检查 | [@ 3ximus (中文(简体) )](https://github.com/3ximus) |
| [2894号](https://github.com/exceljs/exceljs/pull/2894) | 修复 SAX 解析器, 突破块边界的多字节 UTF-8 字符( 中文、 emoji等) | [@maoxian-1 (英语)](https://github.com/maoxian-1) |
| [2874号](https://github.com/exceljs/exceljs/pull/2874) | 修补种族条件和溪流循环中的内存泄漏 | [@StevenGee3398 (英语)](https://github.com/StevenGee3398) |

### 改进

| 公关 | 说明 | 作者 |
| --- | --- | --- |
| [2867号](https://github.com/exceljs/exceljs/pull/2867) | 样式缓存模式( E)`FAST_MAP`, (中文(简体) ), `JSON_MAP`()——最多3x写作性能与 `useStyles` | [@brunoargolo (英语)](https://github.com/brunoargolo) |
| [2998号](https://github.com/exceljs/exceljs/pull/2998) | 修补 `getTable().addRow()` 用于从文件装入的表格 — refs, autoFilter, 和工作表绑定 | [@ protobi-pieter (原始内容存档于2019-09-21) (英语)](https://github.com/protobi-pieter) |
| [2995号](https://github.com/exceljs/exceljs/pull/2995) | 支持每个工作簿+固定的多条支点表 `.splice()` 数据突变错误 | [@ protobi-pieter (原始内容存档于2019-09-21) (英语)](https://github.com/protobi-pieter) |

感谢所有原作者对卓越生态系统的贡献.

## 许可证

麻省理工学院 -- -- 原作 [盖翁·罗什](https://github.com/guyonroche) 财务报告和审定财务报表 [杰出贡献者](https://github.com/exceljs/exceljs/graphs/contributors)。 。 。 .

## 常见问题

### @ayocore/exceljs 是什么？

用于服务器侧XLSX生成的 EscelJS 的轻量级节点\.js-只叉\.

### 如何安装 @ayocore/exceljs？

在项目目录运行 npm install @ayocore/exceljs，或使用 pnpm add / yarn add / bun add。

### @ayocore/exceljs 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @ayocore/exceljs 支持 ESM 还是 CommonJS？

以 CommonJS 形式发布，可以直接 require\(\)；在 ES Module 项目中也可以用 import 引入（Node\.js 会把 module\.exports 作为默认导出）。

### @ayocore/exceljs 需要什么版本的 Node\.js？

package\.json 的 engines 字段要求 Node\.js \>=22\.0\.0。版本不符时 npm 默认只给出警告，开启 engine-strict 后会拒绝安装。

### @ayocore/exceljs 可以商用吗？

@ayocore/exceljs 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @ayocore/exceljs 的下载量有多少？

根据 npm 官方下载统计，@ayocore/exceljs 在 2026/10/08 – 2026/11/06 这 30 天内被下载 10,048 次，日均约 335 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @ayocore/exceljs 还在维护吗？

最新版本 5\.0\.4 发布于 2026/03/29（7 个月前）；至今共发布 5 个版本，其中过去 12 个月发布了 5 个；首次发布于 2026/03/28。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

