@xlvane/compat 0.0.0-stage → 1.0.1

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/LICENSE ADDED
@@ -0,0 +1,46 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 DevXord
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
6
+ associated documentation files (the "Software"), to deal in the Software without restriction, including
7
+ without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the
9
+ following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all copies or substantial
12
+ portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
15
+ LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
16
+ EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
18
+ USE OR OTHER DEALINGS IN THE SOFTWARE.
19
+
20
+ ---
21
+
22
+ The API and the type declarations of this package follow those of exceljs 4.4.0
23
+ (https://github.com/exceljs/exceljs), which is distributed under the following license:
24
+
25
+ The MIT License (MIT)
26
+
27
+ Copyright (c) 2014-2019 Guyon Roche
28
+
29
+ Permission is hereby granted, free of charge, to any person obtaining a copy
30
+ of this software and associated documentation files (the "Software"), to deal
31
+ in the Software without restriction, including without limitation the rights
32
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
33
+ copies of the Software, and to permit persons to whom the Software is
34
+ furnished to do so, subject to the following conditions:
35
+
36
+ The above copyright notice and this permission notice shall be included in all
37
+ copies or substantial portions of the Software.
38
+
39
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
40
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
41
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
42
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
43
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
44
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
45
+ SOFTWARE.
46
+
package/README.md CHANGED
@@ -1,3 +1,75 @@
1
- # Temporary Holding Version
1
+ # @xlvane/compat
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The [exceljs](https://github.com/exceljs/exceljs) 4.4.0 API, built on [xlvane](https://www.npmjs.com/package/xlvane), with the differences listed below and in [docs/exceljs-compat.md](https://github.com/DevXord/xlvane/blob/main/docs/exceljs-compat.md). Code written for exceljs keeps working after one change in `package.json`:
4
+
5
+ ```json
6
+ "dependencies": {
7
+ "exceljs": "npm:@xlvane/compat@^1"
8
+ }
9
+ ```
10
+
11
+ npm installs the package under the name `exceljs` (an npm alias), so `import ExcelJS from 'exceljs'` and `require('exceljs')` load `@xlvane/compat` and the code stays unchanged.
12
+
13
+ ## Installing
14
+
15
+ In a project that uses exceljs, either install the alias:
16
+
17
+ ```sh
18
+ npm install exceljs@npm:@xlvane/compat@^1
19
+ ```
20
+
21
+ or let the `xlvane` command line prepare the project:
22
+
23
+ ```sh
24
+ npx xlvane migrate # report: the change to package.json and places in the code to check
25
+ npx xlvane migrate --force # change package.json, then run npm install
26
+ ```
27
+
28
+ `xlvane migrate` changes only `package.json`, and only with `--force`. It scans the files that mention exceljs for API outside the supported subset; the matching is textual, so a finding is a place to look at.
29
+
30
+ ## Example
31
+
32
+ ```js
33
+ import ExcelJS from 'exceljs';
34
+
35
+ const workbook = new ExcelJS.Workbook();
36
+ const sheet = workbook.addWorksheet('Sales');
37
+ sheet.columns = [
38
+ { header: 'Region', key: 'region', width: 15 },
39
+ { header: 'Revenue', key: 'revenue', width: 12 },
40
+ ];
41
+ sheet.addRow({ region: 'North', revenue: 1200 });
42
+ await workbook.xlsx.writeFile('sales.xlsx');
43
+ ```
44
+
45
+ In CommonJS, `const ExcelJS = require('exceljs');` gives the same object; call `writeFile` inside an async function there.
46
+
47
+ ## Requirements
48
+
49
+ - Node.js 22.12 or later (`engines.node`). The package is an ES module; `require()` of ES modules works without a flag from Node.js 22.12. Named imports such as `import { Workbook } from 'exceljs'` work too.
50
+ - The same test bundle runs in Node.js 22, 24 and 26, Bun, Deno, Chromium and the Cloudflare Workers runtime (workerd). Methods that read or write files (`xlsx.readFile`, `xlsx.writeFile`, `csv.readFile`, `csv.writeFile`, the `filename` forms of the streaming classes and of `addImage`) work in Node.js, Bun and Deno; in browsers and Workers they throw `XLV_E_NOT_SUPPORTED`, and a bundler leaves the file helpers out.
51
+ - Dependencies: `xlvane` only, which depends on `fflate` only.
52
+ - TypeScript: the type names of exceljs's `index.d.ts` are exported (`ExcelJS.Worksheet`, `ExcelJS.Fill`, …) and work with `moduleResolution` `bundler` and `nodenext` and with `module: commonjs`. In a CommonJS project, TypeScript refuses `import ExcelJS = require('exceljs')` of an ES module under `module: node16` (TS1471); use `nodenext` or `commonjs`.
53
+
54
+ ## Differences from exceljs
55
+
56
+ The full list, with the exceljs source of each behaviour, is in [docs/exceljs-compat.md](https://github.com/DevXord/xlvane/blob/main/docs/exceljs-compat.md) (also in `node_modules/xlvane/docs/exceljs-compat.md` after installing). The ones most likely to matter:
57
+
58
+ - **Not offered:** row and column operations on a streamed worksheet (`insertRow(s)`, `spliceRows`, `duplicateRow`, `spliceColumns`; exceljs's streaming worksheet does not have them either) throw an `XlvError` with code `XLV_E_NOT_SUPPORTED` and the name of the method. Deep imports of exceljs internals (`exceljs/lib/...`) do not resolve; `exceljs/dist/es5` and the `exceljs/dist/exceljs*.js` files do. Nothing is dropped silently.
59
+ - **CSV:** text that starts with `=`, `+`, `-`, `@`, a tab, CR or LF is written with a leading `'`, so spreadsheet applications do not run it as a formula. `formulaInjection: "off"` writes it unchanged, as exceljs does.
60
+ - **Sheet ids:** the file gets `sheetId` 1, 2, 3… in sheet order, and a loaded workbook numbers its sheets 1, 2, 3… in file order. After removing a sheet, `getWorksheet(id)` can give another sheet than with exceljs; look sheets up by name.
61
+ - **Views:** only the first view of a worksheet is written; a split view is written without its `topLeftCell`.
62
+ - **Notes:** `protection.locked` and `lockText` read back as `'True'`/`'False'`, the values Excel writes.
63
+ - **Module object:** it is frozen, so adding or replacing its properties (monkey-patching) has no effect.
64
+ - **Streaming writer speed:** `stream.xlsx.WorkbookWriter` compresses in JavaScript (fflate) and took about twice as long as exceljs, which uses Node.js zlib (300 000 rows: 6.1 s against 2.8 s).
65
+ - **Input files** are treated as untrusted, as in xlvane: ZIP and XML limits, no DTDs or external entities. A file over a limit is rejected with an `XlvError` (`XLV_E_*` code, location and hint; `node_modules/xlvane/docs/errors.md`).
66
+
67
+ ## Links
68
+
69
+ - Changes in each version: [CHANGELOG.md](https://github.com/DevXord/xlvane/blob/main/CHANGELOG.md)
70
+ - Bugs and questions: [GitHub issues](https://github.com/DevXord/xlvane/issues)
71
+ - Reporting a vulnerability: [SECURITY.md](https://github.com/DevXord/xlvane/blob/main/SECURITY.md)
72
+
73
+ ## License
74
+
75
+ MIT. @xlvane/compat is an independent project. It is not affiliated with or endorsed by the exceljs project or its authors, and it contains no exceljs code; its API and type declarations follow exceljs 4.4.0, whose MIT license notice is included in LICENSE.