@univerjs/engine-formula is Univer's formula runtime. It parses formulas, registers functions and descriptions, manages dependencies, calculates results, and exposes shared formula editor helpers.
| Package | UMD global | CSS | Locales | Facade entry | Worker entry |
|---|---|---|---|---|---|
@univerjs/engine-formula |
UniverEngineFormula |
No | Yes | Yes | Yes |
pnpm add @univerjs/engine-formula
# or
npm install @univerjs/engine-formulaStart with the integration setup for your document type, including its required plugins, styles, and locale resources. The snippet below assumes that setup is complete.
import { UniverFormulaEnginePlugin } from '@univerjs/engine-formula';
univer.registerPlugin(UniverFormulaEnginePlugin);On the main thread, import UniverFormulaEnginePlugin from @univerjs/engine-formula. Set notExecuteFormula: true to delegate calculation to the worker.
In the worker entry, import UniverFormulaEnginePlugin from @univerjs/engine-formula/worker:
import { UniverFormulaEnginePlugin } from '@univerjs/engine-formula/worker';
univer.registerPlugin(UniverFormulaEnginePlugin, { notExecuteFormula: false });- Load the locale resources from
@univerjs/engine-formula/locale/<language>for each language enabled by your application. - Import
@univerjs/engine-formula/facadewhen using this package through Univer Facade APIs. - Custom calculation engines must await
FormulaResultServicebefore emitting completion. Subclasses ofCalculateFormulaServicemust pass this service to the base constructor.