@nazarkalytiuk/rusc-xlsx 1.0.4 → 1.0.5
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 +23 -6
- package/index.d.ts +1 -1
- package/package.json +8 -8
- package/wrapper.d.ts +20 -0
- package/wrapper.js +19 -0
package/README.md
CHANGED
|
@@ -116,6 +116,8 @@ const worksheet = workbook.addWorksheetWithConstantMemory('Large');
|
|
|
116
116
|
- **Memory**: Constant ~0.02 MB (regardless of size!)
|
|
117
117
|
- **Limitations**: Sequential row writing only, no tables
|
|
118
118
|
|
|
119
|
+
> **Important:** For large exports, use `addWorksheetWithConstantMemory()` with `save(filename)` — not `saveToBuffer()`. The constant memory mode flushes rows to temp files as they're written, but `saveToBuffer()` would load the entire result back into memory, defeating the purpose. Use `saveToStream()` if you need to pipe the output without disk I/O overhead.
|
|
120
|
+
|
|
119
121
|
**Example: 1 million rows**
|
|
120
122
|
```javascript
|
|
121
123
|
const workbook = new Workbook();
|
|
@@ -126,7 +128,7 @@ for (let row = 0; row < 1000000; row++) {
|
|
|
126
128
|
worksheet.write(row, 1, row * 100);
|
|
127
129
|
}
|
|
128
130
|
|
|
129
|
-
workbook.save('large.xlsx');
|
|
131
|
+
workbook.save('large.xlsx'); // Use save(), not saveToBuffer()
|
|
130
132
|
```
|
|
131
133
|
|
|
132
134
|
### Low Memory Mode
|
|
@@ -213,11 +215,26 @@ workbook.save('output.xlsx');
|
|
|
213
215
|
|
|
214
216
|
See the `examples/` directory for complete examples:
|
|
215
217
|
- `basic.js` - Simple workbook creation
|
|
216
|
-
- `formatting.js` - Cell formatting
|
|
217
|
-
- `
|
|
218
|
-
- `
|
|
219
|
-
- `
|
|
220
|
-
- `
|
|
218
|
+
- `formatting.js` - Cell formatting and number formats
|
|
219
|
+
- `data-types.js` - All supported data types
|
|
220
|
+
- `datetime.js` - Date/time writing methods and formats
|
|
221
|
+
- `multiple-sheets.js` - Working with multiple worksheets
|
|
222
|
+
- `advanced-styling.js` - Fonts, borders, patterns, fills
|
|
223
|
+
- `advanced-features.js` - Formulas, data validation, hyperlinks, freeze panes
|
|
224
|
+
- `charts.js` - Column, line, pie, bar, and scatter charts
|
|
225
|
+
- `tables.js` - Excel tables with totals, formulas, and styles
|
|
226
|
+
- `images.js` - Inserting images from buffers with scaling and links
|
|
227
|
+
- `sparklines.js` - Line, column, and win/lose sparklines
|
|
228
|
+
- `rich-text.js` - Multi-format text within cells
|
|
229
|
+
- `notes.js` - Cell comments with custom styling
|
|
230
|
+
- `conditional-formatting-and-page-setup.js` - Conditional formatting and print setup
|
|
231
|
+
- `protection.js` - Worksheet protection with granular permissions
|
|
232
|
+
- `doc-properties.js` - Document metadata (author, title, etc.)
|
|
233
|
+
- `constant-memory.js` - Large datasets with constant memory mode
|
|
234
|
+
- `low-memory.js` - Large datasets with low memory mode
|
|
235
|
+
- `save-to-buffer.js` - Saving to Buffer for HTTP responses
|
|
236
|
+
- `typescript-example.ts` - Full TypeScript usage
|
|
237
|
+
- `type-safety-demo.ts` - TypeScript type safety features
|
|
221
238
|
|
|
222
239
|
## Building from Source
|
|
223
240
|
|
package/index.d.ts
CHANGED
|
@@ -380,7 +380,7 @@ export declare class RuscTableColumn {
|
|
|
380
380
|
/** Set the header name for the column */
|
|
381
381
|
setHeader(header: string): this
|
|
382
382
|
/** Set the total function for the column */
|
|
383
|
-
setTotalFunction(
|
|
383
|
+
setTotalFunction(func: string): this
|
|
384
384
|
/** Set a custom total label for the column */
|
|
385
385
|
setTotalLabel(label: string): this
|
|
386
386
|
/** Set a custom formula for the column */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nazarkalytiuk/rusc-xlsx",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "Fast Excel XLSX library for Node.js powered by rust_xlsxwriter",
|
|
5
5
|
"main": "wrapper.js",
|
|
6
6
|
"types": "wrapper.d.ts",
|
|
@@ -69,12 +69,12 @@
|
|
|
69
69
|
"node": ">=16"
|
|
70
70
|
},
|
|
71
71
|
"optionalDependencies": {
|
|
72
|
-
"@nazarkalytiuk/rusc-xlsx-win32-x64-msvc": "1.0.
|
|
73
|
-
"@nazarkalytiuk/rusc-xlsx-win32-ia32-msvc": "1.0.
|
|
74
|
-
"@nazarkalytiuk/rusc-xlsx-win32-arm64-msvc": "1.0.
|
|
75
|
-
"@nazarkalytiuk/rusc-xlsx-darwin-universal": "1.0.
|
|
76
|
-
"@nazarkalytiuk/rusc-xlsx-linux-x64-gnu": "1.0.
|
|
77
|
-
"@nazarkalytiuk/rusc-xlsx-linux-arm64-gnu": "1.0.
|
|
78
|
-
"@nazarkalytiuk/rusc-xlsx-linux-x64-musl": "1.0.
|
|
72
|
+
"@nazarkalytiuk/rusc-xlsx-win32-x64-msvc": "1.0.5",
|
|
73
|
+
"@nazarkalytiuk/rusc-xlsx-win32-ia32-msvc": "1.0.5",
|
|
74
|
+
"@nazarkalytiuk/rusc-xlsx-win32-arm64-msvc": "1.0.5",
|
|
75
|
+
"@nazarkalytiuk/rusc-xlsx-darwin-universal": "1.0.5",
|
|
76
|
+
"@nazarkalytiuk/rusc-xlsx-linux-x64-gnu": "1.0.5",
|
|
77
|
+
"@nazarkalytiuk/rusc-xlsx-linux-arm64-gnu": "1.0.5",
|
|
78
|
+
"@nazarkalytiuk/rusc-xlsx-linux-x64-musl": "1.0.5"
|
|
79
79
|
}
|
|
80
80
|
}
|
package/wrapper.d.ts
CHANGED
|
@@ -2242,6 +2242,26 @@ export declare class Workbook {
|
|
|
2242
2242
|
*/
|
|
2243
2243
|
saveToBuffer(): Buffer;
|
|
2244
2244
|
|
|
2245
|
+
/**
|
|
2246
|
+
* Save the workbook to a Writable stream
|
|
2247
|
+
*
|
|
2248
|
+
* Streams XLSX data directly to the writable without buffering the entire
|
|
2249
|
+
* file in memory. Combines the speed of `saveToBuffer()` with the low
|
|
2250
|
+
* memory footprint of `save(filename)`.
|
|
2251
|
+
*
|
|
2252
|
+
* @param writable - A Node.js Writable stream (e.g., fs.createWriteStream, HTTP response)
|
|
2253
|
+
* @example
|
|
2254
|
+
* const fs = require('fs');
|
|
2255
|
+
* const stream = fs.createWriteStream('output.xlsx');
|
|
2256
|
+
* workbook.saveToStream(stream);
|
|
2257
|
+
*
|
|
2258
|
+
* @example
|
|
2259
|
+
* // HTTP response
|
|
2260
|
+
* res.setHeader('Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
|
|
2261
|
+
* workbook.saveToStream(res);
|
|
2262
|
+
*/
|
|
2263
|
+
saveToStream(writable: import('stream').Writable): void;
|
|
2264
|
+
|
|
2245
2265
|
/**
|
|
2246
2266
|
* Define a named range or formula
|
|
2247
2267
|
* @param name - Name for the range (e.g., 'Sales' or 'Sheet1!Sales' for local names)
|
package/wrapper.js
CHANGED
|
@@ -1263,6 +1263,25 @@ class Workbook {
|
|
|
1263
1263
|
return this._native.saveToBuffer()
|
|
1264
1264
|
}
|
|
1265
1265
|
|
|
1266
|
+
saveToStream(writable) {
|
|
1267
|
+
const os = require('os')
|
|
1268
|
+
const path = require('path')
|
|
1269
|
+
const fs = require('fs')
|
|
1270
|
+
const crypto = require('crypto')
|
|
1271
|
+
|
|
1272
|
+
const tmpFile = path.join(os.tmpdir(), `rusc-xlsx-${crypto.randomBytes(8).toString('hex')}.xlsx`)
|
|
1273
|
+
this._native.save(tmpFile)
|
|
1274
|
+
|
|
1275
|
+
const readable = fs.createReadStream(tmpFile)
|
|
1276
|
+
readable.on('end', () => {
|
|
1277
|
+
fs.unlink(tmpFile, () => {})
|
|
1278
|
+
})
|
|
1279
|
+
readable.on('error', () => {
|
|
1280
|
+
fs.unlink(tmpFile, () => {})
|
|
1281
|
+
})
|
|
1282
|
+
readable.pipe(writable)
|
|
1283
|
+
}
|
|
1284
|
+
|
|
1266
1285
|
defineName(name, formula) {
|
|
1267
1286
|
return this._native.defineName(name, formula)
|
|
1268
1287
|
}
|