@coloop-ai/xlsx-wasm 0.0.0-stage → 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Genie Technology Limited
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,87 @@
1
- # Temporary Holding Version
1
+ # @coloop-ai/xlsx-wasm
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
+ [![npm version](https://img.shields.io/npm/v/@coloop-ai/xlsx-wasm.svg)](https://www.npmjs.com/package/@coloop-ai/xlsx-wasm)
4
+ [![npm downloads](https://img.shields.io/npm/dm/@coloop-ai/xlsx-wasm.svg)](https://www.npmjs.com/package/@coloop-ai/xlsx-wasm)
5
+ [![License: MIT](https://img.shields.io/npm/l/@coloop-ai/xlsx-wasm.svg)](https://github.com/Genei-Ltd/xlsx-wasm/blob/main/LICENSE)
6
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.9-blue?logo=typescript)](https://www.typescriptlang.org/)
7
+
8
+ Read Excel workbooks as Excel shows them: a sandboxed WebAssembly binding to the [IronCalc](https://github.com/ironcalc/IronCalc) spreadsheet engine.
9
+
10
+ It gives you everything IronCalc reads from a workbook: values as stored and as displayed, formulas, number formats, styles, merged cells, Excel tables, defined names, frozen panes, hidden rows, columns and sheets, comments, links and conditional formats. It also evaluates Excel formulas against the workbook. It is made for tools that must make sense of spreadsheets with arbitrary layouts.
11
+
12
+ ## Installation
13
+
14
+ ```bash
15
+ npm install @coloop-ai/xlsx-wasm
16
+ ```
17
+
18
+ ## Usage
19
+
20
+ ```ts
21
+ import { readFile } from 'node:fs/promises'
22
+ import { Workbook } from '@coloop-ai/xlsx-wasm'
23
+
24
+ const workbook = await Workbook.open(await readFile('survey.xlsx'))
25
+ try {
26
+ const { sheets } = workbook.describe()
27
+ const cells = workbook.cells(0, {
28
+ firstRow: 1,
29
+ firstColumn: 1,
30
+ lastRow: 40,
31
+ lastColumn: 8,
32
+ })
33
+ const [count] = workbook.evaluate(0, ['=COUNTIFS(C5:C500,"UK")'])
34
+ } finally {
35
+ workbook.close()
36
+ }
37
+ ```
38
+
39
+ ## API
40
+
41
+ | Method | Returns |
42
+ | ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
43
+ | `Workbook.open(bytes)` | A workbook, read from the bytes of an `.xlsx` file. |
44
+ | `describe()` | Metadata, defined names, Excel tables, the styles in use, and each sheet with its visibility, used range, frozen panes, merged cells, hidden rows and columns, comments, links and conditional formats. |
45
+ | `cells(sheet, area?)` | The non-empty cells of a sheet, or of an area of it: value, displayed text, formula, style and spill. |
46
+ | `evaluate(sheet, formulas, mode?)` | One result per formula: a value, or the rows of an array. A reference without a sheet name refers to `sheet`. |
47
+ | `recalculate()` | The formula cells whose value differs between the saved workbook and a full recalculation. |
48
+ | `formatValue(value, format)` | A number formatted with an Excel number format. |
49
+ | `close()` | Frees the workbook. |
50
+
51
+ Sheets are numbered from 0, rows and columns from 1. Every method throws an `XlsxError` whose `kind` is `invalid_workbook`, `invalid_request`, `out_of_memory`, `crashed` or `closed`.
52
+
53
+ ## Evaluation modes
54
+
55
+ - `saved` (the default): formulas read the results that Excel saved for the workbook's own formulas. This matches what Excel shows, even where IronCalc lacks a function the workbook uses.
56
+ - `recalculated`: the workbook is recalculated first. A function IronCalc does not support gives `#NAME?`.
57
+
58
+ `recalculate()` lists where the two disagree.
59
+
60
+ ## Sandbox and limits
61
+
62
+ Each workbook runs in its own WebAssembly instance, with a WASI layer written in JavaScript ([@bjorn3/browser_wasi_shim](https://github.com/bjorn3/browser_wasi_shim)). The instance gets the workbook's bytes and nothing else: no file system, no network, no environment variables and no bridge to JavaScript. Its memory is capped at 256 MiB. A workbook that needs more ends with `out_of_memory`, and later calls on it throw the same error.
63
+
64
+ Calls are synchronous. Run them in a worker thread if they must not block the event loop.
65
+
66
+ Some IronCalc functions read a whole column (`A:A`) as a million cells. Prefer ranges with rows (`A2:A500`). Only `.xlsx` workbooks are supported, not `.xls`.
67
+
68
+ ## Development
69
+
70
+ The library is a Rust crate in `rust/`. Its toolchain is pinned in `rust/rust-toolchain.toml`, which also installs the `wasm32-wasip1` target.
71
+
72
+ ```bash
73
+ pnpm install
74
+ pnpm run build:wasm # Build xlsx.wasm (needed before the tests)
75
+ pnpm run notices # Regenerate THIRD-PARTY-NOTICES.md (needs cargo-about)
76
+ pnpm run build # Build the package
77
+ pnpm run tc # Type-check
78
+ pnpm run lint # Lint
79
+ pnpm run test # Run tests
80
+ pnpm run format # Check formatting
81
+ ```
82
+
83
+ New dependency versions must wait seven days before pnpm can install them. This is configured in `pnpm-workspace.yaml` as a supply-chain safety delay.
84
+
85
+ ## License
86
+
87
+ MIT License. See [LICENSE](./LICENSE) for details. `xlsx.wasm` contains compiled third-party Rust crates. Their licences are in [THIRD-PARTY-NOTICES.md](./THIRD-PARTY-NOTICES.md).