# office-viewer

> office 文档在线预览

Latest version **0.3.17** (published 2026-06-17) · Apache 2.0 license · 0 weekly downloads

## Install

```sh
npm install office-viewer
pnpm add office-viewer
yarn add office-viewer
bun add office-viewer
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads; large bundle; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.3.17 |
| Published | 2026-06-17 |
| First published | 2023-03-22 |
| Weekly downloads | 0 |
| License | Apache 2.0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 3 |
| Unpacked size | 10.8 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | nwind, fis-dev |
| Keywords | office, word, excel, docx, xlsx |

## Links

- npm: https://www.npmjs.com/package/office-viewer
- Repository: https://github.com/baidu/amis-inner
- Homepage: https://github.com/baidu/amis#readme
- Issues: https://github.com/baidu/amis/issues
- npm.io page: https://npm.io/package/office-viewer

## Dependencies (3)

- [tslib](https://npm.io/package/tslib.md) ^2.3.1
- [numfmt](https://npm.io/package/numfmt.md) ^2.5.2
- [papaparse](https://npm.io/package/papaparse.md) ^5.4.1

## Recent versions

- 0.3.17 (latest) — 2026-06-17
- 0.3.16 — 2026-06-15
- 0.3.15 — 2026-05-11
- 0.3.14 — 2024-05-23
- 0.3.13 — 2024-05-09
- 0.3.12 — 2024-05-07
- 0.3.11 — 2024-04-18
- 0.3.10 — 2024-04-10
- 0.3.9 — 2024-04-03
- 0.3.8 — 2024-03-22
- 0.3.7 — 2024-03-22
- 0.3.6 — 2024-03-21
- 0.3.5 — 2024-03-19
- 0.3.4 — 2024-03-19
- 0.3.2 — 2024-03-19
- … 8 more at https://npm.io/package/office-viewer/versions

## README

# 说明

Word 和 Excel 渲染器，目前接口还未完全稳定，新版可能会修改，请参考 examples

## Word 渲染

### 原理

Word 渲染器，原理是将 docx 里的 xml 格式转成 html

相对于 Canvas 渲染，这个实现方案比较简单，最终页面也可以很方便复制，但无法保证和原始 docx 文件展现一致，因为有部分功能难以在 HTML 中实现，比如图文环绕效果。

### 已知不支持的功能

- 艺术字
- 域
- 对象
- wmf，需要使用 https://github.com/SheetJS/js-wmf

### 参考资料

- [官方规范](https://www.ecma-international.org/publications-and-standards/standards/ecma-376/)
- [标签的在线文档](http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/index.html)

日常开发可以使用 [OOXML viewer](https://marketplace.visualstudio.com/items?itemName=yuenm18.ooxml-viewer) 插件查看

开发过程啊参考了

- [docx](https://github.com/dolanmiu/docx) 的类型定义
- [docxjs](https://github.com/zVolodymyr/docxjs) 里格式的实现

## Excel 渲染

### 原理

使用 Canvas 渲染

---
_Source: https://npm.io/package/office-viewer · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
