@openjsxl/core 0.1.0 → 0.2.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/README.md +29 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# @openjsxl/core
|
|
2
2
|
|
|
3
|
-
The zero-dependency OOXML engine behind [`openjsxl`](https://www.npmjs.com/package/openjsxl)
|
|
3
|
+
The zero-dependency OOXML engine behind [`openjsxl`](https://www.npmjs.com/package/openjsxl):
|
|
4
4
|
the `zip → xml → ooxml → reader` layers that turn an `.xlsx` into typed cells, built only on
|
|
5
|
-
platform Web APIs (`DecompressionStream`, `TextDecoder`, …).
|
|
5
|
+
platform Web APIs (`DecompressionStream`, `TextDecoder`, …). No runtime dependencies.
|
|
6
6
|
|
|
7
7
|
**Most users should install [`openjsxl`](https://www.npmjs.com/package/openjsxl) instead** — it
|
|
8
8
|
re-exports everything here and is the stable public surface. Install `@openjsxl/core` directly
|
|
@@ -12,12 +12,37 @@ only if you want the engine without the facade.
|
|
|
12
12
|
npm install @openjsxl/core
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
15
17
|
```ts
|
|
16
18
|
import { openXlsx, streamSheetRows, XlsxError } from '@openjsxl/core'
|
|
19
|
+
import { readFile } from 'node:fs/promises'
|
|
20
|
+
|
|
21
|
+
const wb = await openXlsx(await readFile('data.xlsx'))
|
|
22
|
+
const sheet = wb.sheet('Sheet1')
|
|
23
|
+
|
|
24
|
+
sheet.cell('A1') // { ref, type, value } — narrow on `type` for a typed value
|
|
25
|
+
sheet.numberFormat('C1') // "mm-dd-yy" | undefined
|
|
26
|
+
sheet.mergedCells // ["A1:B1", …]
|
|
27
|
+
|
|
28
|
+
// Constant-memory streaming for large sheets — one row at a time.
|
|
29
|
+
for await (const row of streamSheetRows(await readFile('huge.xlsx'))) {
|
|
30
|
+
console.log(row.index, row.cells.length)
|
|
31
|
+
}
|
|
17
32
|
```
|
|
18
33
|
|
|
19
|
-
|
|
20
|
-
|
|
34
|
+
Malformed input throws a typed `XlsxError` with a discriminating `.code`
|
|
35
|
+
(`'not-a-zip' | 'not-xlsx' | 'missing-part' | 'corrupt-zip' | 'part-too-large' | …`), never a
|
|
36
|
+
bare `TypeError` from a corrupt file.
|
|
37
|
+
|
|
38
|
+
## Exports
|
|
39
|
+
|
|
40
|
+
- **Reader:** `openXlsx`, `streamSheetRows`, `Workbook`, `Worksheet`, `ReadOptions`
|
|
41
|
+
- **Errors:** `XlsxError`, `XlsxErrorCode`
|
|
42
|
+
- **Types:** `Row`, `Cell`, `CellType`, `Comment`, `Hyperlink`, `SheetInfo`, `CellRef`
|
|
43
|
+
- **A1 & dates:** `columnToIndex`, `indexToColumn`, `parseRef`, `formatRef`, `serialToDate`
|
|
44
|
+
|
|
45
|
+
Full guide, design notes, and roadmap: <https://github.com/joaquimserafim/openjsxl>
|
|
21
46
|
|
|
22
47
|
## License
|
|
23
48
|
|