@office-open/xlsx 0.12.2 → 0.12.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.
- package/README.md +45 -8
- package/package.json +6 -4
package/README.md
CHANGED
|
@@ -63,9 +63,32 @@ const buffer = await generateWorkbook({
|
|
|
63
63
|
writeFileSync("workbook.xlsx", buffer);
|
|
64
64
|
```
|
|
65
65
|
|
|
66
|
+
## API
|
|
67
|
+
|
|
68
|
+
- `generateWorkbook(options)` — generate a `.xlsx` file; `generateWorkbookSync` and `generateWorkbookStream` cover sync and streaming output
|
|
69
|
+
- `parseWorkbook(bytes)` — read a `.xlsx` back into `WorkbookOptions`
|
|
70
|
+
- `patchWorkbook(input)` — patch an existing `.xlsx` template by placeholder replacement
|
|
71
|
+
|
|
72
|
+
Every input is a plain JSON object (`WorkbookOptions` and its option types). The full typed API reference lives in the [documentation](https://www.office-open.com/en/xlsx/); the same types are also frozen as JSON Schemas — `npx office-open schema slice xlsx WorkbookOptions`.
|
|
73
|
+
|
|
74
|
+
## Parsing
|
|
75
|
+
|
|
76
|
+
Read existing `.xlsx` files and re-create them as `WorkbookOptions`:
|
|
77
|
+
|
|
78
|
+
```typescript
|
|
79
|
+
import { parseWorkbook, generateWorkbook } from "@office-open/xlsx";
|
|
80
|
+
import { readFileSync, writeFileSync } from "node:fs";
|
|
81
|
+
|
|
82
|
+
const opts = parseWorkbook(new Uint8Array(readFileSync("input.xlsx")));
|
|
83
|
+
|
|
84
|
+
// Modify parsed data, then re-generate
|
|
85
|
+
const buffer = await generateWorkbook(opts);
|
|
86
|
+
writeFileSync("output.xlsx", buffer);
|
|
87
|
+
```
|
|
88
|
+
|
|
66
89
|
## Examples
|
|
67
90
|
|
|
68
|
-
Check the [demo folder](
|
|
91
|
+
Check the [demo folder](https://github.com/DemoMacro/office-open/tree/main/packages/xlsx/demo) for working examples covering every feature.
|
|
69
92
|
|
|
70
93
|
## Benchmark
|
|
71
94
|
|
|
@@ -86,22 +109,22 @@ generateWorkbookStream(options);
|
|
|
86
109
|
|
|
87
110
|
| Scenario | Runtime | Default sync | Default async | All STORE sync | All STORE async | Default stream | hucre |
|
|
88
111
|
| ---------------- | ------- | ------------ | ------------- | -------------- | --------------- | -------------- | ----------- |
|
|
89
|
-
| Simple (3 rows) | Node 24 | 1,992 ops/s | 1,821 ops/s | 16,644 ops/s | 18,069 ops/s |
|
|
112
|
+
| Simple (3 rows) | Node 24 | 1,992 ops/s | 1,821 ops/s | 16,644 ops/s | 18,069 ops/s | 781 ops/s | 826 ops/s |
|
|
90
113
|
| | Bun 1.4 | 9,862 ops/s | 993 ops/s | 32,644 ops/s | 31,071 ops/s | 1,005 ops/s | 1,128 ops/s |
|
|
91
|
-
| Styled rows (20) | Node 24 | 1,819 ops/s | 1,859 ops/s | 16,499 ops/s | 13,662 ops/s |
|
|
114
|
+
| Styled rows (20) | Node 24 | 1,819 ops/s | 1,859 ops/s | 16,499 ops/s | 13,662 ops/s | 834 ops/s | 842 ops/s |
|
|
92
115
|
| | Bun 1.4 | 9,072 ops/s | 916 ops/s | 23,892 ops/s | 22,729 ops/s | 1,092 ops/s | 835 ops/s |
|
|
93
|
-
| Table (10x5) | Node 24 | 1,812 ops/s | 2,084 ops/s | 16,471 ops/s | 13,092 ops/s |
|
|
116
|
+
| Table (10x5) | Node 24 | 1,812 ops/s | 2,084 ops/s | 16,471 ops/s | 13,092 ops/s | 842 ops/s | 766 ops/s |
|
|
94
117
|
| | Bun 1.4 | 8,891 ops/s | 935 ops/s | 23,550 ops/s | 21,559 ops/s | 1,164 ops/s | 806 ops/s |
|
|
95
118
|
|
|
96
119
|
**Large Files — Create + toBuffer / toStream**
|
|
97
120
|
|
|
98
121
|
| Scenario | Runtime | Default sync | Default async | All STORE sync | All STORE async | Default stream | hucre |
|
|
99
122
|
| ----------------------------- | ------- | ------------ | ------------- | -------------- | --------------- | -------------- | ---------- |
|
|
100
|
-
| 2000 rows + 10 images | Node 24 | 117 ops/s | 116 ops/s | 142 ops/s | 139 ops/s |
|
|
123
|
+
| 2000 rows + 10 images | Node 24 | 117 ops/s | 116 ops/s | 142 ops/s | 139 ops/s | 125 ops/s | 41.4 ops/s |
|
|
101
124
|
| | Bun 1.4 | 213 ops/s | 192 ops/s | 260 ops/s | 243 ops/s | 50.1 ops/s | 44.0 ops/s |
|
|
102
|
-
| 200x10 table | Node 24 | 838 ops/s | 985 ops/s | 1,374 ops/s | 1,129 ops/s |
|
|
125
|
+
| 200x10 table | Node 24 | 838 ops/s | 985 ops/s | 1,374 ops/s | 1,129 ops/s | 470 ops/s | 263 ops/s |
|
|
103
126
|
| | Bun 1.4 | 1,157 ops/s | 609 ops/s | 1,636 ops/s | 1,549 ops/s | 373 ops/s | 270 ops/s |
|
|
104
|
-
| 20 sheets × 100 rows + 20 img | Node 24 | 73.3 ops/s | 70.0 ops/s | 97.5 ops/s | 97.1 ops/s |
|
|
127
|
+
| 20 sheets × 100 rows + 20 img | Node 24 | 73.3 ops/s | 70.0 ops/s | 97.5 ops/s | 97.1 ops/s | 72.7 ops/s | 23.5 ops/s |
|
|
105
128
|
| | Bun 1.4 | 158 ops/s | 74.0 ops/s | 160 ops/s | 166 ops/s | 28.2 ops/s | 24.3 ops/s |
|
|
106
129
|
|
|
107
130
|
**Large Data — 100,000 rows × 20 columns (2M cells)**
|
|
@@ -113,6 +136,20 @@ generateWorkbookStream(options);
|
|
|
113
136
|
|
|
114
137
|
**Stream** = `generateWorkbookStream` (default compression, fully drained). Plain-data workbooks stream through a constant-memory path — at 1M rows × 3 cols, peak RSS is +177 MB streamed vs +810 MB buffered. Scenarios with images fall back to the full-memory stream.
|
|
115
138
|
|
|
139
|
+
## Documentation
|
|
140
|
+
|
|
141
|
+
- [Documentation](https://www.office-open.com/en/xlsx/) — guides, API reference, and examples
|
|
142
|
+
- [Changelog](https://github.com/DemoMacro/office-open/releases) — release notes
|
|
143
|
+
- [Report Issues](https://github.com/DemoMacro/office-open/issues) — bug reports and feature requests
|
|
144
|
+
|
|
145
|
+
## Related Packages
|
|
146
|
+
|
|
147
|
+
- [office-open](https://www.npmjs.com/package/office-open) — all formats + CLI + AI SDK tools in one install
|
|
148
|
+
- [@office-open/docx](https://www.npmjs.com/package/@office-open/docx) — Word (.docx)
|
|
149
|
+
- [@office-open/pptx](https://www.npmjs.com/package/@office-open/pptx) — PowerPoint (.pptx)
|
|
150
|
+
- [@office-open/core](https://www.npmjs.com/package/@office-open/core) — shared OOXML infrastructure
|
|
151
|
+
- [@office-open/xml](https://www.npmjs.com/package/@office-open/xml) — XML parsing and serialization
|
|
152
|
+
|
|
116
153
|
## License
|
|
117
154
|
|
|
118
|
-
- [MIT](LICENSE) © [Demo Macro](https://www.demomacro.com/)
|
|
155
|
+
- [MIT](https://github.com/DemoMacro/office-open/blob/main/LICENSE) © [Demo Macro](https://www.demomacro.com/)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@office-open/xlsx",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.3",
|
|
4
4
|
"description": "AI-native Excel (.xlsx) generation, parsing, and patching from plain JSON — fully typed TypeScript, 100% OOXML coverage, no Microsoft Office required",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
"generate",
|
|
10
10
|
"json",
|
|
11
11
|
"llm",
|
|
12
|
+
"microsoft-excel",
|
|
12
13
|
"office",
|
|
13
14
|
"office-open",
|
|
14
15
|
"ooxml",
|
|
@@ -32,7 +33,8 @@
|
|
|
32
33
|
},
|
|
33
34
|
"repository": {
|
|
34
35
|
"type": "git",
|
|
35
|
-
"url": "git+https://github.com/DemoMacro/office-open.git"
|
|
36
|
+
"url": "git+https://github.com/DemoMacro/office-open.git",
|
|
37
|
+
"directory": "packages/xlsx"
|
|
36
38
|
},
|
|
37
39
|
"files": [
|
|
38
40
|
"dist"
|
|
@@ -48,8 +50,8 @@
|
|
|
48
50
|
}
|
|
49
51
|
},
|
|
50
52
|
"dependencies": {
|
|
51
|
-
"@office-open/
|
|
52
|
-
"@office-open/
|
|
53
|
+
"@office-open/xml": "0.12.3",
|
|
54
|
+
"@office-open/core": "0.12.3"
|
|
53
55
|
},
|
|
54
56
|
"scripts": {
|
|
55
57
|
"dev": "basis build --stub",
|