Skip to content

Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.

2.3 KB
Raw Blame

@univerjs/engine-formula

npm version license downloads

@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 Overview

Package UMD global CSS Locales Facade entry Worker entry
@univerjs/engine-formula UniverEngineFormula No Yes Yes Yes

Installation

pnpm add @univerjs/engine-formula
# or
npm install @univerjs/engine-formula

Usage

Start 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);

Worker usage

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 });

Integration Notes

  • Load the locale resources from @univerjs/engine-formula/locale/<language> for each language enabled by your application.
  • Import @univerjs/engine-formula/facade when using this package through Univer Facade APIs.
  • Custom calculation engines must await FormulaResultService before emitting completion. Subclasses of CalculateFormulaService must pass this service to the base constructor.

Resources