@rosperitus/excelerate-reader 0.8.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) 2026 Yuri Rubtsov (aka rosperitus)
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 ADDED
@@ -0,0 +1,106 @@
1
+ # excelerate-reader
2
+
3
+ Read spreadsheets in Node or the browser - xlsx, xls, ods, csv, html, SYLK,
4
+ Gnumeric and SpreadsheetML 2003 - and read how their cells are painted. Rust
5
+ compiled to WebAssembly, no native module to build and nothing to install
6
+ alongside it.
7
+
8
+ This is the reading half of [excelerate](https://www.npmjs.com/package/excelerate).
9
+ The full package also writes files back out and carries a 443-function formula
10
+ engine; if you need either, use that one. Here they are not compiled in at all,
11
+ which is the point: a reader that cannot write cannot be made to write, and the
12
+ binary is the smaller for it.
13
+
14
+ ```js
15
+ const { readFileSync } = require("node:fs");
16
+ const { Book } = require("@rosperitus/excelerate-reader");
17
+
18
+ // The format is worked out from the bytes; the name only settles what they
19
+ // cannot say themselves.
20
+ const book = Book.read(readFileSync("report.xlsx"), "report.xlsx");
21
+
22
+ for (const name of book.sheetNames()) {
23
+ const sheet = book.sheetIndex(name);
24
+ console.log(name, book.usedRange(sheet));
25
+ }
26
+
27
+ // A cell's value, the text Excel shows for it, and the formula behind it.
28
+ book.get(0, "B2"); // 1234.5
29
+ book.getFormatted(0, "B2"); // "1 234,50 ₽"
30
+ book.getFormula(0, "B2"); // "SUM(B3:B9)" - the text, not its answer
31
+
32
+ // A whole rectangle in one crossing of the wasm boundary.
33
+ book.getRange(0, "A1:D20");
34
+
35
+ // Or a whole row with its styling, which is one crossing instead of a dozen.
36
+ book.getRowAt(0, 3); // { values, formatted, bold, indent, hidden }
37
+ book.getRowAt(0, 3, false); // the same without the displayed text, which is
38
+ // a string per cell nobody asked for
39
+ ```
40
+
41
+ ## Layout
42
+
43
+ Reading a sheet usually means asking the same few things of every row, so each
44
+ has an answer that does not build a whole style to get at one flag:
45
+
46
+ ```js
47
+ book.cellBoldAt(0, 3, 1); // true - the font flag on its own
48
+ book.rowHidden(0, 3); // false
49
+ book.mergedRanges(0); // ["A1:H1", "A2:H2", ...] - what the header spans
50
+ book.mergedRangesAt(0); // the same as numbers: [r1, c1, r2, c2] per area,
51
+ // one Uint32Array where a big sheet has 300k areas
52
+ book.sheetVisibility(0); // "visible" | "hidden" | "veryHidden"
53
+ ```
54
+
55
+ `sheetNames` lists every sheet, hidden ones included: the index every other
56
+ call takes is the sheet's position in the workbook, and skipping the hidden
57
+ ones would shift it.
58
+
59
+ ## Styles
60
+
61
+ `cellStyle` answers with the number format, font, fill, borders and text
62
+ placement, as the file states them. A cell the file says nothing about answers
63
+ with Excel's own defaults, which is what Excel shows for it.
64
+
65
+ ```js
66
+ const style = book.cellStyle(0, "A1");
67
+ style.font.bold; // true
68
+ style.font.size; // 14 - points, not the hundredths the file stores
69
+ style.fill.foreground; // "#FFFFE699"
70
+ style.borders.bottom; // { style: "thin", color: "#FF000000" }
71
+ style.alignment.wrapText; // true
72
+ style.numberFormat; // "#,##0.00"
73
+ ```
74
+
75
+ Colours come as text: `#AARRGGBB` when the file names one outright, `null`
76
+ where it leaves the choice to the reader, and `indexed:N` or `theme:N` when it
77
+ points into the legacy palette or the workbook theme instead. A theme colour
78
+ carries its tint as `theme:4@-0.25`. The two indirect forms are not resolved
79
+ for you - an indexed colour needs the palette of the file it came from, and a
80
+ theme colour needs the workbook theme, which the reader keeps but does not
81
+ interpret.
82
+
83
+ ## Formulas
84
+
85
+ A formula's **text** is here (`getFormula`), and so is the value the file was
86
+ saved with - `get` on a formula cell answers with the cached result. What is
87
+ not here is the engine that would recompute it: `evaluate`, `recalculate` and
88
+ `recalculateFrom` exist only in the full package.
89
+
90
+ That cached value is worth exactly what the application that wrote the file is
91
+ worth. A package with no `xl/calcChain.xml` was not last saved by Excel, and
92
+ its cached values may be stale.
93
+
94
+ ## Reading a package that expands a long way
95
+
96
+ `Book.read(bytes, name, maxExpanded)` takes a ceiling on how far a zipped
97
+ package may unpack, which is what stops a zip bomb. It defaults to 512 MB; a
98
+ real workbook can outgrow that - a 100 MB package unpacking to 560 MB is not
99
+ unusual - so raise it when you know where the file came from.
100
+
101
+ ## What is not here
102
+
103
+ Writing, in any format. Recalculation. Everything else the full package can do
104
+ with a workbook once it is open - the reading side of it - is.
105
+
106
+ MIT.
@@ -0,0 +1,263 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ /** What a cell can hold on the JS side. An error cell reads as its code, `#DIV/0!`. */
5
+ export type CellValue = number | string | boolean | null;
6
+ /** A rectangle of cells, row by row, as `getRange` returns it. */
7
+ export type CellGrid = CellValue[][];
8
+ /**
9
+ * One row with its styling, as `getRowAt` returns it. `formatted` is `null`
10
+ * when the call asked for values alone. `bold` is one byte per cell, 0 or 1.
11
+ */
12
+ export interface SheetRow {
13
+ values: CellValue[];
14
+ formatted: string[] | null;
15
+ bold: Uint8Array;
16
+ indent: Uint32Array;
17
+ hidden: boolean;
18
+ }
19
+ /**
20
+ * A colour as the file states it: `null` when the file leaves it to the
21
+ * reader, `#AARRGGBB` when it names one outright, and `indexed:N` or
22
+ * `theme:N` when it points into the legacy palette or the workbook theme -
23
+ * a theme colour carries its tint as `theme:4@-0.25`.
24
+ */
25
+ export type StyleColor = string | null;
26
+ /** One side of a cell's border. */
27
+ export interface BorderSide { style: string; color: StyleColor }
28
+ /** How a cell is painted, as `cellStyle` returns it. */
29
+ export interface CellStyle {
30
+ numberFormat: string;
31
+ font: {
32
+ name: string;
33
+ size: number;
34
+ bold: boolean;
35
+ italic: boolean;
36
+ underline: string;
37
+ strike: boolean;
38
+ color: StyleColor;
39
+ };
40
+ fill: { pattern: string; foreground: StyleColor; background: StyleColor };
41
+ borders: {
42
+ left: BorderSide;
43
+ right: BorderSide;
44
+ top: BorderSide;
45
+ bottom: BorderSide;
46
+ };
47
+ alignment: {
48
+ horizontal: string | null;
49
+ vertical: string | null;
50
+ wrapText: boolean;
51
+ shrinkToFit: boolean;
52
+ indent: number;
53
+ textRotation: number;
54
+ };
55
+ }
56
+
57
+
58
+
59
+ /**
60
+ * A workbook.
61
+ */
62
+ export class Book {
63
+ free(): void;
64
+ [Symbol.dispose](): void;
65
+ /**
66
+ * The tab a reader opens the workbook on.
67
+ */
68
+ activeSheet(): number;
69
+ /**
70
+ * Appends a sheet and returns its index.
71
+ */
72
+ addSheet(title: string): number;
73
+ /**
74
+ * Whether a cell is bold.
75
+ *
76
+ * The one flag, without building the rest of the style: a parser that
77
+ * looks for a header row asks this of every cell, and `cellStyle` would
78
+ * make it pay for the font, fill and four borders it never reads.
79
+ */
80
+ cellBold(sheet: number, address: string): boolean;
81
+ /**
82
+ * The same by 1-based row and column.
83
+ */
84
+ cellBoldAt(sheet: number, row: number, column: number): boolean;
85
+ /**
86
+ * How many non-empty cells the workbook holds, or one sheet of it.
87
+ */
88
+ cellCount(sheet?: number | null): number;
89
+ /**
90
+ * The indent of a cell, in Excel's indent steps (0 when it has none).
91
+ *
92
+ * Indent lives on the cell's style, and a spreadsheet only honours it for
93
+ * left, right and distributed alignment - but the number is returned as
94
+ * the file states it, whatever the alignment.
95
+ */
96
+ cellIndent(sheet: number, address: string): number;
97
+ /**
98
+ * The same by 1-based row and column.
99
+ */
100
+ cellIndentAt(sheet: number, row: number, column: number): number;
101
+ /**
102
+ * How a cell is painted: number format, font, fill, borders and text
103
+ * placement, as the file states them.
104
+ *
105
+ * A cell the file says nothing about answers with Excel's defaults, which
106
+ * is what Excel itself shows for it.
107
+ */
108
+ cellStyle(sheet: number, address: string): CellStyle;
109
+ /**
110
+ * The same by 1-based row and column.
111
+ */
112
+ cellStyleAt(sheet: number, row: number, column: number): CellStyle;
113
+ /**
114
+ * Empties a cell, style and all.
115
+ */
116
+ clear(sheet: number, address: string): void;
117
+ /**
118
+ * The same by 1-based row and column.
119
+ */
120
+ clearAt(sheet: number, row: number, column: number): void;
121
+ /**
122
+ * The same for a column, named by its letters: `columnLevel(0, "C")`.
123
+ */
124
+ columnLevel(sheet: number, column: string): number;
125
+ /**
126
+ * Reads an xlsx package from its bytes.
127
+ */
128
+ static fromXlsx(bytes: Uint8Array): Book;
129
+ /**
130
+ * The value at `address` on sheet `sheet`, as a JS number, string, boolean
131
+ * or `null`. A formula cell gives its cached result, not its text.
132
+ */
133
+ get(sheet: number, address: string): CellValue;
134
+ /**
135
+ * The same by 1-based row and column, the numbers `ROW()` and `COLUMN()`
136
+ * return: `getAt(0, 4, 2)` is `B4`. Saves formatting an address only to
137
+ * parse it again.
138
+ */
139
+ getAt(sheet: number, row: number, column: number): CellValue;
140
+ /**
141
+ * The cell as a spreadsheet would display it: the value run through its
142
+ * number format, so `0.256` under `0.0%` reads `25.6%`.
143
+ */
144
+ getFormatted(sheet: number, address: string): string;
145
+ /**
146
+ * The same by 1-based row and column.
147
+ */
148
+ getFormattedAt(sheet: number, row: number, column: number): string;
149
+ /**
150
+ * The formula text of a cell without its leading `=`, or `undefined` when
151
+ * the cell holds a plain value.
152
+ */
153
+ getFormula(sheet: number, address: string): string | undefined;
154
+ /**
155
+ * The same by 1-based row and column.
156
+ */
157
+ getFormulaAt(sheet: number, row: number, column: number): string | undefined;
158
+ /**
159
+ * A rectangle of cells, row by row. One call across the boundary instead
160
+ * of one per cell, which is what makes reading a sheet worth doing.
161
+ */
162
+ getRange(sheet: number, range: string): CellGrid;
163
+ /**
164
+ * The same by numbers: the top-left cell, then how many rows and columns
165
+ * to take. `getRangeAt(0, 1, 1, 3, 2)` is `A1:B3`.
166
+ */
167
+ getRangeAt(sheet: number, row: number, column: number, rows: number, columns: number): CellGrid;
168
+ /**
169
+ * A whole row in one crossing of the boundary: values, displayed text,
170
+ * bold and indent, plus whether the row is hidden.
171
+ *
172
+ * The arrays run from column 1 to the last column this row has a cell in,
173
+ * so a row of ten cells costs one call rather than forty.
174
+ *
175
+ * `formatted` is what the number format makes of each value, and building
176
+ * it allocates a string per cell - which a caller reading values does not
177
+ * want to pay half a sheet over. Pass `false` and the field comes back
178
+ * `null`; `getFormattedAt` still answers for the cells that need it.
179
+ */
180
+ getRowAt(sheet: number, row: number, formatted?: boolean | null): SheetRow;
181
+ /**
182
+ * The merged areas of a sheet, as `"A1:C1"` strings in the order the file
183
+ * lists them.
184
+ */
185
+ mergedRanges(sheet: number): string[];
186
+ /**
187
+ * The merged areas of a sheet as numbers: four per area, `[r1, c1, r2,
188
+ * c2]`, rows and columns 1-based.
189
+ *
190
+ * One typed array instead of a JS string per area, which is what a sheet
191
+ * carrying three hundred thousand of them needs.
192
+ */
193
+ mergedRangesAt(sheet: number): Uint32Array;
194
+ /**
195
+ * A new workbook with one empty sheet.
196
+ */
197
+ constructor();
198
+ /**
199
+ * Reads a workbook of any format this crate supports, working the format
200
+ * out from the bytes themselves.
201
+ *
202
+ * `name` is the file name they came from, if the caller has one: it
203
+ * settles what the bytes cannot say (a `.csv` against a `.html`) and names
204
+ * the sheet of a SYLK file.
205
+ */
206
+ static read(bytes: Uint8Array, name?: string | null, max_expanded?: number | null, on_progress?: Function | null): Book;
207
+ /**
208
+ * Renames a sheet.
209
+ */
210
+ renameSheet(sheet: number, title: string): void;
211
+ /**
212
+ * Whether a row is hidden. `row` is the number a user sees.
213
+ */
214
+ rowHidden(sheet: number, row: number): boolean;
215
+ /**
216
+ * How deeply a row is grouped: 0 when it is not, 1 for the outermost
217
+ * group, and so on. `row` is the number a user sees.
218
+ */
219
+ rowLevel(sheet: number, row: number): number;
220
+ /**
221
+ * Writes a value: a number, boolean, or string. A string starting with `=`
222
+ * becomes a formula.
223
+ */
224
+ set(index: number, address: string, value: CellValue): void;
225
+ /**
226
+ * Sets that tab.
227
+ */
228
+ setActiveSheet(sheet: number): void;
229
+ /**
230
+ * The same by 1-based row and column.
231
+ */
232
+ setAt(sheet: number, row: number, column: number, value: CellValue): void;
233
+ /**
234
+ * Writes a rectangle of values with `at` as its top-left corner. Rows may
235
+ * differ in length; a `null` leaves its cell empty.
236
+ */
237
+ setRange(sheet: number, at: string, values: CellGrid): void;
238
+ /**
239
+ * The same with the corner given as 1-based row and column.
240
+ */
241
+ setRangeAt(sheet: number, row: number, column: number, values: CellGrid): void;
242
+ /**
243
+ * The tab index of a sheet by name, or `undefined` when there is none.
244
+ * Names are compared the way Excel does, ignoring case.
245
+ */
246
+ sheetIndex(name: string): number | undefined;
247
+ /**
248
+ * Sheet titles, in tab order.
249
+ */
250
+ sheetNames(): string[];
251
+ /**
252
+ * Whether a sheet has a tab: `"visible"`, `"hidden"` or `"veryHidden"`.
253
+ *
254
+ * `sheetNames` lists every sheet, hidden ones included, because that is
255
+ * what the index of every other call counts.
256
+ */
257
+ sheetVisibility(sheet: number): string;
258
+ /**
259
+ * The used range of a sheet as `A1:D9`, or `undefined` if it holds
260
+ * nothing. This is the rectangle to walk; the sheet itself is sparse.
261
+ */
262
+ usedRange(sheet: number): string | undefined;
263
+ }
package/excelerate.js ADDED
@@ -0,0 +1,872 @@
1
+ /* @ts-self-types="./excelerate.d.ts" */
2
+
3
+ /**
4
+ * A workbook.
5
+ */
6
+ class Book {
7
+ static __wrap(ptr) {
8
+ const obj = Object.create(Book.prototype);
9
+ obj.__wbg_ptr = ptr;
10
+ BookFinalization.register(obj, obj.__wbg_ptr, obj);
11
+ return obj;
12
+ }
13
+ __destroy_into_raw() {
14
+ const ptr = this.__wbg_ptr;
15
+ this.__wbg_ptr = 0;
16
+ BookFinalization.unregister(this);
17
+ return ptr;
18
+ }
19
+ free() {
20
+ const ptr = this.__destroy_into_raw();
21
+ wasm.__wbg_book_free(ptr, 0);
22
+ }
23
+ /**
24
+ * The tab a reader opens the workbook on.
25
+ * @returns {number}
26
+ */
27
+ activeSheet() {
28
+ const ret = wasm.book_activeSheet(this.__wbg_ptr);
29
+ return ret >>> 0;
30
+ }
31
+ /**
32
+ * Appends a sheet and returns its index.
33
+ * @param {string} title
34
+ * @returns {number}
35
+ */
36
+ addSheet(title) {
37
+ const ptr0 = passStringToWasm0(title, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
38
+ const len0 = WASM_VECTOR_LEN;
39
+ const ret = wasm.book_addSheet(this.__wbg_ptr, ptr0, len0);
40
+ if (ret[2]) {
41
+ throw takeFromExternrefTable0(ret[1]);
42
+ }
43
+ return ret[0] >>> 0;
44
+ }
45
+ /**
46
+ * Whether a cell is bold.
47
+ *
48
+ * The one flag, without building the rest of the style: a parser that
49
+ * looks for a header row asks this of every cell, and `cellStyle` would
50
+ * make it pay for the font, fill and four borders it never reads.
51
+ * @param {number} sheet
52
+ * @param {string} address
53
+ * @returns {boolean}
54
+ */
55
+ cellBold(sheet, address) {
56
+ const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
57
+ const len0 = WASM_VECTOR_LEN;
58
+ const ret = wasm.book_cellBold(this.__wbg_ptr, sheet, ptr0, len0);
59
+ if (ret[2]) {
60
+ throw takeFromExternrefTable0(ret[1]);
61
+ }
62
+ return ret[0] !== 0;
63
+ }
64
+ /**
65
+ * The same by 1-based row and column.
66
+ * @param {number} sheet
67
+ * @param {number} row
68
+ * @param {number} column
69
+ * @returns {boolean}
70
+ */
71
+ cellBoldAt(sheet, row, column) {
72
+ const ret = wasm.book_cellBoldAt(this.__wbg_ptr, sheet, row, column);
73
+ if (ret[2]) {
74
+ throw takeFromExternrefTable0(ret[1]);
75
+ }
76
+ return ret[0] !== 0;
77
+ }
78
+ /**
79
+ * How many non-empty cells the workbook holds, or one sheet of it.
80
+ * @param {number | null} [sheet]
81
+ * @returns {number}
82
+ */
83
+ cellCount(sheet) {
84
+ const ret = wasm.book_cellCount(this.__wbg_ptr, isLikeNone(sheet) ? Number.MAX_SAFE_INTEGER : (sheet) >>> 0);
85
+ return ret >>> 0;
86
+ }
87
+ /**
88
+ * The indent of a cell, in Excel's indent steps (0 when it has none).
89
+ *
90
+ * Indent lives on the cell's style, and a spreadsheet only honours it for
91
+ * left, right and distributed alignment - but the number is returned as
92
+ * the file states it, whatever the alignment.
93
+ * @param {number} sheet
94
+ * @param {string} address
95
+ * @returns {number}
96
+ */
97
+ cellIndent(sheet, address) {
98
+ const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
99
+ const len0 = WASM_VECTOR_LEN;
100
+ const ret = wasm.book_cellIndent(this.__wbg_ptr, sheet, ptr0, len0);
101
+ if (ret[2]) {
102
+ throw takeFromExternrefTable0(ret[1]);
103
+ }
104
+ return ret[0] >>> 0;
105
+ }
106
+ /**
107
+ * The same by 1-based row and column.
108
+ * @param {number} sheet
109
+ * @param {number} row
110
+ * @param {number} column
111
+ * @returns {number}
112
+ */
113
+ cellIndentAt(sheet, row, column) {
114
+ const ret = wasm.book_cellIndentAt(this.__wbg_ptr, sheet, row, column);
115
+ if (ret[2]) {
116
+ throw takeFromExternrefTable0(ret[1]);
117
+ }
118
+ return ret[0] >>> 0;
119
+ }
120
+ /**
121
+ * How a cell is painted: number format, font, fill, borders and text
122
+ * placement, as the file states them.
123
+ *
124
+ * A cell the file says nothing about answers with Excel's defaults, which
125
+ * is what Excel itself shows for it.
126
+ * @param {number} sheet
127
+ * @param {string} address
128
+ * @returns {CellStyle}
129
+ */
130
+ cellStyle(sheet, address) {
131
+ const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
132
+ const len0 = WASM_VECTOR_LEN;
133
+ const ret = wasm.book_cellStyle(this.__wbg_ptr, sheet, ptr0, len0);
134
+ if (ret[2]) {
135
+ throw takeFromExternrefTable0(ret[1]);
136
+ }
137
+ return takeFromExternrefTable0(ret[0]);
138
+ }
139
+ /**
140
+ * The same by 1-based row and column.
141
+ * @param {number} sheet
142
+ * @param {number} row
143
+ * @param {number} column
144
+ * @returns {CellStyle}
145
+ */
146
+ cellStyleAt(sheet, row, column) {
147
+ const ret = wasm.book_cellStyleAt(this.__wbg_ptr, sheet, row, column);
148
+ if (ret[2]) {
149
+ throw takeFromExternrefTable0(ret[1]);
150
+ }
151
+ return takeFromExternrefTable0(ret[0]);
152
+ }
153
+ /**
154
+ * Empties a cell, style and all.
155
+ * @param {number} sheet
156
+ * @param {string} address
157
+ */
158
+ clear(sheet, address) {
159
+ const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
160
+ const len0 = WASM_VECTOR_LEN;
161
+ const ret = wasm.book_clear(this.__wbg_ptr, sheet, ptr0, len0);
162
+ if (ret[1]) {
163
+ throw takeFromExternrefTable0(ret[0]);
164
+ }
165
+ }
166
+ /**
167
+ * The same by 1-based row and column.
168
+ * @param {number} sheet
169
+ * @param {number} row
170
+ * @param {number} column
171
+ */
172
+ clearAt(sheet, row, column) {
173
+ const ret = wasm.book_clearAt(this.__wbg_ptr, sheet, row, column);
174
+ if (ret[1]) {
175
+ throw takeFromExternrefTable0(ret[0]);
176
+ }
177
+ }
178
+ /**
179
+ * The same for a column, named by its letters: `columnLevel(0, "C")`.
180
+ * @param {number} sheet
181
+ * @param {string} column
182
+ * @returns {number}
183
+ */
184
+ columnLevel(sheet, column) {
185
+ const ptr0 = passStringToWasm0(column, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
186
+ const len0 = WASM_VECTOR_LEN;
187
+ const ret = wasm.book_columnLevel(this.__wbg_ptr, sheet, ptr0, len0);
188
+ if (ret[2]) {
189
+ throw takeFromExternrefTable0(ret[1]);
190
+ }
191
+ return ret[0];
192
+ }
193
+ /**
194
+ * Reads an xlsx package from its bytes.
195
+ * @param {Uint8Array} bytes
196
+ * @returns {Book}
197
+ */
198
+ static fromXlsx(bytes) {
199
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
200
+ const len0 = WASM_VECTOR_LEN;
201
+ const ret = wasm.book_fromXlsx(ptr0, len0);
202
+ if (ret[2]) {
203
+ throw takeFromExternrefTable0(ret[1]);
204
+ }
205
+ return Book.__wrap(ret[0]);
206
+ }
207
+ /**
208
+ * The value at `address` on sheet `sheet`, as a JS number, string, boolean
209
+ * or `null`. A formula cell gives its cached result, not its text.
210
+ * @param {number} sheet
211
+ * @param {string} address
212
+ * @returns {CellValue}
213
+ */
214
+ get(sheet, address) {
215
+ const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
216
+ const len0 = WASM_VECTOR_LEN;
217
+ const ret = wasm.book_get(this.__wbg_ptr, sheet, ptr0, len0);
218
+ if (ret[2]) {
219
+ throw takeFromExternrefTable0(ret[1]);
220
+ }
221
+ return takeFromExternrefTable0(ret[0]);
222
+ }
223
+ /**
224
+ * The same by 1-based row and column, the numbers `ROW()` and `COLUMN()`
225
+ * return: `getAt(0, 4, 2)` is `B4`. Saves formatting an address only to
226
+ * parse it again.
227
+ * @param {number} sheet
228
+ * @param {number} row
229
+ * @param {number} column
230
+ * @returns {CellValue}
231
+ */
232
+ getAt(sheet, row, column) {
233
+ const ret = wasm.book_getAt(this.__wbg_ptr, sheet, row, column);
234
+ if (ret[2]) {
235
+ throw takeFromExternrefTable0(ret[1]);
236
+ }
237
+ return takeFromExternrefTable0(ret[0]);
238
+ }
239
+ /**
240
+ * The cell as a spreadsheet would display it: the value run through its
241
+ * number format, so `0.256` under `0.0%` reads `25.6%`.
242
+ * @param {number} sheet
243
+ * @param {string} address
244
+ * @returns {string}
245
+ */
246
+ getFormatted(sheet, address) {
247
+ let deferred3_0;
248
+ let deferred3_1;
249
+ try {
250
+ const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
251
+ const len0 = WASM_VECTOR_LEN;
252
+ const ret = wasm.book_getFormatted(this.__wbg_ptr, sheet, ptr0, len0);
253
+ var ptr2 = ret[0];
254
+ var len2 = ret[1];
255
+ if (ret[3]) {
256
+ ptr2 = 0; len2 = 0;
257
+ throw takeFromExternrefTable0(ret[2]);
258
+ }
259
+ deferred3_0 = ptr2;
260
+ deferred3_1 = len2;
261
+ return getStringFromWasm0(ptr2, len2);
262
+ } finally {
263
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
264
+ }
265
+ }
266
+ /**
267
+ * The same by 1-based row and column.
268
+ * @param {number} sheet
269
+ * @param {number} row
270
+ * @param {number} column
271
+ * @returns {string}
272
+ */
273
+ getFormattedAt(sheet, row, column) {
274
+ let deferred2_0;
275
+ let deferred2_1;
276
+ try {
277
+ const ret = wasm.book_getFormattedAt(this.__wbg_ptr, sheet, row, column);
278
+ var ptr1 = ret[0];
279
+ var len1 = ret[1];
280
+ if (ret[3]) {
281
+ ptr1 = 0; len1 = 0;
282
+ throw takeFromExternrefTable0(ret[2]);
283
+ }
284
+ deferred2_0 = ptr1;
285
+ deferred2_1 = len1;
286
+ return getStringFromWasm0(ptr1, len1);
287
+ } finally {
288
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
289
+ }
290
+ }
291
+ /**
292
+ * The formula text of a cell without its leading `=`, or `undefined` when
293
+ * the cell holds a plain value.
294
+ * @param {number} sheet
295
+ * @param {string} address
296
+ * @returns {string | undefined}
297
+ */
298
+ getFormula(sheet, address) {
299
+ const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
300
+ const len0 = WASM_VECTOR_LEN;
301
+ const ret = wasm.book_getFormula(this.__wbg_ptr, sheet, ptr0, len0);
302
+ let v2;
303
+ if (ret[0] !== 0) {
304
+ v2 = getStringFromWasm0(ret[0], ret[1]);
305
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
306
+ }
307
+ return v2;
308
+ }
309
+ /**
310
+ * The same by 1-based row and column.
311
+ * @param {number} sheet
312
+ * @param {number} row
313
+ * @param {number} column
314
+ * @returns {string | undefined}
315
+ */
316
+ getFormulaAt(sheet, row, column) {
317
+ const ret = wasm.book_getFormulaAt(this.__wbg_ptr, sheet, row, column);
318
+ let v1;
319
+ if (ret[0] !== 0) {
320
+ v1 = getStringFromWasm0(ret[0], ret[1]);
321
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
322
+ }
323
+ return v1;
324
+ }
325
+ /**
326
+ * A rectangle of cells, row by row. One call across the boundary instead
327
+ * of one per cell, which is what makes reading a sheet worth doing.
328
+ * @param {number} sheet
329
+ * @param {string} range
330
+ * @returns {CellGrid}
331
+ */
332
+ getRange(sheet, range) {
333
+ const ptr0 = passStringToWasm0(range, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
334
+ const len0 = WASM_VECTOR_LEN;
335
+ const ret = wasm.book_getRange(this.__wbg_ptr, sheet, ptr0, len0);
336
+ if (ret[2]) {
337
+ throw takeFromExternrefTable0(ret[1]);
338
+ }
339
+ return takeFromExternrefTable0(ret[0]);
340
+ }
341
+ /**
342
+ * The same by numbers: the top-left cell, then how many rows and columns
343
+ * to take. `getRangeAt(0, 1, 1, 3, 2)` is `A1:B3`.
344
+ * @param {number} sheet
345
+ * @param {number} row
346
+ * @param {number} column
347
+ * @param {number} rows
348
+ * @param {number} columns
349
+ * @returns {CellGrid}
350
+ */
351
+ getRangeAt(sheet, row, column, rows, columns) {
352
+ const ret = wasm.book_getRangeAt(this.__wbg_ptr, sheet, row, column, rows, columns);
353
+ if (ret[2]) {
354
+ throw takeFromExternrefTable0(ret[1]);
355
+ }
356
+ return takeFromExternrefTable0(ret[0]);
357
+ }
358
+ /**
359
+ * A whole row in one crossing of the boundary: values, displayed text,
360
+ * bold and indent, plus whether the row is hidden.
361
+ *
362
+ * The arrays run from column 1 to the last column this row has a cell in,
363
+ * so a row of ten cells costs one call rather than forty.
364
+ *
365
+ * `formatted` is what the number format makes of each value, and building
366
+ * it allocates a string per cell - which a caller reading values does not
367
+ * want to pay half a sheet over. Pass `false` and the field comes back
368
+ * `null`; `getFormattedAt` still answers for the cells that need it.
369
+ * @param {number} sheet
370
+ * @param {number} row
371
+ * @param {boolean | null} [formatted]
372
+ * @returns {SheetRow}
373
+ */
374
+ getRowAt(sheet, row, formatted) {
375
+ const ret = wasm.book_getRowAt(this.__wbg_ptr, sheet, row, isLikeNone(formatted) ? 0xFFFFFF : formatted ? 1 : 0);
376
+ if (ret[2]) {
377
+ throw takeFromExternrefTable0(ret[1]);
378
+ }
379
+ return takeFromExternrefTable0(ret[0]);
380
+ }
381
+ /**
382
+ * The merged areas of a sheet, as `"A1:C1"` strings in the order the file
383
+ * lists them.
384
+ * @param {number} sheet
385
+ * @returns {string[]}
386
+ */
387
+ mergedRanges(sheet) {
388
+ const ret = wasm.book_mergedRanges(this.__wbg_ptr, sheet);
389
+ if (ret[3]) {
390
+ throw takeFromExternrefTable0(ret[2]);
391
+ }
392
+ var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]);
393
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
394
+ return v1;
395
+ }
396
+ /**
397
+ * The merged areas of a sheet as numbers: four per area, `[r1, c1, r2,
398
+ * c2]`, rows and columns 1-based.
399
+ *
400
+ * One typed array instead of a JS string per area, which is what a sheet
401
+ * carrying three hundred thousand of them needs.
402
+ * @param {number} sheet
403
+ * @returns {Uint32Array}
404
+ */
405
+ mergedRangesAt(sheet) {
406
+ const ret = wasm.book_mergedRangesAt(this.__wbg_ptr, sheet);
407
+ if (ret[2]) {
408
+ throw takeFromExternrefTable0(ret[1]);
409
+ }
410
+ return takeFromExternrefTable0(ret[0]);
411
+ }
412
+ /**
413
+ * A new workbook with one empty sheet.
414
+ */
415
+ constructor() {
416
+ const ret = wasm.book_new();
417
+ this.__wbg_ptr = ret;
418
+ BookFinalization.register(this, this.__wbg_ptr, this);
419
+ return this;
420
+ }
421
+ /**
422
+ * Reads a workbook of any format this crate supports, working the format
423
+ * out from the bytes themselves.
424
+ *
425
+ * `name` is the file name they came from, if the caller has one: it
426
+ * settles what the bytes cannot say (a `.csv` against a `.html`) and names
427
+ * the sheet of a SYLK file.
428
+ * @param {Uint8Array} bytes
429
+ * @param {string | null} [name]
430
+ * @param {number | null} [max_expanded]
431
+ * @param {Function | null} [on_progress]
432
+ * @returns {Book}
433
+ */
434
+ static read(bytes, name, max_expanded, on_progress) {
435
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
436
+ const len0 = WASM_VECTOR_LEN;
437
+ var ptr1 = isLikeNone(name) ? 0 : passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
438
+ var len1 = WASM_VECTOR_LEN;
439
+ const ret = wasm.book_read(ptr0, len0, ptr1, len1, !isLikeNone(max_expanded), isLikeNone(max_expanded) ? 0 : max_expanded, isLikeNone(on_progress) ? 0 : addToExternrefTable0(on_progress));
440
+ if (ret[2]) {
441
+ throw takeFromExternrefTable0(ret[1]);
442
+ }
443
+ return Book.__wrap(ret[0]);
444
+ }
445
+ /**
446
+ * Renames a sheet.
447
+ * @param {number} sheet
448
+ * @param {string} title
449
+ */
450
+ renameSheet(sheet, title) {
451
+ const ptr0 = passStringToWasm0(title, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
452
+ const len0 = WASM_VECTOR_LEN;
453
+ const ret = wasm.book_renameSheet(this.__wbg_ptr, sheet, ptr0, len0);
454
+ if (ret[1]) {
455
+ throw takeFromExternrefTable0(ret[0]);
456
+ }
457
+ }
458
+ /**
459
+ * Whether a row is hidden. `row` is the number a user sees.
460
+ * @param {number} sheet
461
+ * @param {number} row
462
+ * @returns {boolean}
463
+ */
464
+ rowHidden(sheet, row) {
465
+ const ret = wasm.book_rowHidden(this.__wbg_ptr, sheet, row);
466
+ if (ret[2]) {
467
+ throw takeFromExternrefTable0(ret[1]);
468
+ }
469
+ return ret[0] !== 0;
470
+ }
471
+ /**
472
+ * How deeply a row is grouped: 0 when it is not, 1 for the outermost
473
+ * group, and so on. `row` is the number a user sees.
474
+ * @param {number} sheet
475
+ * @param {number} row
476
+ * @returns {number}
477
+ */
478
+ rowLevel(sheet, row) {
479
+ const ret = wasm.book_rowLevel(this.__wbg_ptr, sheet, row);
480
+ if (ret[2]) {
481
+ throw takeFromExternrefTable0(ret[1]);
482
+ }
483
+ return ret[0];
484
+ }
485
+ /**
486
+ * Writes a value: a number, boolean, or string. A string starting with `=`
487
+ * becomes a formula.
488
+ * @param {number} index
489
+ * @param {string} address
490
+ * @param {CellValue} value
491
+ */
492
+ set(index, address, value) {
493
+ const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
494
+ const len0 = WASM_VECTOR_LEN;
495
+ const ret = wasm.book_set(this.__wbg_ptr, index, ptr0, len0, value);
496
+ if (ret[1]) {
497
+ throw takeFromExternrefTable0(ret[0]);
498
+ }
499
+ }
500
+ /**
501
+ * Sets that tab.
502
+ * @param {number} sheet
503
+ */
504
+ setActiveSheet(sheet) {
505
+ const ret = wasm.book_setActiveSheet(this.__wbg_ptr, sheet);
506
+ if (ret[1]) {
507
+ throw takeFromExternrefTable0(ret[0]);
508
+ }
509
+ }
510
+ /**
511
+ * The same by 1-based row and column.
512
+ * @param {number} sheet
513
+ * @param {number} row
514
+ * @param {number} column
515
+ * @param {CellValue} value
516
+ */
517
+ setAt(sheet, row, column, value) {
518
+ const ret = wasm.book_setAt(this.__wbg_ptr, sheet, row, column, value);
519
+ if (ret[1]) {
520
+ throw takeFromExternrefTable0(ret[0]);
521
+ }
522
+ }
523
+ /**
524
+ * Writes a rectangle of values with `at` as its top-left corner. Rows may
525
+ * differ in length; a `null` leaves its cell empty.
526
+ * @param {number} sheet
527
+ * @param {string} at
528
+ * @param {CellGrid} values
529
+ */
530
+ setRange(sheet, at, values) {
531
+ const ptr0 = passStringToWasm0(at, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
532
+ const len0 = WASM_VECTOR_LEN;
533
+ const ret = wasm.book_setRange(this.__wbg_ptr, sheet, ptr0, len0, values);
534
+ if (ret[1]) {
535
+ throw takeFromExternrefTable0(ret[0]);
536
+ }
537
+ }
538
+ /**
539
+ * The same with the corner given as 1-based row and column.
540
+ * @param {number} sheet
541
+ * @param {number} row
542
+ * @param {number} column
543
+ * @param {CellGrid} values
544
+ */
545
+ setRangeAt(sheet, row, column, values) {
546
+ const ret = wasm.book_setRangeAt(this.__wbg_ptr, sheet, row, column, values);
547
+ if (ret[1]) {
548
+ throw takeFromExternrefTable0(ret[0]);
549
+ }
550
+ }
551
+ /**
552
+ * The tab index of a sheet by name, or `undefined` when there is none.
553
+ * Names are compared the way Excel does, ignoring case.
554
+ * @param {string} name
555
+ * @returns {number | undefined}
556
+ */
557
+ sheetIndex(name) {
558
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
559
+ const len0 = WASM_VECTOR_LEN;
560
+ const ret = wasm.book_sheetIndex(this.__wbg_ptr, ptr0, len0);
561
+ return ret === Number.MAX_SAFE_INTEGER ? undefined : ret;
562
+ }
563
+ /**
564
+ * Sheet titles, in tab order.
565
+ * @returns {string[]}
566
+ */
567
+ sheetNames() {
568
+ const ret = wasm.book_sheetNames(this.__wbg_ptr);
569
+ var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]);
570
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
571
+ return v1;
572
+ }
573
+ /**
574
+ * Whether a sheet has a tab: `"visible"`, `"hidden"` or `"veryHidden"`.
575
+ *
576
+ * `sheetNames` lists every sheet, hidden ones included, because that is
577
+ * what the index of every other call counts.
578
+ * @param {number} sheet
579
+ * @returns {string}
580
+ */
581
+ sheetVisibility(sheet) {
582
+ let deferred2_0;
583
+ let deferred2_1;
584
+ try {
585
+ const ret = wasm.book_sheetVisibility(this.__wbg_ptr, sheet);
586
+ var ptr1 = ret[0];
587
+ var len1 = ret[1];
588
+ if (ret[3]) {
589
+ ptr1 = 0; len1 = 0;
590
+ throw takeFromExternrefTable0(ret[2]);
591
+ }
592
+ deferred2_0 = ptr1;
593
+ deferred2_1 = len1;
594
+ return getStringFromWasm0(ptr1, len1);
595
+ } finally {
596
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
597
+ }
598
+ }
599
+ /**
600
+ * The used range of a sheet as `A1:D9`, or `undefined` if it holds
601
+ * nothing. This is the rectangle to walk; the sheet itself is sparse.
602
+ * @param {number} sheet
603
+ * @returns {string | undefined}
604
+ */
605
+ usedRange(sheet) {
606
+ const ret = wasm.book_usedRange(this.__wbg_ptr, sheet);
607
+ let v1;
608
+ if (ret[0] !== 0) {
609
+ v1 = getStringFromWasm0(ret[0], ret[1]);
610
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
611
+ }
612
+ return v1;
613
+ }
614
+ }
615
+ if (Symbol.dispose) Book.prototype[Symbol.dispose] = Book.prototype.free;
616
+ exports.Book = Book;
617
+ function __wbg_get_imports() {
618
+ const import0 = {
619
+ __proto__: null,
620
+ __wbg_Error_408e67f47ca7b58b: function(arg0, arg1) {
621
+ const ret = Error(getStringFromWasm0(arg0, arg1));
622
+ return ret;
623
+ },
624
+ __wbg___wbindgen_boolean_get_c9c83ebd41b34df3: function(arg0) {
625
+ const v = arg0;
626
+ const ret = typeof(v) === 'boolean' ? v : undefined;
627
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
628
+ },
629
+ __wbg___wbindgen_is_null_7d13f41e1a2d5140: function(arg0) {
630
+ const ret = arg0 === null;
631
+ return ret;
632
+ },
633
+ __wbg___wbindgen_is_undefined_6cff064c44e0d823: function(arg0) {
634
+ const ret = arg0 === undefined;
635
+ return ret;
636
+ },
637
+ __wbg___wbindgen_number_get_136b9679cab35cfb: function(arg0, arg1) {
638
+ const obj = arg1;
639
+ const ret = typeof(obj) === 'number' ? obj : undefined;
640
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
641
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
642
+ },
643
+ __wbg___wbindgen_string_get_d154f1e671052120: function(arg0, arg1) {
644
+ const obj = arg1;
645
+ const ret = typeof(obj) === 'string' ? obj : undefined;
646
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
647
+ var len1 = WASM_VECTOR_LEN;
648
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
649
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
650
+ },
651
+ __wbg___wbindgen_throw_bb96b2010945f0bc: function(arg0, arg1) {
652
+ throw new Error(getStringFromWasm0(arg0, arg1));
653
+ },
654
+ __wbg_call_35dba3c747ad7521: function() { return handleError(function (arg0, arg1, arg2) {
655
+ const ret = arg0.call(arg1, arg2);
656
+ return ret;
657
+ }, arguments); },
658
+ __wbg_get_unchecked_e20b893aeafc3fca: function(arg0, arg1) {
659
+ const ret = arg0[arg1 >>> 0];
660
+ return ret;
661
+ },
662
+ __wbg_isArray_6339f732981044bf: function(arg0) {
663
+ const ret = Array.isArray(arg0);
664
+ return ret;
665
+ },
666
+ __wbg_length_ecfa2c63d3d0d82c: function(arg0) {
667
+ const ret = arg0.length;
668
+ return ret;
669
+ },
670
+ __wbg_new_116be93542d39019: function() {
671
+ const ret = new Array();
672
+ return ret;
673
+ },
674
+ __wbg_new_ebe3e0f6837f0879: function() {
675
+ const ret = new Object();
676
+ return ret;
677
+ },
678
+ __wbg_new_from_slice_3eea173078478cfe: function(arg0, arg1) {
679
+ const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
680
+ return ret;
681
+ },
682
+ __wbg_new_from_slice_8aed4f0384605526: function(arg0, arg1) {
683
+ const ret = new Uint32Array(getArrayU32FromWasm0(arg0, arg1));
684
+ return ret;
685
+ },
686
+ __wbg_now_8b265300afd5f2b9: function() {
687
+ const ret = Date.now();
688
+ return ret;
689
+ },
690
+ __wbg_push_adb0107829f02d75: function(arg0, arg1) {
691
+ const ret = arg0.push(arg1);
692
+ return ret;
693
+ },
694
+ __wbg_set_8155bb79a948541b: function() { return handleError(function (arg0, arg1, arg2) {
695
+ const ret = Reflect.set(arg0, arg1, arg2);
696
+ return ret;
697
+ }, arguments); },
698
+ __wbindgen_cast_0000000000000001: function(arg0) {
699
+ // Cast intrinsic for `F64 -> Externref`.
700
+ const ret = arg0;
701
+ return ret;
702
+ },
703
+ __wbindgen_cast_0000000000000002: function(arg0, arg1) {
704
+ // Cast intrinsic for `Ref(String) -> Externref`.
705
+ const ret = getStringFromWasm0(arg0, arg1);
706
+ return ret;
707
+ },
708
+ __wbindgen_init_externref_table: function() {
709
+ const table = wasm.__wbindgen_externrefs;
710
+ const offset = table.grow(4);
711
+ table.set(0, undefined);
712
+ table.set(offset + 0, undefined);
713
+ table.set(offset + 1, null);
714
+ table.set(offset + 2, true);
715
+ table.set(offset + 3, false);
716
+ },
717
+ };
718
+ return {
719
+ __proto__: null,
720
+ "./excelerate_bg.js": import0,
721
+ };
722
+ }
723
+
724
+ const BookFinalization = (typeof FinalizationRegistry === 'undefined')
725
+ ? { register: () => {}, unregister: () => {} }
726
+ : new FinalizationRegistry(ptr => wasm.__wbg_book_free(ptr, 1));
727
+
728
+ function addToExternrefTable0(obj) {
729
+ const idx = wasm.__externref_table_alloc();
730
+ wasm.__wbindgen_externrefs.set(idx, obj);
731
+ return idx;
732
+ }
733
+
734
+ function getArrayJsValueFromWasm0(ptr, len) {
735
+ ptr = ptr >>> 0;
736
+ const mem = getDataViewMemory0();
737
+ const result = [];
738
+ for (let i = ptr; i < ptr + 4 * len; i += 4) {
739
+ result.push(wasm.__wbindgen_externrefs.get(mem.getUint32(i, true)));
740
+ }
741
+ wasm.__externref_drop_slice(ptr, len);
742
+ return result;
743
+ }
744
+
745
+ function getArrayU32FromWasm0(ptr, len) {
746
+ ptr = ptr >>> 0;
747
+ return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
748
+ }
749
+
750
+ function getArrayU8FromWasm0(ptr, len) {
751
+ ptr = ptr >>> 0;
752
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
753
+ }
754
+
755
+ let cachedDataViewMemory0 = null;
756
+ function getDataViewMemory0() {
757
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
758
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
759
+ }
760
+ return cachedDataViewMemory0;
761
+ }
762
+
763
+ function getStringFromWasm0(ptr, len) {
764
+ return decodeText(ptr >>> 0, len);
765
+ }
766
+
767
+ let cachedUint32ArrayMemory0 = null;
768
+ function getUint32ArrayMemory0() {
769
+ if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
770
+ cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
771
+ }
772
+ return cachedUint32ArrayMemory0;
773
+ }
774
+
775
+ let cachedUint8ArrayMemory0 = null;
776
+ function getUint8ArrayMemory0() {
777
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
778
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
779
+ }
780
+ return cachedUint8ArrayMemory0;
781
+ }
782
+
783
+ function handleError(f, args) {
784
+ try {
785
+ return f.apply(this, args);
786
+ } catch (e) {
787
+ const idx = addToExternrefTable0(e);
788
+ wasm.__wbindgen_exn_store(idx);
789
+ }
790
+ }
791
+
792
+ function isLikeNone(x) {
793
+ return x === undefined || x === null;
794
+ }
795
+
796
+ function passArray8ToWasm0(arg, malloc) {
797
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
798
+ getUint8ArrayMemory0().set(arg, ptr / 1);
799
+ WASM_VECTOR_LEN = arg.length;
800
+ return ptr;
801
+ }
802
+
803
+ function passStringToWasm0(arg, malloc, realloc) {
804
+ if (realloc === undefined) {
805
+ const buf = cachedTextEncoder.encode(arg);
806
+ const ptr = malloc(buf.length, 1) >>> 0;
807
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
808
+ WASM_VECTOR_LEN = buf.length;
809
+ return ptr;
810
+ }
811
+
812
+ let len = arg.length;
813
+ let ptr = malloc(len, 1) >>> 0;
814
+
815
+ const mem = getUint8ArrayMemory0();
816
+
817
+ let offset = 0;
818
+
819
+ for (; offset < len; offset++) {
820
+ const code = arg.charCodeAt(offset);
821
+ if (code > 0x7F) break;
822
+ mem[ptr + offset] = code;
823
+ }
824
+ if (offset !== len) {
825
+ if (offset !== 0) {
826
+ arg = arg.slice(offset);
827
+ }
828
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
829
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
830
+ const ret = cachedTextEncoder.encodeInto(arg, view);
831
+
832
+ offset += ret.written;
833
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
834
+ }
835
+
836
+ WASM_VECTOR_LEN = offset;
837
+ return ptr;
838
+ }
839
+
840
+ function takeFromExternrefTable0(idx) {
841
+ const value = wasm.__wbindgen_externrefs.get(idx);
842
+ wasm.__externref_table_dealloc(idx);
843
+ return value;
844
+ }
845
+
846
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
847
+ cachedTextDecoder.decode();
848
+ function decodeText(ptr, len) {
849
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
850
+ }
851
+
852
+ const cachedTextEncoder = new TextEncoder();
853
+
854
+ if (!('encodeInto' in cachedTextEncoder)) {
855
+ cachedTextEncoder.encodeInto = function (arg, view) {
856
+ const buf = cachedTextEncoder.encode(arg);
857
+ view.set(buf);
858
+ return {
859
+ read: arg.length,
860
+ written: buf.length
861
+ };
862
+ };
863
+ }
864
+
865
+ let WASM_VECTOR_LEN = 0;
866
+
867
+ const wasmPath = `${__dirname}/excelerate_bg.wasm`;
868
+ const wasmBytes = require('fs').readFileSync(wasmPath);
869
+ const wasmModule = new WebAssembly.Module(wasmBytes);
870
+ let wasmInstance = new WebAssembly.Instance(wasmModule, __wbg_get_imports());
871
+ let wasm = wasmInstance.exports;
872
+ wasm.__wbindgen_start();
Binary file
package/package.json ADDED
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "@rosperitus/excelerate-reader",
3
+ "description": "Read spreadsheets in the browser or Node: xlsx, xls, ods, csv, html, SYLK, Gnumeric and SpreadsheetML, with cell styles. Reading only.",
4
+ "version": "0.8.0",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/rosperitus/excelerate.git"
9
+ },
10
+ "files": [
11
+ "excelerate_bg.wasm",
12
+ "excelerate.js",
13
+ "excelerate.d.ts"
14
+ ],
15
+ "main": "excelerate.js",
16
+ "homepage": "https://github.com/rosperitus/excelerate#readme",
17
+ "types": "excelerate.d.ts",
18
+ "keywords": [
19
+ "xlsx",
20
+ "xls",
21
+ "ods",
22
+ "csv",
23
+ "spreadsheet",
24
+ "excel",
25
+ "reader"
26
+ ],
27
+ "publishConfig": {
28
+ "access": "public"
29
+ },
30
+ "bugs": {
31
+ "url": "https://github.com/rosperitus/excelerate/issues"
32
+ }
33
+ }