@bilig/xlsx-formula-recalc
v0.40.42
Published
Scoped XLSX formula recalculation package for Node.js without Excel, LibreOffice, or browser automation.
Maintainers
Readme
@bilig/xlsx-formula-recalc
Scoped XLSX formula recalculation package for Node.js without Excel, LibreOffice, or browser automation.
This package is the canonical scoped Bilig entrypoint for the high-friction Node XLSX workflow:
- import an XLSX workbook,
- edit input cells,
- recalculate formulas,
- read proof values,
- export an updated XLSX.
It fits xlsx-populate, SheetJS / xlsx, template-generation, and backend file
pipelines where the file writer can edit the workbook but the Node service also
needs fresh formula readback before returning.
The unscoped xlsx-formula-recalc package remains published as a compatibility
and search alias.
If You Arrived From SheetJS or xlsx-populate
xlsx, SheetJS-style workbook objects, and xlsx-populate are good at file
I/O. They can read workbook bytes, write cells, preserve formulas, and export
an .xlsx artifact.
They do not make stale cached formula values fresh inside your Node process. That is the failure behind issues and searches like:
xlsx-populate formula calculated valueSheetJS formula result not updatingxlsx formula recalculation Node.jsget computed value from xlsx formula cell
Use this package at the file boundary:
- let your existing library produce XLSX bytes;
- call
recalculateXlsx(...); - read the proof cells from
result.reads; - write
result.xlsxif the recalculated workbook artifact is needed.
That keeps your current file-writer choice intact and adds only the missing calculation/readback step.
Install
npm install @bilig/xlsx-formula-recalcCLI
Run a self-contained proof first:
npx --package @bilig/xlsx-formula-recalc xlsx-recalc --demo --jsonThat command creates a tiny workbook, changes Inputs!B2 and Inputs!B3,
recalculates Summary!B2, writes bilig-formula-recalc-demo.xlsx, and prints
verified: true with the recalculated value.
For an existing workbook:
npx --package @bilig/xlsx-formula-recalc xlsx-recalc pricing.xlsx \
--set Inputs!B2=48 \
--set Inputs!B3=1500 \
--read Summary!B7 \
--out pricing.recalculated.xlsx \
--jsonThe CLI writes a recalculated workbook and prints readback values. Cell targets
must be sheet-qualified A1 references such as Inputs!B2 or
'Pricing Model'!F12.
API
import { recalculateXlsx } from '@bilig/xlsx-formula-recalc'
const result = recalculateXlsx(await fs.promises.readFile('pricing.xlsx'), {
edits: [
{ target: 'Inputs!B2', value: 48 },
{ target: 'Inputs!B3', value: 1500 },
],
reads: ['Summary!B7'],
})
await fs.promises.writeFile('pricing.recalculated.xlsx', result.xlsx)
console.log(result.reads['Summary!B7'])If another library already produced the workbook bytes, pass those bytes directly:
const output = await workbook.outputAsync('nodebuffer') // for example, from xlsx-populate
const result = recalculateXlsx(output, {
reads: ['Summary!B7'],
})For the full workbook API, import WorkPaper, importXlsx, and exportXlsx
from @bilig/workpaper.
Common Boundaries
| Existing tool | Keep using it for | Add this package when |
| ----------------------------------- | ------------------------------------------------------ | ------------------------------------------------ |
| xlsx-populate | template editing and workbook generation | formula cells need fresh cached values in Node |
| SheetJS / xlsx | broad XLSX parsing, writing, and file interchange | edited inputs must update dependent formulas now |
| ExcelJS | styled reports, sheets, tables, and ExcelJS workbooks | use @bilig/exceljs-formula-recalc |
| Excel, LibreOffice, Microsoft Graph | exact spreadsheet application behavior | you cannot depend on an external app or API call |
| @bilig/workpaper | service-owned formula workbook state with JSON storage | the workbook does not have to stay XLSX-first |
Scope
Use this when a Node service needs deterministic formula readback after it
changes XLSX inputs. It is not a full Excel clone: unsupported Excel functions,
external workbook links, macros, and volatile functions may need review. Import
warnings are returned in result.warnings.
Full docs: https://proompteng.github.io/bilig/xlsx-formula-recalculation-node.html
