xls-reader 0.2.0 → 0.4.0
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/CHANGELOG.md +23 -0
- package/README.md +29 -0
- package/README.pt-BR.md +30 -0
- package/dist/cli.mjs +965 -0
- package/dist/index.cjs +16 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -1
- package/dist/index.d.mts +3 -1
- package/dist/index.mjs +16 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# xls-reader
|
|
2
2
|
|
|
3
|
+
## 0.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#37](https://github.com/zanlucathiago/xls-reader/pull/37) [`67fb30c`](https://github.com/zanlucathiago/xls-reader/commit/67fb30cc06f2dba2ea59becbb7bfeca2fbb82654) Thanks [@zanlucathiago](https://github.com/zanlucathiago)! - Add a `xls-reader` command-line tool. Run `npx xls-reader report.xls` to print a
|
|
8
|
+
workbook's cells as JSON without writing any code — handy for a quick look or a
|
|
9
|
+
shell pipeline, and directly runnable by agents/tooling. Flags: `--objects` (rows
|
|
10
|
+
as header-keyed objects), `--sheet <name|index>`, `--visible-only`, `--compact`,
|
|
11
|
+
plus `--help` / `--version`. It reads from a file argument and writes JSON to
|
|
12
|
+
stdout; errors go to stderr with a non-zero exit code. The library API is
|
|
13
|
+
unchanged.
|
|
14
|
+
|
|
15
|
+
## 0.3.0
|
|
16
|
+
|
|
17
|
+
### Minor Changes
|
|
18
|
+
|
|
19
|
+
- [#35](https://github.com/zanlucathiago/xls-reader/pull/35) [`5fe65c2`](https://github.com/zanlucathiago/xls-reader/commit/5fe65c29acb9f76894507cad9f54bdd74571c3ca) Thanks [@zanlucathiago](https://github.com/zanlucathiago)! - Surface sheet visibility and stop returning non-worksheet substreams. Each `Sheet`
|
|
20
|
+
now carries `visibility` (`"visible" | "hidden" | "very-hidden"`), decoded from the
|
|
21
|
+
`BOUNDSHEET8` record, so you can skip hidden lookup/config sheets. Chart sheets,
|
|
22
|
+
Excel-4 macro sheets, and VBA modules are bound sheets that hold no cells — they
|
|
23
|
+
were previously returned as empty phantom sheets and are now omitted from
|
|
24
|
+
`workbook.sheets`.
|
|
25
|
+
|
|
3
26
|
## 0.2.0
|
|
4
27
|
|
|
5
28
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -32,6 +32,7 @@ npm install xls-reader
|
|
|
32
32
|
- [Why this exists](#why-this-exists)
|
|
33
33
|
- [Usage](#usage)
|
|
34
34
|
- [Convert an .xls to JSON](#convert-an-xls-to-json)
|
|
35
|
+
- [Command line](#command-line)
|
|
35
36
|
- [API](#api)
|
|
36
37
|
- [Comparison](#comparison)
|
|
37
38
|
- [Supported](#supported)
|
|
@@ -122,6 +123,26 @@ try {
|
|
|
122
123
|
}
|
|
123
124
|
```
|
|
124
125
|
|
|
126
|
+
## Command line
|
|
127
|
+
|
|
128
|
+
No code needed for a quick look or a shell pipeline — the package ships an
|
|
129
|
+
`xls-reader` bin that prints a workbook's cells as JSON to stdout:
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
npx xls-reader report.xls # every sheet, pretty-printed
|
|
133
|
+
npx xls-reader report.xls --objects # rows keyed by the header row
|
|
134
|
+
npx xls-reader report.xls --sheet 0 --compact > sheet0.json
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
| Flag | Effect |
|
|
138
|
+
| ------------------- | ---------------------------------------------- |
|
|
139
|
+
| `--objects` | Each row as an object keyed by the header row |
|
|
140
|
+
| `--sheet <name\|n>` | Only the sheet with this name or 0-based index |
|
|
141
|
+
| `--visible-only` | Skip hidden and very-hidden sheets |
|
|
142
|
+
| `--compact` | Single-line JSON (default is pretty-printed) |
|
|
143
|
+
|
|
144
|
+
JSON goes to stdout; errors go to stderr with a non-zero exit code.
|
|
145
|
+
|
|
125
146
|
## API
|
|
126
147
|
|
|
127
148
|
### `readXls(data: ArrayBuffer | Uint8Array): Workbook`
|
|
@@ -146,8 +167,11 @@ The raw serial-number → `Date` (UTC) conversion, if you need it directly.
|
|
|
146
167
|
```ts
|
|
147
168
|
type Cell = string | number | boolean | Date | null;
|
|
148
169
|
|
|
170
|
+
type SheetVisibility = "visible" | "hidden" | "very-hidden";
|
|
171
|
+
|
|
149
172
|
interface Sheet {
|
|
150
173
|
name: string;
|
|
174
|
+
visibility: SheetVisibility;
|
|
151
175
|
rows: Cell[][]; // dense, null-padded to the last used column
|
|
152
176
|
}
|
|
153
177
|
|
|
@@ -161,6 +185,9 @@ interface Workbook {
|
|
|
161
185
|
returned as a `Date` (UTC). Use `excelSerialToDate` if you need the raw
|
|
162
186
|
conversion.
|
|
163
187
|
- **Blank / error** cells are `null`.
|
|
188
|
+
- **Visibility** — each sheet reports whether it's `visible`, `hidden`, or
|
|
189
|
+
`very-hidden`, so you can skip the hidden lookup/config tabs. Chart, macro, and
|
|
190
|
+
VBA substreams aren't worksheets and are left out of `workbook.sheets`.
|
|
164
191
|
|
|
165
192
|
## Comparison
|
|
166
193
|
|
|
@@ -185,6 +212,8 @@ of a legacy `.xls`.
|
|
|
185
212
|
`BLANK`, `MULBLANK`, `BOOLERR`, `FORMULA` (+ its `STRING` result).
|
|
186
213
|
- Shared-string table (`SST`) including strings split across `CONTINUE` records.
|
|
187
214
|
- Date detection via `XF` + `FORMAT`, and the 1900 / 1904 date systems.
|
|
215
|
+
- Sheet visibility (`visible` / `hidden` / `very-hidden`); chart, Excel-4 macro,
|
|
216
|
+
and VBA substreams are recognized and skipped (they aren't worksheets).
|
|
188
217
|
|
|
189
218
|
## Limitations
|
|
190
219
|
|
package/README.pt-BR.md
CHANGED
|
@@ -33,6 +33,7 @@ npm install xls-reader
|
|
|
33
33
|
- [Por que isso existe](#por-que-isso-existe)
|
|
34
34
|
- [Uso](#uso)
|
|
35
35
|
- [Converter um .xls para JSON](#converter-um-xls-para-json)
|
|
36
|
+
- [Linha de comando](#linha-de-comando)
|
|
36
37
|
- [API](#api)
|
|
37
38
|
- [Comparação](#comparação)
|
|
38
39
|
- [Suportado](#suportado)
|
|
@@ -125,6 +126,27 @@ try {
|
|
|
125
126
|
}
|
|
126
127
|
```
|
|
127
128
|
|
|
129
|
+
## Linha de comando
|
|
130
|
+
|
|
131
|
+
Sem escrever código, para uma olhada rápida ou um pipeline no shell — o pacote
|
|
132
|
+
inclui um bin `xls-reader` que imprime as células de um workbook como JSON no
|
|
133
|
+
stdout:
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
npx xls-reader relatorio.xls # todas as planilhas, formatado
|
|
137
|
+
npx xls-reader relatorio.xls --objects # linhas com chaves do cabeçalho
|
|
138
|
+
npx xls-reader relatorio.xls --sheet 0 --compact > planilha0.json
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
| Flag | Efeito |
|
|
142
|
+
| ------------------- | ------------------------------------------------------- |
|
|
143
|
+
| `--objects` | Cada linha como objeto com chaves da linha de cabeçalho |
|
|
144
|
+
| `--sheet <nome\|n>` | Só a planilha com este nome ou índice (base 0) |
|
|
145
|
+
| `--visible-only` | Ignora planilhas `hidden` e `very-hidden` |
|
|
146
|
+
| `--compact` | JSON em uma linha (o padrão é formatado) |
|
|
147
|
+
|
|
148
|
+
O JSON vai para o stdout; erros vão para o stderr com código de saída diferente de zero.
|
|
149
|
+
|
|
128
150
|
## API
|
|
129
151
|
|
|
130
152
|
### `readXls(data: ArrayBuffer | Uint8Array): Workbook`
|
|
@@ -152,8 +174,11 @@ diretamente.
|
|
|
152
174
|
```ts
|
|
153
175
|
type Cell = string | number | boolean | Date | null;
|
|
154
176
|
|
|
177
|
+
type SheetVisibility = "visible" | "hidden" | "very-hidden";
|
|
178
|
+
|
|
155
179
|
interface Sheet {
|
|
156
180
|
name: string;
|
|
181
|
+
visibility: SheetVisibility;
|
|
157
182
|
rows: Cell[][]; // densa, preenchida com null até a última coluna usada
|
|
158
183
|
}
|
|
159
184
|
|
|
@@ -168,6 +193,9 @@ interface Workbook {
|
|
|
168
193
|
customizado) volta como `Date` (UTC). Use `excelSerialToDate` se precisar da
|
|
169
194
|
conversão bruta.
|
|
170
195
|
- Células **em branco / de erro** viram `null`.
|
|
196
|
+
- **Visibilidade** — cada planilha informa se é `visible`, `hidden` ou
|
|
197
|
+
`very-hidden`, então dá para pular as abas ocultas de lookup/config. Substreams
|
|
198
|
+
de gráfico, macro e VBA não são planilhas e ficam de fora de `workbook.sheets`.
|
|
171
199
|
|
|
172
200
|
## Comparação
|
|
173
201
|
|
|
@@ -193,6 +221,8 @@ valores de um `.xls` legado.
|
|
|
193
221
|
- Tabela de strings compartilhadas (`SST`), incluindo strings divididas entre
|
|
194
222
|
registros `CONTINUE`.
|
|
195
223
|
- Detecção de datas via `XF` + `FORMAT`, e os sistemas de data 1900 / 1904.
|
|
224
|
+
- Visibilidade da planilha (`visible` / `hidden` / `very-hidden`); substreams de
|
|
225
|
+
gráfico, macro do Excel 4 e VBA são reconhecidos e ignorados (não são planilhas).
|
|
196
226
|
|
|
197
227
|
## Limitações
|
|
198
228
|
|