@univer-community/sheets-formula-display
v0.22.0
Published
A plugin for toggling formula display in Univer Sheets.
Downloads
64
Readme
@univer-community/sheets-formula-display
A plugin for toggling formula display in Univer Sheets.
- Extends
FWorkbook - Adds a
Show Formulasribbon menu action for Sheets UI - Toggles formula rendering without mutating persisted workbook data
Installation
pnpm add @univer-community/sheets-formula-displayUsage
Register the plugin
import { UniverSheetsFormulaDisplayPlugin } from "@univer-community/sheets-formula-display";
univer.registerPlugin(UniverSheetsFormulaDisplayPlugin);Create the facade API:
import { FUniver } from "@univerjs/core/facade";
import "@univerjs/sheets/facade";
const univerAPI = FUniver.newAPI(univer);Facade API Methods
FWorkbook
const workbook = univerAPI.getActiveWorkbook();
workbook?.setFormulaDisplay(true);
const visible = workbook?.getFormulaDisplay();
workbook?.toggleFormulaDisplay();Menu
The plugin mounts a Show Formulas button in the Sheets UI Formulas ribbon.
When enabled, formula cells render their formula text. Toggling it again restores the computed results.
The toggle state is tracked per workbook.
API Notes
- Formula display state is tracked per workbook
- Toggling affects rendering only; underlying formula cell data stays unchanged
- Saving the workbook still persists the original formula/result data, not the temporary display text
- This package depends on Sheets UI to show the ribbon menu; without UI, the
FWorkbookfacade API still works
Local Development
Install dependencies:
pnpm installRun lint:
pnpm lintRun tests:
pnpm testRun type checking:
pnpm typecheckBuild the library:
pnpm buildBuild the demo:
pnpm build:demoStart the demo:
pnpm devBuild Output
Running pnpm build generates:
lib/es: ESM outputlib/cjs: CommonJS outputlib/es/localeandlib/cjs/locale: locale entry outputlib/types: TypeScript declaration files
Demo
The demo/ directory shows a complete formula display flow:
- Initialize a Univer Sheets app with the required Sheets, UI, and formula plugins
- Register
UniverSheetsFormulaDisplayPlugin - Fill sample cells with formulas
- Toggle formula display through the ribbon menu or the
FWorkbookfacade API
License
MIT
