Skip to content
librazPublic

About

Excel 365 calculation engine in C++17: evaluate formulas and recalculate .xlsx / .xlsb workbooks without Excel. Ships as WASM (browser / Node), a Python package, and a native CLI.

Topics

Resources

Contributing

Security policy

Stars

11 stars

Watchers

0 watching

Forks

Repository files navigation

Formulon

CI npm PyPI codecov License C++17 Platform Docs

Formulon recalculates Excel workbooks and formulas without Excel, with results checked against real Excel 365. No Excel install, no Windows, no COM automation: one C++17 core ships as WebAssembly for browsers and Node, as a Python package, and as native CLI binaries, so a workbook gives the same values wherever it runs.

Use it when you need to:

  • Recalculate workbooks on a server — load .xlsx or .xlsb in a batch job, CI run or data pipeline, change inputs, and save it with fresh values.
  • Run spreadsheet logic in the browser — evaluate formulas and whole workbooks client-side, so uploaded files never leave the user's machine.
  • Keep the model in Excel — call the workbook your team already maintains from Node or Python instead of re-implementing its formulas.
  • Get the answer Excel gives in a given locale — Japanese byte counting, German decimal commas and localized TRUE / FALSE follow the Excel profile you pick.
  • Give AI agents spreadsheet tools — formulon-mcp exposes the engine over MCP.

Known differences from Excel are listed case by case in tests/divergence.yaml, each with a reason and the Excel build it was last verified on.

📖 Documentation  ·  Getting started  ·  Locale profiles  ·  Formula coverage  ·  API

What's inside

  • Formula engine — 527 Excel function names, 512 implemented locally; dynamic arrays, LET / LAMBDA, and REGEX*. The rest call cloud or COM services and return a fixed error. Coverage
  • Workbook I/O — read, recalculate and write .xlsx and .xlsb, including styles, conditional formatting, tables, pivot tables (refresh and grouping), charts, chartsheets, in-cell pictures, theme apply and save, and print layout; .xlsb carries pictures, charts and pivot tables too. A loaded workbook keeps its cached values where Excel would, and recalcFull() recomputes everything. A save of a workbook that holds something the target format cannot store fails with IoFeatureNotWritable and writes nothing. File formats
  • Locale profiles — 28 Excel behavior profiles across fourteen locales on Mac and Windows hosts. Locale profiles
  • Excel oracle — formula results are compared bit for bit against goldens captured from Mac Excel 365 in fourteen locales; pivot and print layout against Windows Excel 365. Oracle testing
  • Size-budgeted WASM — CI fails the build above 6 MiB uncompressed or 1920 KiB Brotli. Size budgets

Installation

npm install @libraz/formulon   # browsers and Node 22+
pip install formulon            # Python 3.10+

CLI binaries for darwin-arm64, linux-x64 and linux-arm64 are on GitHub Releases. Changes between releases are in the CHANGELOG; until 1.0 a minor release may break the API and a patch release does not.

Quick start

import createFormulon from '@libraz/formulon';

const formulon = await createFormulon();
console.log(formulon.evaluateFormula('=SUM(1,2,3)')); // 6
import formulon

print(formulon.evaluate_formula("=SUM(1,2,3)"))  # 6.0

Python returns numbers as float, because every Excel number is a double.

import createFormulon from '@libraz/formulon';

const formulon = await createFormulon();
const wb = formulon.Workbook.createDefault();
try {
  const ws = wb.sheet(0);
  ws.setValue('A1', 0.256);
  ws.updateCellFormat('A1', { numberFormat: '0.0%', font: { bold: true } });
  console.log(ws.getDisplayText('A1').text); // 25.6%
} finally {
  wb.dispose();
}
import formulon

with formulon.Workbook.create_default() as wb:
    ws = wb.sheet(0)
    ws["A1"] = 0.256
    ws.update_cell_format("A1", number_format="0.0%", font={"bold": True})
    print(ws.get_display_text("A1").text)  # 25.6%
formulon eval '=SUM(1,2,3)'
formulon recalc input.xlsx -o output.xlsx

Failures throw FormulonError in JavaScript and FormulonError subclasses in Python. A string that starts with = passed to setValue (JavaScript) or set_value / ws[...] = (Python) is entered as a formula; enter untrusted text with setText / set_text, which always stores text. Loading, editing and saving workbooks are covered in Recalculate a workbook.

Switching Excel profiles

New workbooks use win-365-en_US, the default Excel profile. Formulas are always written with English function names and the stored separators; the Excel profile decides how text is parsed and how results are rendered. =LENB("日本") gives 2 on mac-365-en_US and 4 on mac-365-ja_JP, and =ISEVEN(2) shows WAHR on mac-365-de_DE. Switch it per workbook and recalculate:

import createFormulon from '@libraz/formulon';

const formulon = await createFormulon();
const wb = formulon.Workbook.createDefault();
try {
  const ws = wb.sheet(0);
  ws.setFormula('A1', '=LENB("日本")');
  wb.setProfileId('mac-365-ja_JP'); // Python: set_profile_id
  wb.recalc(); // a profile change marks formulas dirty
  console.log(ws.getDisplayText('A1').text); // 4
} finally {
  wb.dispose();
}

The ids are {mac,win}-365-{ja_JP,en_US,de_DE,fr_FR,zh_CN,ko_KR,th_TH,es_ES,es_MX,pt_BR,ru_RU,zh_TW,it_IT,nl_NL}. Every mac-* profile and win-365-ja_JP is measured against Excel; the other win-* profiles are estimated from the Mac measurements. A win-* profile means Windows at 100% display scaling, which sets row heights and column widths. The profile is not saved into the file, so apply it again after loading. formulon.Workbook.createForProfile(id) also gives a new workbook the fonts, style names and sheet names Excel uses in that locale. See Locale profiles and Text comparison and sorting.

Non-goals

VBA execution, legacy .xls, chart rendering, Power Query / DAX, live external connections, and a spreadsheet UI are permanently out of scope. See Non-goals.

Contributing

Pull requests are welcome, including small and unfinished ones; the maintainer reviews, finishes and merges them. The most useful contribution needs no code: Excel oracle data from your locale, especially from Windows Excel 365. make oracle-contribute drives Excel and captures goldens. See CONTRIBUTING.md and Oracle contribution.

License

Apache License 2.0. See also NOTICE.

Related projects

About

Excel 365 calculation engine in C++17: evaluate formulas and recalculate .xlsx / .xlsb workbooks without Excel. Ships as WASM (browser / Node), a Python package, and a native CLI.

Topics

Resources

Contributing

Security policy

Stars

11 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages