xls-reader 0.1.0 → 0.1.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 (3) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/README.md +90 -5
  3. package/package.json +30 -16
package/CHANGELOG.md ADDED
@@ -0,0 +1,23 @@
1
+ # xls-reader
2
+
3
+ ## 0.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#1](https://github.com/zanlucathiago/xls-reader/pull/1) [`7cd6a31`](https://github.com/zanlucathiago/xls-reader/commit/7cd6a3127caa16fe2ecc3428b0b51cd51b5c4d45) Thanks [@zanlucathiago](https://github.com/zanlucathiago)! - Republish with npm provenance attestation and a rewritten README (badges,
8
+ comparison table vs SheetJS/ExcelJS, browser and error-handling examples). No
9
+ changes to the parser or public API.
10
+
11
+ ## 0.1.0
12
+
13
+ Initial release. A zero-dependency reader for legacy `.xls` (BIFF8 / Excel
14
+ 97–2003) files that returns each worksheet as a dense grid of typed cells
15
+ (strings, numbers, booleans, dates, and `null` for blank/error cells).
16
+
17
+ - OLE2 / Compound File container support, including mini streams.
18
+ - BIFF8 cell records: `LABELSST`, `LABEL`, `RSTRING`, `NUMBER`, `RK`, `MULRK`,
19
+ `BLANK`, `MULBLANK`, `BOOLERR`, and `FORMULA` (with its cached `STRING`
20
+ result).
21
+ - Shared-string table (`SST`) with `CONTINUE`-split strings.
22
+ - Date detection via `XF` + `FORMAT`, honoring the 1900 and 1904 date systems.
23
+ - Dual ESM/CJS output, full type declarations, and npm provenance.
package/README.md CHANGED
@@ -1,13 +1,39 @@
1
- # xls-reader
2
-
3
- Zero-dependency reader for **legacy `.xls`** files (BIFF8 — Excel 97–2003). It
4
- returns each worksheet as a grid of typed cells: strings, numbers, booleans, and
5
- dates. Runs in Node and the browser (it only needs `Uint8Array` / `DataView`).
1
+ <h1 align="center">xls-reader</h1>
2
+
3
+ <p align="center">
4
+ Zero-dependency reader for <strong>legacy <code>.xls</code></strong> files (BIFF8 — Excel 97–2003).<br />
5
+ Returns each worksheet as a grid of typed cells: strings, numbers, booleans, and dates.
6
+ </p>
7
+
8
+ <p align="center">
9
+ <a href="https://www.npmjs.com/package/xls-reader"><img src="https://img.shields.io/npm/v/xls-reader.svg?color=cb3837&logo=npm" alt="npm version" /></a>
10
+ <a href="https://www.npmjs.com/package/xls-reader"><img src="https://img.shields.io/npm/dm/xls-reader.svg?color=cb3837&logo=npm" alt="npm downloads" /></a>
11
+ <a href="https://github.com/zanlucathiago/xls-reader/actions/workflows/ci.yml"><img src="https://github.com/zanlucathiago/xls-reader/actions/workflows/ci.yml/badge.svg" alt="CI status" /></a>
12
+ <a href="https://codecov.io/gh/zanlucathiago/xls-reader"><img src="https://codecov.io/gh/zanlucathiago/xls-reader/branch/main/graph/badge.svg" alt="coverage" /></a>
13
+ <a href="https://bundlephobia.com/package/xls-reader"><img src="https://img.shields.io/bundlephobia/minzip/xls-reader.svg?label=min%2Bgzip" alt="bundle size" /></a>
14
+ <img src="https://img.shields.io/badge/dependencies-0-brightgreen.svg" alt="zero dependencies" />
15
+ <a href="./LICENSE"><img src="https://img.shields.io/npm/l/xls-reader.svg?color=blue" alt="MIT license" /></a>
16
+ </p>
17
+
18
+ Runs in Node and the browser — it only needs `Uint8Array` / `DataView`. It ships
19
+ as **~3.8 KB min+gzip with zero runtime dependencies**, dual ESM/CJS, fully typed,
20
+ and published to npm with [provenance](https://docs.npmjs.com/generating-provenance-statements).
6
21
 
7
22
  ```bash
8
23
  npm install xls-reader
24
+ # or: pnpm add xls-reader / yarn add xls-reader
9
25
  ```
10
26
 
27
+ ## Contents
28
+
29
+ - [Why this exists](#why-this-exists)
30
+ - [Usage](#usage)
31
+ - [API](#api)
32
+ - [Comparison](#comparison)
33
+ - [Supported](#supported)
34
+ - [Limitations](#limitations)
35
+ - [Contributing](#contributing)
36
+
11
37
  ## Why this exists
12
38
 
13
39
  Modern readers like [ExcelJS](https://github.com/exceljs/exceljs) only handle the
@@ -45,6 +71,36 @@ import { readFirstSheet } from "xls-reader";
45
71
  const sheet = readFirstSheet(bytes);
46
72
  ```
47
73
 
74
+ In the browser (e.g. from a file `<input>`):
75
+
76
+ ```ts
77
+ import { readXls } from "xls-reader";
78
+
79
+ input.addEventListener("change", async () => {
80
+ const file = input.files?.[0];
81
+ if (!file) return;
82
+ const workbook = readXls(await file.arrayBuffer());
83
+ console.table(workbook.sheets[0]?.rows);
84
+ });
85
+ ```
86
+
87
+ Handling non-`.xls` input:
88
+
89
+ ```ts
90
+ import { readXls, XlsError } from "xls-reader";
91
+
92
+ try {
93
+ const workbook = readXls(bytes);
94
+ } catch (err) {
95
+ if (err instanceof XlsError) {
96
+ // Not a BIFF .xls — e.g. it's really an .xlsx, CSV, or HTML mislabeled as .xls
97
+ console.error(err.message);
98
+ } else {
99
+ throw err;
100
+ }
101
+ }
102
+ ```
103
+
48
104
  ## API
49
105
 
50
106
  ### `readXls(data: ArrayBuffer | Uint8Array): Workbook`
@@ -55,14 +111,20 @@ Parses a whole workbook. Throws `XlsError` if the bytes aren't a BIFF `.xls`.
55
111
 
56
112
  The first worksheet, for the single-sheet case.
57
113
 
114
+ ### `excelSerialToDate(serial: number, date1904: boolean): Date`
115
+
116
+ The raw serial-number → `Date` (UTC) conversion, if you need it directly.
117
+
58
118
  ### Types
59
119
 
60
120
  ```ts
61
121
  type Cell = string | number | boolean | Date | null;
122
+
62
123
  interface Sheet {
63
124
  name: string;
64
125
  rows: Cell[][]; // dense, null-padded to the last used column
65
126
  }
127
+
66
128
  interface Workbook {
67
129
  sheets: Sheet[];
68
130
  }
@@ -74,6 +136,22 @@ interface Workbook {
74
136
  conversion.
75
137
  - **Blank / error** cells are `null`.
76
138
 
139
+ ## Comparison
140
+
141
+ | | **xls-reader** | SheetJS (`xlsx`) | ExcelJS |
142
+ | -------------------------------- | -------------- | --------------------- | ------- |
143
+ | Reads legacy `.xls` (BIFF8) | ✅ | ✅ | ❌ |
144
+ | Reads `.xlsx` (OOXML) | ❌ | ✅ | ✅ |
145
+ | Latest fixes on the npm registry | ✅ | ⚠️ frozen at `0.18.5` | ✅ |
146
+ | Runtime dependencies | **0** | several | several |
147
+ | Install size | ~4 KB min+gzip | large | large |
148
+ | npm provenance attestation | ✅ | ❌ | ❌ |
149
+ | Writes files / styling / charts | ❌ | ✅ | ✅ |
150
+
151
+ If you need to **write** spreadsheets, style cells, or read `.xlsx`, reach for
152
+ ExcelJS or SheetJS. `xls-reader` deliberately does one thing: get the values out
153
+ of a legacy `.xls`.
154
+
77
155
  ## Supported
78
156
 
79
157
  - OLE2 / Compound File container (regular **and** mini streams).
@@ -91,6 +169,13 @@ interface Workbook {
91
169
  - Dates before 1900-03-01 in the 1900 system are off by one day (Excel's
92
170
  historical leap-year bug); real-world data is unaffected.
93
171
 
172
+ ## Contributing
173
+
174
+ Bug reports, sample files, and PRs are very welcome — see
175
+ [CONTRIBUTING.md](./CONTRIBUTING.md). Please also read the
176
+ [Code of Conduct](./CODE_OF_CONDUCT.md). To report a security issue, see the
177
+ [Security Policy](./SECURITY.md).
178
+
94
179
  ## License
95
180
 
96
181
  [MIT](./LICENSE) © Thiago Zanluca
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xls-reader",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Zero-dependency reader for legacy .xls (BIFF8 / Excel 97-2003) files. Returns each sheet as a grid of typed cells.",
5
5
  "keywords": [
6
6
  "xls",
@@ -11,7 +11,14 @@
11
11
  "cfb",
12
12
  "legacy-excel",
13
13
  "parser",
14
- "xlrd"
14
+ "xls-parser",
15
+ "read-xls",
16
+ "sheetjs-alternative",
17
+ "xlrd",
18
+ "zero-dependency",
19
+ "typescript",
20
+ "browser",
21
+ "node"
15
22
  ],
16
23
  "license": "MIT",
17
24
  "author": "Thiago Zanluca",
@@ -37,30 +44,37 @@
37
44
  "files": [
38
45
  "dist",
39
46
  "README.md",
47
+ "CHANGELOG.md",
40
48
  "LICENSE"
41
49
  ],
42
50
  "sideEffects": false,
43
51
  "engines": {
44
52
  "node": ">=18"
45
53
  },
54
+ "devDependencies": {
55
+ "@changesets/changelog-github": "^0.7.0",
56
+ "@changesets/cli": "^2.31.0",
57
+ "@eslint/js": "^10.0.1",
58
+ "@types/node": "^22.20.0",
59
+ "@vitest/coverage-v8": "^4.1.9",
60
+ "eslint": "^10.6.0",
61
+ "prettier": "^3.4.2",
62
+ "tsup": "^8.3.5",
63
+ "typescript": "^6.0.3",
64
+ "typescript-eslint": "^8.18.1",
65
+ "vite": "^7.3.6",
66
+ "vitest": "^4.1.9"
67
+ },
46
68
  "scripts": {
47
69
  "build": "tsup",
48
70
  "test": "vitest run",
49
71
  "test:watch": "vitest",
72
+ "coverage": "vitest run --coverage",
50
73
  "typecheck": "tsc --noEmit",
51
74
  "lint": "eslint .",
52
75
  "format": "prettier --write .",
53
- "prepublishOnly": "npm run build"
54
- },
55
- "devDependencies": {
56
- "@eslint/js": "^9.17.0",
57
- "@types/node": "^20.17.0",
58
- "eslint": "^9.17.0",
59
- "prettier": "^3.4.2",
60
- "tsup": "^8.3.5",
61
- "typescript": "^5.7.2",
62
- "typescript-eslint": "^8.18.1",
63
- "vitest": "^2.1.8"
64
- },
65
- "packageManager": "pnpm@11.9.0"
66
- }
76
+ "changeset": "changeset",
77
+ "version-packages": "changeset version",
78
+ "release": "changeset publish"
79
+ }
80
+ }