@xlvane/compat 1.0.0 → 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.
Files changed (2) hide show
  1. package/README.md +52 -7
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @xlvane/compat
2
2
 
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 in docs/exceljs-compat.md (link below). Code written for exceljs keeps working after one change in `package.json`:
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
4
 
5
5
  ```json
6
6
  "dependencies": {
@@ -8,8 +8,29 @@ The [exceljs](https://github.com/exceljs/exceljs) 4.4.0 API, built on [xlvane](h
8
8
  }
9
9
  ```
10
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
+
11
32
  ```js
12
- import ExcelJS from 'exceljs'; // or: const ExcelJS = require('exceljs');
33
+ import ExcelJS from 'exceljs';
13
34
 
14
35
  const workbook = new ExcelJS.Workbook();
15
36
  const sheet = workbook.addWorksheet('Sales');
@@ -21,10 +42,34 @@ sheet.addRow({ region: 'North', revenue: 1200 });
21
42
  await workbook.xlsx.writeFile('sales.xlsx');
22
43
  ```
23
44
 
24
- - Requires Node.js 22.12 or later for `require()` (the package is an ES module; `require()` of ES modules works without a flag from 22.12). ESM `import` works the same way, and named imports such as `import { Workbook } from 'exceljs'` work too.
25
- - The few exceljs features that are not offered (row and column operations on a streamed worksheet, which exceljs itself does not have, and deep imports of exceljs internals such as `exceljs/lib/...`) throw an `XlvError` with code `XLV_E_NOT_SUPPORTED` and the name of the feature, or fail to resolve. Nothing is dropped silently.
26
- - What is supported, partly supported and not supported, with the source of each exceljs behaviour: [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). Errors are described in `node_modules/xlvane/docs/errors.md`.
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)
27
72
 
28
- @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.
73
+ ## License
29
74
 
30
- License: MIT
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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xlvane/compat",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "The commonly used exceljs 4.4.0 API on top of xlvane, for switching with one line in package.json.",
5
5
  "keywords": [
6
6
  "xlsx",
@@ -72,7 +72,7 @@
72
72
  "build": "tsdown"
73
73
  },
74
74
  "dependencies": {
75
- "xlvane": "^1.0.0"
75
+ "xlvane": "^1.0.1"
76
76
  },
77
77
  "publishConfig": {
78
78
  "access": "public",