@bilig/xlsx-formula-recalc 0.38.1 → 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 +111 -2
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -2,16 +2,125 @@
2
2
 
3
3
  Scoped XLSX formula recalculation package for Node.js without Excel, LibreOffice, or browser automation.
4
4
 
5
+ This package is the canonical scoped Bilig entrypoint for the high-friction Node
6
+ XLSX workflow:
7
+
8
+ 1. import an XLSX workbook,
9
+ 2. edit input cells,
10
+ 3. recalculate formulas,
11
+ 4. read proof values,
12
+ 5. export an updated XLSX.
13
+
14
+ It fits `xlsx-populate`, SheetJS / `xlsx`, template-generation, and backend file
15
+ pipelines where the file writer can edit the workbook but the Node service also
16
+ needs fresh formula readback before returning.
17
+
18
+ The unscoped `xlsx-formula-recalc` package remains published as a compatibility
19
+ and search alias.
20
+
21
+ ## If You Arrived From SheetJS or xlsx-populate
22
+
23
+ `xlsx`, SheetJS-style workbook objects, and `xlsx-populate` are good at file
24
+ I/O. They can read workbook bytes, write cells, preserve formulas, and export
25
+ an `.xlsx` artifact.
26
+
27
+ They do not make stale cached formula values fresh inside your Node process.
28
+ That is the failure behind issues and searches like:
29
+
30
+ - `xlsx-populate formula calculated value`
31
+ - `SheetJS formula result not updating`
32
+ - `xlsx formula recalculation Node.js`
33
+ - `get computed value from xlsx formula cell`
34
+
35
+ Use this package at the file boundary:
36
+
37
+ 1. let your existing library produce XLSX bytes;
38
+ 2. call `recalculateXlsx(...)`;
39
+ 3. read the proof cells from `result.reads`;
40
+ 4. write `result.xlsx` if the recalculated workbook artifact is needed.
41
+
42
+ That keeps your current file-writer choice intact and adds only the missing
43
+ calculation/readback step.
44
+
45
+ ## Install
46
+
5
47
  ```sh
6
48
  npm install @bilig/xlsx-formula-recalc
49
+ ```
50
+
51
+ ## CLI
52
+
53
+ Run a self-contained proof first:
54
+
55
+ ```sh
7
56
  npx --package @bilig/xlsx-formula-recalc xlsx-recalc --demo --json
8
57
  ```
9
58
 
59
+ That command creates a tiny workbook, changes `Inputs!B2` and `Inputs!B3`,
60
+ recalculates `Summary!B2`, writes `bilig-formula-recalc-demo.xlsx`, and prints
61
+ `verified: true` with the recalculated value.
62
+
63
+ For an existing workbook:
64
+
65
+ ```sh
66
+ npx --package @bilig/xlsx-formula-recalc xlsx-recalc pricing.xlsx \
67
+ --set Inputs!B2=48 \
68
+ --set Inputs!B3=1500 \
69
+ --read Summary!B7 \
70
+ --out pricing.recalculated.xlsx \
71
+ --json
72
+ ```
73
+
74
+ The CLI writes a recalculated workbook and prints readback values. Cell targets
75
+ must be sheet-qualified A1 references such as `Inputs!B2` or
76
+ `'Pricing Model'!F12`.
77
+
78
+ ## API
79
+
10
80
  ```ts
11
81
  import { recalculateXlsx } from '@bilig/xlsx-formula-recalc'
82
+
83
+ const result = recalculateXlsx(await fs.promises.readFile('pricing.xlsx'), {
84
+ edits: [
85
+ { target: 'Inputs!B2', value: 48 },
86
+ { target: 'Inputs!B3', value: 1500 },
87
+ ],
88
+ reads: ['Summary!B7'],
89
+ })
90
+
91
+ await fs.promises.writeFile('pricing.recalculated.xlsx', result.xlsx)
92
+ console.log(result.reads['Summary!B7'])
12
93
  ```
13
94
 
14
- The unscoped `xlsx-formula-recalc` package remains published as a compatibility
15
- and search alias.
95
+ If another library already produced the workbook bytes, pass those bytes
96
+ directly:
97
+
98
+ ```ts
99
+ const output = await workbook.outputAsync('nodebuffer') // for example, from xlsx-populate
100
+
101
+ const result = recalculateXlsx(output, {
102
+ reads: ['Summary!B7'],
103
+ })
104
+ ```
105
+
106
+ For the full workbook API, import `WorkPaper`, `importXlsx`, and `exportXlsx`
107
+ from `@bilig/workpaper`.
108
+
109
+ ## Common Boundaries
110
+
111
+ | Existing tool | Keep using it for | Add this package when |
112
+ | ----------------------------------- | ------------------------------------------------------ | ------------------------------------------------ |
113
+ | `xlsx-populate` | template editing and workbook generation | formula cells need fresh cached values in Node |
114
+ | SheetJS / `xlsx` | broad XLSX parsing, writing, and file interchange | edited inputs must update dependent formulas now |
115
+ | ExcelJS | styled reports, sheets, tables, and ExcelJS workbooks | use `@bilig/exceljs-formula-recalc` |
116
+ | Excel, LibreOffice, Microsoft Graph | exact spreadsheet application behavior | you cannot depend on an external app or API call |
117
+ | `@bilig/workpaper` | service-owned formula workbook state with JSON storage | the workbook does not have to stay XLSX-first |
118
+
119
+ ## Scope
120
+
121
+ Use this when a Node service needs deterministic formula readback after it
122
+ changes XLSX inputs. It is not a full Excel clone: unsupported Excel functions,
123
+ external workbook links, macros, and volatile functions may need review. Import
124
+ warnings are returned in `result.warnings`.
16
125
 
17
126
  Full docs: <https://proompteng.github.io/bilig/xlsx-formula-recalculation-node.html>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bilig/xlsx-formula-recalc",
3
- "version": "0.38.1",
3
+ "version": "0.38.3",
4
4
  "description": "Scoped XLSX formula recalculation package for Node.js without Excel, LibreOffice, or browser automation.",
5
5
  "keywords": [
6
6
  "bilig",
@@ -61,7 +61,7 @@
61
61
  "smoke": "node ./dist/cli.js --help"
62
62
  },
63
63
  "dependencies": {
64
- "xlsx-formula-recalc": "0.38.1"
64
+ "xlsx-formula-recalc": "0.38.3"
65
65
  },
66
66
  "engines": {
67
67
  "node": ">=22.0.0"