npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@christophervr/xlsx-react-viewer

v2.2.0

Published

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

Downloads

4,871

Readme

@christophervr/xlsx-react-viewer

The Excel spreadsheet editor as a React component: open, edit, calculate and save .xlsx, .xlsm, .xltx, legacy .xls and .csv files in the browser.

npm version license types

Live demo · Documentation · React guide · Changelog · Report a bug

The Excel editor in use: selecting a range, inserting a column chart, adding a SUM formula and changing values while the chart and the total update

Install

npm install @christophervr/xlsx-react-viewer react
  • Peer dependency: react >=18.
  • Bundled: the <xlsx-editor> web component and the React adapter. Installed with it: @christophervr/xlsx-core (the workbook model, re-exported from this package), ooxml-core and ooxml-ui.
  • Use one Excel editor package per application: each registers the same <xlsx-editor> element.

Quick start

import { useRef } from 'react';
import { SpreadsheetEditor, type EditorHandle } from '@christophervr/xlsx-react-viewer';

export function Budget() {
	const editor = useRef<EditorHandle>(null);
	return (
		<>
			<button onClick={() => void editor.current?.download('Budget.xlsx')}>Download</button>
			<SpreadsheetEditor
				ref={editor}
				src="/files/budget.xlsx"
				fileName="Budget.xlsx"
				className="sheet"
				onDirtyChange={(dirty) => console.log('unsaved edits:', dirty)}
			/>
		</>
	);
}

Give the host a height in your CSS (for example .sheet { height: 80vh }): the editor fills the <div> that className styles and scrolls inside it. There is no stylesheet to import: the element carries its own styles. Without src, bytes or workbook the editor starts with a blank workbook.

Props

| Prop | What it does | | -------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | workbook, bytes, src, fileName | What to show: a workbook model, file bytes or a URL, and the name used by the title bar, Save and Download (default Book1.xlsx). | | readOnly | Opens in Viewing mode (default false). | | locale | Interface language (see Localisation). | | theme, themeColors | light, dark or auto (default), and --xve-* token overrides (see Theming). | | showToolbar, showFormulaBar | Show or hide the ribbon and the formula bar (both default true). | | hiddenActions, ribbonAddIns | Hide ribbon commands by stable id, or add your own tabs after Excel's. | | customization | Capabilities, hidden ribbon tabs (File included), extra File pages and context-menu commands. | | storage, fileProviders | Send File > Save and Open to your own storage, and add OneDrive or your own cloud places to File > Open. | | collaboration | Join a shared room while set; null leaves it. | | imageProvider | Opt in to IMAGE formulas with your own fetcher (without one they show #BLOCKED!). | | googleFonts | Turn font downloads off (false) or point them at Google Fonts or your mirror ({ baseUrl }); unset leaves it to the reader (off by default). | | fonts | Font files you supply ({ family, data, bold?, italic? }, FontFace or { family, src }), used for layout, drawing and printing before the workbook is first shown. Keep the array stable. | | authorName, validateReplace | The author of new comments (default Author), and whether Replace applies data validation (default false). | | className | Class of the host <div> the editor fills. |

Props are forwarded only when their value changes, so a re-render never undoes what the user changed inside the editor (Editing or Viewing, theme, language, Customize Ribbon). Keep customization, fileProviders and ribbonAddIns stable between renders.

The ref is the editor handle. The handle has load(bytes, fileName?), newWorkbook(), save(), saveBytes('xlsx' | 'csv'), download(fileName?), markClean(), openCloudFile(file), select(ref), getSelection(), setActiveSheet(index), share(), and the dirty and element properties. A method called before the editor has mounted throws Editor is not mounted.

Full reference: framework bindings and the element API.

Events

| Callback | Receives | | ----------------------- | ----------------------------------------------------------------------------------------------------------------------- | | onWorkbookChange | The edited Workbook. | | onDirtyChange | true while there are unsaved edits. | | onWorkbookError | An Error when a file or a src fetch fails to open. | | onFileCommand | The cancelable file-command event: call event.preventDefault() to run New, Open, Save, Print and the rest yourself. | | onSelectionChange | { sheet, ref, active }. | | onSheetChange | { index, name } of the new active sheet. | | onReadOnlyChange | (readOnly, { readOnly, locked, hostReadOnly }); a controlled parent stores hostReadOnly. | | onWorkbookWarning | The loader's notes about content it could not read. | | onRibbonAction | { id } of a command that ran. | | onRibbonCustomize | The new hidden-action list after Customize Ribbon. | | onRibbonAddIn | { tab, command } of a host tab command. | | onCollaborationChange | The sharing state. | | onReady | The <xlsx-editor> element, once mounted. |

