Skip to content

About

Excel-like spreadsheet component for the browser, React and Vue: canvas grid, formula bar, ribbon and sheet tabs, calculated by the Formulon WASM engine.

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

formulon-cell

CI npm npm — react npm — vue codecov License TypeScript Docs Demo

formulon-cell is an Excel-like spreadsheet component for web apps, built to match desktop Excel. It mounts into a DOM node, a React component or a Vue component and renders a canvas grid with the formula bar, ribbon, sheet tabs, context menu and dialogs; formulas run in formulon, a C++ calc engine compiled to WebAssembly. Cell rendering, dialogs, keyboard shortcuts and clipboard behaviour are compared against the Excel desktop app one feature at a time, and corrected where they differ.

🧪 Live demo  ·  📖 Documentation  ·  Getting started

Beta, pre-1.0. The public API may still change between minor versions. Behaviour that has not been compared yet may differ from Excel; please report a divergence as an issue.

What's inside

  • Desktop spreadsheet chrome — formula bar, status bar, ribbon, sheet tabs, context menu and dialogs. Ribbon toolbar · Modals and dialogs
  • Desktop formula editing — F4 and arrow-key reference picking, Ctrl+arrow while pointing, undo inside the draft, F9 on a selection, R1C1 references.
  • Canvas grid with themes — styled through CSS tokens; paper, ink and contrast ship in the box. Theming
  • Charts — seven chart types with a settings panel, edited in place and saved back. Charts
  • XLSX persistence — comments, images, charts, tables, PivotTables, slicers, protection and more survive a save; Save As can write .xlsb, and offers .xlsx instead when the binary writer cannot carry a feature. Host integration
  • Restricted embedding — fixedFormPolicy(ranges) and viewerPolicy() limit what users may change on every input path, independently of which UI is shown. Embedding and use cases
  • UI profiles and extensions — ui.profile (embedded, minimal, standard, full), with any piece swappable or left out through extensions. Extensions
  • Mac profile — ui: { platform: 'mac' } switches to the Mac ribbon, shortcuts and argument palette. Platform and Mac UI
  • Runtime i18n — seven languages built in, strings overridable through instance.i18n.override(). Internationalization

Installation

npm install @libraz/formulon-cell
npm install @libraz/formulon-cell-react @libraz/formulon-cell react react-dom  # React 18+
npm install @libraz/formulon-cell-vue @libraz/formulon-cell vue                # Vue 3

The default engine is single-threaded and needs neither COOP/COEP headers nor SharedArrayBuffer. Workbook.createDefault() rejects if the engine fails to initialize; there is no silent fallback, and the in-memory stub engine runs only when you pass engine: 'stub'. Node.js integrations require Node 22 or later.

Bundler integration

The engine loads its WASM through an Emscripten wrapper, so the bundler has to leave it alone. For Vite:

// vite.config.ts
export default defineConfig({
  build: { target: 'es2022' }, // the engine factory uses top-level await
  optimizeDeps: { exclude: ['@libraz/formulon-cell', '@libraz/formulon'] },
});

Serving the .wasm from a CDN (locateFile) and the threaded engine build are covered in Bundler setup.

Quick start

JavaScript / TypeScript

import { mount, Workbook } from '@libraz/formulon-cell';
import { ribbon } from '@libraz/formulon-cell/toolbar';
import '@libraz/formulon-cell/styles.css';

const wb = await Workbook.createDefault();
const sheet = await mount(document.getElementById('sheet')!, {
  workbook: wb,
  ui: { profile: 'full', features: { localeSwitcher: true } },
  locale: 'en',
  toolbar: ribbon(),
});

sheet.update({ locale: 'ja' }); // swap locale without re-mounting
sheet.update({ theme: 'ink' }); // dark theme

→ Options

React

import { Spreadsheet } from '@libraz/formulon-cell-react';
import '@libraz/formulon-cell/styles.css';

<Spreadsheet ui={{ profile: 'full' }} locale="en" style={{ height: '100vh' }} />;

→ React / Vue

Vue

<script setup lang="ts">
import { Spreadsheet } from '@libraz/formulon-cell-vue';
import '@libraz/formulon-cell/styles.css';
</script>

<template>
  <Spreadsheet :ui="{ profile: 'full' }" locale="en" style="height: 100vh" />
</template>

→ React / Vue

Build from source

yarn install
yarn dev:react   # React demo (apps/react-demo)
yarn dev:vue     # Vue demo (apps/vue-demo)
yarn build       # libraries
yarn test        # core unit tests

The checks CI runs are listed in CONTRIBUTING.md; releases follow docs/releasing.md.

Embedding

Three independent options decide what an embedded sheet shows and what users may do with it, and each one can be changed later without re-mounting (update({ ui, policy, viewport })).

import { mount, Workbook, fixedFormPolicy, viewerPolicy } from '@libraz/formulon-cell';

const sheet = await mount(host, {
  workbook: await Workbook.createDefault(),
  ui: { profile: 'embedded', features: { formulaBar: true } }, // grid plus formula bar
  policy: fixedFormPolicy(['B2:B11']), // only B2:B11 accept input, on every sheet
  viewport: { mode: 'fixed', range: 'A1:D12', tabNavigation: 'editable' },
});

sheet.update({ policy: viewerPolicy() }); // after submit: select and copy only
  • ui — what is shown: a profile (embedded, minimal, standard, full) plus about thirty switches such as sheetTabs, contextMenu, charts or clipboard.
  • policy — what users may change: 27 operations (value edit, paste, format, row insert, sort, ...) allowed or denied one by one, editable cells as A1 ranges ('B2:B11' applies on every sheet, 'Input!B2:B11' on one) or a predicate, and a restrict hook that can deny but never grant. It applies to every input path, so hiding the ribbon is not what makes a cell readonly.
  • viewport — which cells are visible and selectable, and whether Tab walks only the editable cells.
  • contextMenu and overlays — pick or replace the right-click menu, and keep popups inside a host modal or fullscreen element.

Under a policy, ribbon commands that are not classified by operation stay disabled, so a restricted sheet is best shown without the ribbon or with host-built controls. See Embedding and use cases.

Documentation

The documentation lives at formulon.libraz.net/cell.

Non-goals

formulon-cell is the UI layer, not the calculation engine and not an application. Formula evaluation, recalculation and xlsx parsing belong to formulon. There is no server, persistence layer, collaboration transport or authentication; the host owns those. The React and Vue packages stay thin, with menus, commands and dialogs living in core so the three hosts cannot drift apart.

License

Apache-2.0

About

Excel-like spreadsheet component for the browser, React and Vue: canvas grid, formula bar, ribbon and sheet tabs, calculated by the Formulon WASM engine.

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages