@christophervr/xlsx-react-viewer

中文文档
1.4.1发布于 2026/11/07Apache-2.0TypeScriptES Module构建来源已验证近 30 天下载 2443

React component for the Excel spreadsheet editor. Self-contained: includes the editor, the formula engine and the legacy .xls reader.

原始使用文档
文档目录10 节
  1. Install
  2. Quick start
  3. Features
  4. API
  5. Building blocks
  6. Limitations
  7. Documentation
  8. Privacy and network use
  9. License
  10. OneDrive integration

@christophervr/xlsx-react-viewer

npm version license types

A browser Excel spreadsheet editor for React, using one shared editor and the canonical OOXML document engine.

Live demo | npm | Full docs | Source

Part of ooxml: Office · Word · Excel · PowerPoint · Visio · OpenTeams · Core

Install

npm install @christophervr/xlsx-react-viewer

Use the framework peers declared by this package: react (>=18). Existing framework apps normally already provide them.

The package bundles its editor UI and adapter. The core model and shared controls are installed as regular registry dependencies and the model API is re-exported. One viewer package is enough; no separate core install is required.

Quick start

import { useState } from 'react';
import { createWorkbook, SpreadsheetEditor } from '@christophervr/xlsx-react-viewer';

export function Editor() {
    const [workbook, setWorkbook] = useState(() => createWorkbook());
    return <SpreadsheetEditor workbook={workbook} onWorkbookChange={setWorkbook} />;
}

Mount in the browser and give the host a height. Use one editor package per application: each registers the same editor custom element.

Features

FeatureDescription
EditingShared grid, ribbon, formula bar, sheet tabs and workbook change events.
FilesXLSX, XLSM, XLTX, legacy XLS and CSV loading through core.
ModelcreateWorkbook, loadWorkbook, saveXlsx and core types from the package entry.
FrameworksThe same <xlsx-editor> UI behind six thin adapters.

API

Shared option types, loadWorkbook and detectWorkbookFormat helpers are exported from the package. Framework handles expose load, save and download. The vanilla package supplies mountEditor(container, options) for framework-free lifecycle management. ooxml-core and ooxml-ui are regular dependencies. Parsing, formulas, editing and grid calculations live in core.

Building blocks

To build your own UI around the grid, use useViewerBuildingBlocks with SpreadsheetCanvas and the optional Toolbar, FormulaBar and SheetTabs. The hook returns canvasProps, toolbarProps (state, enabled flags and callbacks for formatting, undo, redo, formula entry and sheet navigation), loading, error, mode, dirty, selection, collaboration and editError, and takes host callbacks such as onOpenShareDialog and onValidationError. The surface is read-only until you pass canEdit: true. No title bar, ribbon, backstage or dialog is mounted. See the building blocks guide.

Limitations

This is an early editor, without Microsoft Excel parity or guaranteed lossless saving for unsupported features. Legacy XLS input saves as XLSX. Pivot tables, slicers and sparklines are not editable; macros never execute. Review core diagnostics and the feature guide before relying on preservation.

Documentation

Framework guide | Bindings

Privacy and network use

The Excel packages make no network request when opening, rendering, editing or saving a document: linked pictures are not fetched, linked data is not refreshed, and fonts come from the device only (nothing is downloaded from Google Fonts or any other font service). Hyperlinks open only when the reader follows them. Nothing collects analytics or telemetry. See PRIVACY.md.

License

Apache-2.0.

OneDrive integration

Use the optional shared ooxml-core/embedding/onedrive connection with host-supplied Microsoft sign-in. See the Office package and integration reference for this product's load/save API, native storage wiring, sharing permissions and conflict recovery. The testing guide separates test-local transports from live Microsoft acceptance. No simulation service is shipped; OneDrive storage does not provide Microsoft Office coauthoring or automatic document merging.

版本与发布记录

@christophervr/xlsx-react-viewer 共发布 25 个版本,首次发布于 2026/10/02;过去 12 个月发布了 25 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.4.1latest2026/11/072 天前
1.4.02026/11/054 天前
1.3.02026/11/045 天前
1.2.22026/10/2911 天前
1.2.12026/10/2317 天前
1.2.02026/10/2218 天前

关于 @christophervr/xlsx-react-viewer 的常见问题

@christophervr/xlsx-react-viewer 是什么?

React component for the Excel spreadsheet editor. Self-contained: includes the editor, the formula engine and the legacy .xls reader.

如何安装 @christophervr/xlsx-react-viewer?

在项目目录运行 npm install @christophervr/xlsx-react-viewer,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(>=18)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@christophervr/xlsx-react-viewer 支持 TypeScript 吗?

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

@christophervr/xlsx-react-viewer 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@christophervr/xlsx-react-viewer 可以商用吗?

@christophervr/xlsx-react-viewer 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@christophervr/xlsx-react-viewer 的下载量有多少?

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

@christophervr/xlsx-react-viewer 还在维护吗?

最新版本 1.4.1 发布于 2026/11/07(2 天前);至今共发布 25 个版本,其中过去 12 个月发布了 25 个;首次发布于 2026/10/02。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。