See callbacks and events.

Open and save files

The editor opens .xlsx, .xlsm (macros never run), .xltx, password-protected workbooks, legacy .xls and .csv; .xls and .csv are saved as .xlsx. save() resolves to an .xlsx Blob and does not clear dirty: call markClean() once you have stored it, or use download(), which does both. saveBytes('csv') exports the active sheet. The model API (createWorkbook, loadWorkbook, saveWorkbook, detectWorkbookFormat and the rest of @christophervr/xlsx-core) is re-exported here, so headless work needs no second install. The component renders only its host <div> on the server and mounts in an effect, so it is safe in server-rendered apps.

Theming

theme picks light, dark or auto, and themeColors sets --xve-* tokens on the editor (for example { primary: '#1f9d63', radius: '6px' }). The chrome also follows the shared --office-* tokens and a data-office-theme attribute on any ancestor; install them once with installOfficeUiTheme() from ooxml-ui/theme. Theme changes never alter workbook colours. See theming.

Localisation

The interface is available in English (en, the default, built in), French (fr), German (de), Spanish (es) and Simplified Chinese (zh-CN), set with locale. A tag that maps to one (de-DE, zh-Hans) works; any other falls back to English. Other languages load on demand. Workbook content and function names are never translated. See localization.

Status and limits

Excel is Stable under the stability policy: a frozen API under semver, a preservation guarantee and native Excel save and reopen checks. It does not match Microsoft Excel feature for feature.

  • .xlsb and .ods do not open.
  • Macros never run (a .xlsm keeps its VBA project). External links, data connections and Power Query are kept with their cached values and never refreshed.
  • PivotTables from external or OLAP sources and advanced pivot filters are kept but not editable; the sparkline style gallery is missing.
  • Ink is drawn, erased and saved as Excel ink from the Draw tab, with the Ruler, and shared in a shared workbook (Ink to Math needs a handwriting recognizer the host supplies with setInkMathRecognizer; none is built in). Older OLE objects show as placeholders; form controls cannot be moved or resized, and buttons run no macro.
  • In a shared room, pictures, ink, other drawings, page setup and PivotTables are not shared.

See features and limitations and the parity checklist.

Privacy and network use

Workbooks open, calculate, render, edit and save on the device. Nothing is uploaded, and nothing collects analytics or telemetry.

  • Same-origin assets. Workers, the selected non-English language, and chart, PivotTable, picture and shape tool code load on demand from your app's origin, carrying only the asset URL. Keep locale at en to skip language requests.
  • Fonts. Off by default. Fonts the device lacks are downloaded from fonts.googleapis.com and fonts.gstatic.com only when the reader turns on File > Options > Trust Center "Download fonts that are not installed or embedded", or the host sets the googleFonts prop: false turns downloads off and locks the toggle, { baseUrl } points at Google Fonts or your own mirror. Only public font family names are sent. Font files you pass in the fonts prop are registered on the page and fetched only when an entry is a URL you name; they are removed when the editor is removed.
  • Linked content. Linked pictures are not fetched, external links and linked data are not refreshed, and WEBSERVICE is not evaluated. IMAGE formulas fetch only through an imageProvider you pass.
  • Destinations you choose. src fetches the URL you pass; sharing (collaboration, or a server URL the reader types in File > Share) talks only to that server, and without one connects tabs of the same browser only; OneDrive and other fileProviders only when you add them. Hyperlinks and the Forms link open only when the reader follows them.
  • On the device. Small preferences, such as the font-download choice (ooxml.xlsx.allowFontDownloads), stay in localStorage.

See PRIVACY.md.

Browser support

The last two major versions of Chrome, Edge, Firefox and Safari, and Safari 16.4 at least (browser support). React 18 or newer. Node.js 22.3 or newer for builds, tests and server rendering. A slow calculation on open runs in a module worker from your origin, so a Content Security Policy must allow worker-src 'self'; without workers it runs on the page under the same time limit.

Documentation and demos

License

Apache-2.0. See NOTICE for attributions.