@bilig/exceljs-formula-recalc 0.38.2 → 0.38.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +116 -2
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -2,16 +2,130 @@
2
2
 
3
3
  Scoped ExcelJS formula recalculation package for Node.js without Excel, LibreOffice, or browser automation.
4
4
 
5
+ ExcelJS can read and write formula cells, but it does not run an
6
+ Excel-compatible calculation engine for you after backend code edits inputs.
7
+ This package bridges that gap: serialize the ExcelJS workbook, run the Bilig
8
+ WorkPaper recalculation path, optionally load the recalculated XLSX back into
9
+ the same ExcelJS workbook, and read proof values.
10
+
11
+ The unscoped `exceljs-formula-recalc` package remains published as a
12
+ compatibility and search alias.
13
+
14
+ ## If You Arrived From an ExcelJS Formula Issue
15
+
16
+ This package is for the recurring ExcelJS boundary behind issues and searches
17
+ like:
18
+
19
+ - `ExcelJS formula result not updating`
20
+ - `Formula based cell not updating`
21
+ - `Updating Formula Result`
22
+ - `Automatic formula calculation`
23
+ - `get computed value of Excel sheet cell in Node.js`
24
+
25
+ The important distinction is:
26
+
27
+ - `workbook.calcProperties.fullCalcOnLoad = true` asks Excel or LibreOffice to
28
+ recalculate later, when the file is opened.
29
+ - `@bilig/exceljs-formula-recalc` recalculates before your Node process returns,
30
+ then patches requested ExcelJS formula cells with fresh `result` values.
31
+
32
+ Use ExcelJS for workbook I/O and presentation. Use this package only for the
33
+ calculation/readback boundary that ExcelJS intentionally does not own.
34
+
35
+ ## Install
36
+
37
+ ```sh
38
+ npm install @bilig/exceljs-formula-recalc
39
+ ```
40
+
41
+ If you do not already have ExcelJS in the project:
42
+
5
43
  ```sh
6
44
  npm install exceljs @bilig/exceljs-formula-recalc
45
+ ```
46
+
47
+ ## CLI
48
+
49
+ If your ExcelJS workflow has already written an `.xlsx` file, the package also
50
+ ships an ExcelJS-named CLI for quick proof runs:
51
+
52
+ ```sh
7
53
  npx --package @bilig/exceljs-formula-recalc exceljs-recalc --demo --json
8
54
  ```
9
55
 
56
+ For a real workbook saved by ExcelJS:
57
+
58
+ ```sh
59
+ npx --package @bilig/exceljs-formula-recalc exceljs-recalc quote.xlsx \
60
+ --set Inputs!B2=48 \
61
+ --set Inputs!B3=1500 \
62
+ --read Summary!B7 \
63
+ --out quote.recalculated.xlsx \
64
+ --json
65
+ ```
66
+
67
+ Use the API below when backend code needs the recalculated values patched back
68
+ onto the in-memory ExcelJS workbook object.
69
+
70
+ ## Use With ExcelJS
71
+
10
72
  ```ts
73
+ import ExcelJS from 'exceljs'
11
74
  import { recalculateExceljsWorkbook } from '@bilig/exceljs-formula-recalc'
75
+
76
+ const workbook = new ExcelJS.Workbook()
77
+ await workbook.xlsx.readFile('quote.xlsx')
78
+
79
+ const result = await recalculateExceljsWorkbook(workbook, {
80
+ edits: [
81
+ { target: 'Inputs!B2', value: 48 },
82
+ { target: 'Inputs!B3', value: 1500 },
83
+ ],
84
+ reads: ['Summary!B7'],
85
+ })
86
+
87
+ console.log(result.reads['Summary!B7'])
88
+ await workbook.xlsx.writeFile('quote.recalculated.xlsx')
12
89
  ```
13
90
 
14
- The unscoped `exceljs-formula-recalc` package remains published as a compatibility
15
- and search alias.
91
+ By default, `recalculateExceljsWorkbook` mutates the provided ExcelJS workbook
92
+ by loading the recalculated XLSX bytes back into it. For targets listed in
93
+ `reads`, it also patches the ExcelJS formula cell object with the recalculated
94
+ `result`, so backend code can inspect proof values without reopening the file.
95
+ Pass `mutateWorkbook: false` if you only need the returned `xlsx` bytes.
96
+
97
+ ## Common Boundaries
98
+
99
+ | Job | Use |
100
+ | --------------------------------------------------------------- | ------------------------------- |
101
+ | Create styled XLSX reports, worksheets, tables, images, or rows | ExcelJS |
102
+ | Ask Excel to recalculate after a human opens the file | ExcelJS `fullCalcOnLoad` |
103
+ | Read recalculated formula values before an API/job returns | `@bilig/exceljs-formula-recalc` |
104
+ | Recalculate raw XLSX bytes from SheetJS or xlsx-populate | `@bilig/xlsx-formula-recalc` |
105
+ | Keep formula-backed business state as JSON, not XLSX | `@bilig/workpaper` |
106
+
107
+ ## API
108
+
109
+ ```ts
110
+ import { recalculateExceljsBuffer, recalculateExceljsWorkbook } from '@bilig/exceljs-formula-recalc'
111
+ ```
112
+
113
+ `recalculateExceljsWorkbook(workbook, options)` accepts any workbook-like object
114
+ with `workbook.xlsx.writeBuffer()` and `workbook.xlsx.load(...)`, which matches
115
+ ExcelJS workbooks.
116
+
117
+ `recalculateExceljsBuffer(input, options)` accepts XLSX bytes and returns the
118
+ same result shape as `@bilig/xlsx-formula-recalc`.
119
+
120
+ Cell targets must be sheet-qualified A1 references such as `Inputs!B2` or
121
+ `'Pricing Model'!F12`.
122
+
123
+ ## Scope
124
+
125
+ Use this when a Node service already uses ExcelJS for workbook I/O but needs
126
+ deterministic formula readback after changing inputs. It is not a full Excel
127
+ clone: unsupported Excel functions, external workbook links, macros, and
128
+ volatile functions may need review. Import warnings are returned in
129
+ `result.warnings`.
16
130
 
17
131
  Full docs: <https://proompteng.github.io/bilig/exceljs-formula-recalculation-node.html>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bilig/exceljs-formula-recalc",
3
- "version": "0.38.2",
3
+ "version": "0.38.3",
4
4
  "description": "Scoped ExcelJS formula recalculation package for Node.js without Excel, LibreOffice, or browser automation.",
5
5
  "keywords": [
6
6
  "bilig",
@@ -52,8 +52,8 @@
52
52
  "build": "pnpm --dir ../.. --filter @bilig/xlsx-formula-recalc build && pnpm --dir ../.. --filter exceljs-formula-recalc build && rm -rf dist tsconfig.tsbuildinfo && tsc -p tsconfig.json"
53
53
  },
54
54
  "dependencies": {
55
- "@bilig/xlsx-formula-recalc": "0.38.2",
56
- "exceljs-formula-recalc": "0.38.2"
55
+ "@bilig/xlsx-formula-recalc": "0.38.3",
56
+ "exceljs-formula-recalc": "0.38.3"
57
57
  },
58
58
  "devDependencies": {
59
59
  "exceljs": "4.4.0"