8sheets
v1.6.0
Published
Excel-compatible spreadsheet for the web: open, edit and save xlsx files in the browser, or build and calculate workbooks in Node. Canvas grid, 500+ functions, charts, PivotTables.
Maintainers
Readme
8sheets
An Excel-compatible spreadsheet for the web, in plain JavaScript modules with no runtime dependencies. Open, edit and save .xlsx and CSV files in the browser, or create, calculate and save workbooks in Node with no page at all. It has a canvas grid, 500+ Excel functions, charts (filled maps included), PivotTables, tables, conditional formatting, printing to PDF and a full ribbon interface.
This package is published as both @8sheets/core and 8sheets, with the same contents. Components for React, Vue and Angular build on @8sheets/core.
Install
npm i @8sheets/coreUse in a page
import { mountWorkbook } from '@8sheets/core';
mountWorkbook(document.querySelector('#sheet'), { chrome: 'light' }).then((wb) => {
wb.activeSheet.range('A1').values = [['Item', 'Qty'], ['Pens', 4]];
});The element needs a height. mountWorkbook brings its own stylesheet, scoped to the element, and loads the grid, the ribbon and the panels on demand.
Use in Node
import { writeFile } from 'node:fs/promises';
import { createWorkbook } from '@8sheets/core';
const wb = createWorkbook();
wb.activeSheet.range('A1:B2').values = [['Item', 'Qty'], ['Pens', 4]];
wb.activeSheet.range('B3').formulas = [['=B2*2']];
await wb.whenCalculated();
const chunks = [];
await wb.saveXlsx({ write: async (bytes) => chunks.push(bytes.slice()) });
await writeFile('book.xlsx', Buffer.concat(chunks));Bundlers
8sheets finds its Workers, icons, dictionaries and map data next to its own modules, with new URL('./…', import.meta.url) and literal paths, so Vite, webpack and Next.js (Turbopack or webpack) copy them into your build. The Workers are ES modules.
- Vite: set
worker: { format: 'es' }. Before Vite 8, don'tawaitmountWorkbookat the top level of your entry module: Rollup bundles 8sheets' modules into the entry's chunk, the parts loaded on demand wait for it, and the page waits forever. Call it inside a function or with.then, or load 8sheets withawait import('@8sheets/core'). Before Vite 8, also keep 8sheets out of the dev server's dependency pre-bundling withoptimizeDeps: { exclude: ['@8sheets/core'] }: the older pre-bundling moves the modules away from their Workers, so files can't be opened or saved invitedev. Vite 8 needs no such setting. - Angular CLI: see @8sheets/angular, which serves this package as static files.
- No bundler: serve the package folder and import
api/index.jsfrom it.
The files that are only fetched when a feature needs them are the bulk of the package: map data for filled map charts (about 4.8 MB), spelling dictionaries (about 1.1 MB), the thesaurus (about 3.8 MB) and the icon set (about 0.5 MB). A page that never uses them never downloads them.
TypeScript
The declarations ship with the package, so import { createWorkbook } from '@8sheets/core' is typed with no setting. They name DOM types such as HTMLElement, because the same API mounts in a page, so a Node project that checks library types (skipLibCheck: false) needs "DOM" in lib.
Documentation
- For developers: what the API offers.
- API reference: every class, option, event and command. TypeScript declarations ship with the package.
- React, Vue and Angular.
- Changelog.
Licence
8sheets is commercial software, not open source. You may install it and try it for free, to evaluate it. Using it in a product, or deploying it for your users or your own staff, needs a licence from 8sheets.com/pricing: Internal 999 USD or SaaS / OEM 2,999 USD, each paid once per company and covering every developer and every deployment, or Enterprise, quoted. There is no licence key and nothing in the package checks for one. The terms are in LICENSE.md and, once you hold a licence, the 8sheets Source Licence.
This package includes data under its own licences (icons, map data, dictionaries, thesauri): see the notice files next to that data and Third-party notices.
