@rosperitus/excelerate-reader 0.11.0 → 0.12.3
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 +33 -1
- package/excelerate.d.ts +237 -0
- package/excelerate.js +341 -0
- package/excelerate_bg.wasm +0 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -56,6 +56,35 @@ book.sheetVisibility(0); // "visible" | "hidden" | "veryHidden"
|
|
|
56
56
|
call takes is the sheet's position in the workbook, and skipping the hidden
|
|
57
57
|
ones would shift it.
|
|
58
58
|
|
|
59
|
+
`usedRangeHint` answers the same question as `usedRange` without ever walking
|
|
60
|
+
the rows (`usedRange` walks them only after a cell in an edge column was
|
|
61
|
+
removed, and the hint may then be wider), and `columnWidth`
|
|
62
|
+
and `rowHeight` come back `undefined` where the sheet leaves them to the
|
|
63
|
+
default.
|
|
64
|
+
|
|
65
|
+
## What is on a sheet besides cells
|
|
66
|
+
|
|
67
|
+
```js
|
|
68
|
+
book.comments(0); // [{ address: "B2", author: "Иванов", text: "сверить" }]
|
|
69
|
+
book.hyperlinks(0); // [{ range, target, external, display, tooltip }]
|
|
70
|
+
book.tables(0); // [{ name, displayName, range, columns, ... }]
|
|
71
|
+
book.charts(0); // [{ name, title, kinds: ["barChart"], seriesCount, anchor }]
|
|
72
|
+
book.images(0); // [{ name, format, byteLength, anchor }] - no bytes
|
|
73
|
+
book.imageData(0, 0); // Uint8Array, the picture itself
|
|
74
|
+
book.shapes(0); // [{ name, geometry, text, anchor }]
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
An anchor is where the object sits, in the numbers a user sees:
|
|
78
|
+
`{ kind: "twoCell", row: 3, column: 2 }`. An absolute anchor is at a point on
|
|
79
|
+
the sheet rather than at a cell, so its row and column are `null`.
|
|
80
|
+
|
|
81
|
+
Beyond the cells, a file states rules and names, and those are here too:
|
|
82
|
+
`definedNames()`, `dataValidations(sheet)`, `conditionalFormats(sheet)`,
|
|
83
|
+
`autoFilter(sheet)`, `pivotTables(sheet)`, `arrayFormulas(sheet)`,
|
|
84
|
+
`externalBooks()`, `sheetView(sheet)` (frozen rows and columns, zoom, grid
|
|
85
|
+
lines) and `sheetProtection(sheet)` with `verifySheetPassword`. `Book.readCsv`
|
|
86
|
+
reads CSV with the delimiter stated rather than guessed.
|
|
87
|
+
|
|
59
88
|
## Styles
|
|
60
89
|
|
|
61
90
|
`cellStyle` answers with the number format, font, fill, borders and text
|
|
@@ -100,7 +129,10 @@ unusual - so raise it when you know where the file came from.
|
|
|
100
129
|
|
|
101
130
|
## What is not here
|
|
102
131
|
|
|
103
|
-
Writing, in any format
|
|
132
|
+
Writing, in any format - including painting a cell, writing a note, a link or
|
|
133
|
+
a table. Recalculation. Editing the grid - inserting and
|
|
134
|
+
removing rows, columns and sheets - which only makes sense when the result can
|
|
135
|
+
be saved. Everything else the full package can do
|
|
104
136
|
with a workbook once it is open - the reading side of it - is.
|
|
105
137
|
|
|
106
138
|
MIT.
|
package/excelerate.d.ts
CHANGED
|
@@ -16,6 +16,109 @@ export interface SheetRow {
|
|
|
16
16
|
indent: Uint32Array;
|
|
17
17
|
hidden: boolean;
|
|
18
18
|
}
|
|
19
|
+
/** Where a drawing object sits, in the 1-based numbers a user sees. */
|
|
20
|
+
export interface ObjectAnchor {
|
|
21
|
+
kind: "twoCell" | "oneCell" | "absolute";
|
|
22
|
+
row: number | null;
|
|
23
|
+
column: number | null;
|
|
24
|
+
}
|
|
25
|
+
/** How a sheet is frozen and shown, as `sheetView` returns it. */
|
|
26
|
+
export interface SheetViewInfo {
|
|
27
|
+
frozenRows: number;
|
|
28
|
+
frozenColumns: number;
|
|
29
|
+
zoom: number | null;
|
|
30
|
+
showGridLines: boolean;
|
|
31
|
+
showRowColHeaders: boolean;
|
|
32
|
+
rightToLeft: boolean;
|
|
33
|
+
topLeftCell: string | null;
|
|
34
|
+
}
|
|
35
|
+
/** A name that stands for a formula, as `definedNames` returns it. */
|
|
36
|
+
export interface WorkbookName {
|
|
37
|
+
name: string;
|
|
38
|
+
formula: string;
|
|
39
|
+
sheet: number | null;
|
|
40
|
+
hidden: boolean;
|
|
41
|
+
}
|
|
42
|
+
/** A rule limiting what a cell accepts, as `dataValidations` returns it. */
|
|
43
|
+
export interface SheetValidation {
|
|
44
|
+
sqref: string[];
|
|
45
|
+
type: string;
|
|
46
|
+
operator: string;
|
|
47
|
+
formula1: string;
|
|
48
|
+
formula2: string;
|
|
49
|
+
allowBlank: boolean;
|
|
50
|
+
showDropDown: boolean;
|
|
51
|
+
}
|
|
52
|
+
/** One conditional formatting block, as `conditionalFormats` returns it. */
|
|
53
|
+
export interface SheetConditionalFormat {
|
|
54
|
+
sqref: string[];
|
|
55
|
+
rules: { type: string; priority: number; operator: string | null; formulas: string[]; text: string | null }[];
|
|
56
|
+
}
|
|
57
|
+
/** The autofilter over a range, as `autoFilter` returns it. */
|
|
58
|
+
export interface SheetAutoFilter {
|
|
59
|
+
range: string;
|
|
60
|
+
columns: { colId: number; kind: "values" | "custom" | "dynamic" | "top10" | "none" }[];
|
|
61
|
+
}
|
|
62
|
+
/** A pivot report on the sheet, as `pivotTables` returns it. */
|
|
63
|
+
export interface SheetPivotTable {
|
|
64
|
+
name: string;
|
|
65
|
+
location: string | null;
|
|
66
|
+
cacheId: number;
|
|
67
|
+
rowFields: number;
|
|
68
|
+
columnFields: number;
|
|
69
|
+
valueFields: number;
|
|
70
|
+
}
|
|
71
|
+
/** How a sheet or the workbook is locked, as `sheetProtection` returns it. */
|
|
72
|
+
export interface ProtectionInfo { locked: boolean; hasPassword: boolean }
|
|
73
|
+
/** How `toCsv` writes, and how `Book.readCsv` reads. */
|
|
74
|
+
export interface CsvOptions {
|
|
75
|
+
delimiter?: string;
|
|
76
|
+
contiguous?: boolean;
|
|
77
|
+
preserveEmptyFields?: boolean;
|
|
78
|
+
}
|
|
79
|
+
/** A note on a cell, as `comments` returns it. */
|
|
80
|
+
export interface SheetComment { address: string; author: string; text: string }
|
|
81
|
+
/** A link over a cell or a block of them, as `hyperlinks` returns it. */
|
|
82
|
+
export interface SheetHyperlink {
|
|
83
|
+
range: string;
|
|
84
|
+
target: string;
|
|
85
|
+
external: boolean;
|
|
86
|
+
display: string | null;
|
|
87
|
+
tooltip: string | null;
|
|
88
|
+
}
|
|
89
|
+
/** A table over a block of cells, as `tables` returns it. */
|
|
90
|
+
export interface SheetTable {
|
|
91
|
+
name: string;
|
|
92
|
+
displayName: string;
|
|
93
|
+
range: string;
|
|
94
|
+
headerRowCount: number | null;
|
|
95
|
+
totalsRowCount: number | null;
|
|
96
|
+
columns: string[];
|
|
97
|
+
}
|
|
98
|
+
/** A chart on the sheet, as `charts` returns it. */
|
|
99
|
+
export interface SheetChart {
|
|
100
|
+
name: string;
|
|
101
|
+
title: string | null;
|
|
102
|
+
kinds: string[];
|
|
103
|
+
seriesCount: number;
|
|
104
|
+
anchor: ObjectAnchor;
|
|
105
|
+
}
|
|
106
|
+
/** A picture on the sheet, as `images` returns it. Bytes come from `imageData`. */
|
|
107
|
+
export interface SheetImage {
|
|
108
|
+
name: string;
|
|
109
|
+
description: string;
|
|
110
|
+
format: string;
|
|
111
|
+
byteLength: number;
|
|
112
|
+
anchor: ObjectAnchor;
|
|
113
|
+
}
|
|
114
|
+
/** A drawn shape, as `shapes` returns it. */
|
|
115
|
+
export interface SheetShape {
|
|
116
|
+
name: string;
|
|
117
|
+
description: string;
|
|
118
|
+
geometry: string | null;
|
|
119
|
+
text: string;
|
|
120
|
+
anchor: ObjectAnchor;
|
|
121
|
+
}
|
|
19
122
|
/**
|
|
20
123
|
* A colour as the file states it: `null` when the file leaves it to the
|
|
21
124
|
* reader, `#AARRGGBB` when it names one outright, and `indexed:N` or
|
|
@@ -53,6 +156,14 @@ export interface CellStyle {
|
|
|
53
156
|
textRotation: number;
|
|
54
157
|
};
|
|
55
158
|
}
|
|
159
|
+
/**
|
|
160
|
+
* The styles of a rectangle, as `getRangeStyles` returns them: each distinct
|
|
161
|
+
* style once in `styles`, and `grid` - row by row - pointing into it.
|
|
162
|
+
*/
|
|
163
|
+
export interface RangeStyles {
|
|
164
|
+
styles: CellStyle[];
|
|
165
|
+
grid: number[][];
|
|
166
|
+
}
|
|
56
167
|
|
|
57
168
|
|
|
58
169
|
|
|
@@ -70,6 +181,16 @@ export class Book {
|
|
|
70
181
|
* Appends a sheet and returns its index.
|
|
71
182
|
*/
|
|
72
183
|
addSheet(title: string): number;
|
|
184
|
+
/**
|
|
185
|
+
* The array formulas of a sheet, as the areas they cover: `["B2:B4"]`.
|
|
186
|
+
* The formula itself is on the top left cell of each.
|
|
187
|
+
*/
|
|
188
|
+
arrayFormulas(sheet: number): string[];
|
|
189
|
+
/**
|
|
190
|
+
* The autofilter over a sheet, or `undefined` when it has none. What the
|
|
191
|
+
* filter hides is a property of each row - see `rowHidden`.
|
|
192
|
+
*/
|
|
193
|
+
autoFilter(sheet: number): SheetAutoFilter | undefined;
|
|
73
194
|
/**
|
|
74
195
|
* Whether a cell is bold.
|
|
75
196
|
*
|
|
@@ -110,6 +231,11 @@ export class Book {
|
|
|
110
231
|
* The same by 1-based row and column.
|
|
111
232
|
*/
|
|
112
233
|
cellStyleAt(sheet: number, row: number, column: number): CellStyle;
|
|
234
|
+
/**
|
|
235
|
+
* The charts on a sheet. `kinds` names the plots drawn in each -
|
|
236
|
+
* `barChart`, `lineChart` - and a combination chart has more than one.
|
|
237
|
+
*/
|
|
238
|
+
charts(sheet: number): SheetChart[];
|
|
113
239
|
/**
|
|
114
240
|
* Empties a cell, style and all.
|
|
115
241
|
*/
|
|
@@ -122,6 +248,36 @@ export class Book {
|
|
|
122
248
|
* The same for a column, named by its letters: `columnLevel(0, "C")`.
|
|
123
249
|
*/
|
|
124
250
|
columnLevel(sheet: number, column: string): number;
|
|
251
|
+
/**
|
|
252
|
+
* The width of a column in characters, or `undefined` when the sheet
|
|
253
|
+
* leaves it to the default. `column` is 1-based.
|
|
254
|
+
*/
|
|
255
|
+
columnWidth(sheet: number, column: number): number | undefined;
|
|
256
|
+
/**
|
|
257
|
+
* The notes on a sheet, in address order.
|
|
258
|
+
*/
|
|
259
|
+
comments(sheet: number): SheetComment[];
|
|
260
|
+
/**
|
|
261
|
+
* The conditional formatting of a sheet, block by block. The formatting
|
|
262
|
+
* each rule applies is not modelled here - it lives in the workbook's
|
|
263
|
+
* differential styles - but what the rule tests is.
|
|
264
|
+
*/
|
|
265
|
+
conditionalFormats(sheet: number): SheetConditionalFormat[];
|
|
266
|
+
/**
|
|
267
|
+
* The rules limiting what cells accept: the dropdown lists, the ranges,
|
|
268
|
+
* the dates.
|
|
269
|
+
*/
|
|
270
|
+
dataValidations(sheet: number): SheetValidation[];
|
|
271
|
+
/**
|
|
272
|
+
* The names the workbook defines: what `=Total` and `Print_Area` stand
|
|
273
|
+
* for. `sheet` is set on a name local to one sheet.
|
|
274
|
+
*/
|
|
275
|
+
definedNames(): WorkbookName[];
|
|
276
|
+
/**
|
|
277
|
+
* The other workbooks this one reads, in the order `[1]Sheet1!A1` counts
|
|
278
|
+
* them. A path is `undefined` where the file does not name one.
|
|
279
|
+
*/
|
|
280
|
+
externalBooks(): any[];
|
|
125
281
|
/**
|
|
126
282
|
* Reads an xlsx package from its bytes.
|
|
127
283
|
*/
|
|
@@ -165,6 +321,17 @@ export class Book {
|
|
|
165
321
|
* to take. `getRangeAt(0, 1, 1, 3, 2)` is `A1:B3`.
|
|
166
322
|
*/
|
|
167
323
|
getRangeAt(sheet: number, row: number, column: number, rows: number, columns: number): CellGrid;
|
|
324
|
+
/**
|
|
325
|
+
* The styles of a rectangle in one call: each distinct style once, and a
|
|
326
|
+
* grid of indexes into them. `cellStyle` per cell costs a crossing and a
|
|
327
|
+
* whole style object per cell; a formatted table of ten thousand cells
|
|
328
|
+
* usually has a dozen styles.
|
|
329
|
+
*/
|
|
330
|
+
getRangeStyles(sheet: number, range: string): RangeStyles;
|
|
331
|
+
/**
|
|
332
|
+
* The same by numbers, as `getRangeAt` takes them.
|
|
333
|
+
*/
|
|
334
|
+
getRangeStylesAt(sheet: number, row: number, column: number, rows: number, columns: number): RangeStyles;
|
|
168
335
|
/**
|
|
169
336
|
* A whole row in one crossing of the boundary: values, displayed text,
|
|
170
337
|
* bold and indent, plus whether the row is hidden.
|
|
@@ -178,6 +345,20 @@ export class Book {
|
|
|
178
345
|
* `null`; `getFormattedAt` still answers for the cells that need it.
|
|
179
346
|
*/
|
|
180
347
|
getRowAt(sheet: number, row: number, formatted?: boolean | null): SheetRow;
|
|
348
|
+
/**
|
|
349
|
+
* The hyperlinks of a sheet. `external` tells a URL from a jump inside
|
|
350
|
+
* the workbook.
|
|
351
|
+
*/
|
|
352
|
+
hyperlinks(sheet: number): SheetHyperlink[];
|
|
353
|
+
/**
|
|
354
|
+
* The bytes of one picture, by its position in `images`.
|
|
355
|
+
*/
|
|
356
|
+
imageData(sheet: number, index: number): Uint8Array;
|
|
357
|
+
/**
|
|
358
|
+
* The pictures on a sheet, without their bytes: `imageData` fetches those
|
|
359
|
+
* for the one that is wanted.
|
|
360
|
+
*/
|
|
361
|
+
images(sheet: number): SheetImage[];
|
|
181
362
|
/**
|
|
182
363
|
* The merged areas of a sheet, as `"A1:C1"` strings in the order the file
|
|
183
364
|
* lists them.
|
|
@@ -195,6 +376,12 @@ export class Book {
|
|
|
195
376
|
* A new workbook with one empty sheet.
|
|
196
377
|
*/
|
|
197
378
|
constructor();
|
|
379
|
+
/**
|
|
380
|
+
* The pivot reports laid out on a sheet. The numbers they show are cells
|
|
381
|
+
* like any others; this says where a report sits and how wide its axes
|
|
382
|
+
* are.
|
|
383
|
+
*/
|
|
384
|
+
pivotTables(sheet: number): SheetPivotTable[];
|
|
198
385
|
/**
|
|
199
386
|
* Reads a workbook of any format this crate supports, working the format
|
|
200
387
|
* out from the bytes themselves.
|
|
@@ -204,10 +391,24 @@ export class Book {
|
|
|
204
391
|
* the sheet of a SYLK file.
|
|
205
392
|
*/
|
|
206
393
|
static read(bytes: Uint8Array, name?: string | null, max_expanded?: number | null, on_progress?: Function | null): Book;
|
|
394
|
+
/**
|
|
395
|
+
* Reads CSV with the guesses overridden: the delimiter, whether a row
|
|
396
|
+
* that produced no cell is skipped, whether an empty field becomes an
|
|
397
|
+
* empty string rather than no cell at all.
|
|
398
|
+
*
|
|
399
|
+
* `Book.read` guesses all of this from the bytes, which is right for a
|
|
400
|
+
* file of unknown origin; this is for one whose shape you already know.
|
|
401
|
+
*/
|
|
402
|
+
static readCsv(bytes: Uint8Array, options: CsvOptions): Book;
|
|
207
403
|
/**
|
|
208
404
|
* Renames a sheet.
|
|
209
405
|
*/
|
|
210
406
|
renameSheet(sheet: number, title: string): void;
|
|
407
|
+
/**
|
|
408
|
+
* The height of a row in points, or `undefined` when the sheet leaves it
|
|
409
|
+
* to the default. `row` is the number a user sees.
|
|
410
|
+
*/
|
|
411
|
+
rowHeight(sheet: number, row: number): number | undefined;
|
|
211
412
|
/**
|
|
212
413
|
* Whether a row is hidden. `row` is the number a user sees.
|
|
213
414
|
*/
|
|
@@ -239,6 +440,10 @@ export class Book {
|
|
|
239
440
|
* The same with the corner given as 1-based row and column.
|
|
240
441
|
*/
|
|
241
442
|
setRangeAt(sheet: number, row: number, column: number, values: CellGrid): void;
|
|
443
|
+
/**
|
|
444
|
+
* The drawn shapes of a sheet, text and all.
|
|
445
|
+
*/
|
|
446
|
+
shapes(sheet: number): SheetShape[];
|
|
242
447
|
/**
|
|
243
448
|
* The tab index of a sheet by name, or `undefined` when there is none.
|
|
244
449
|
* Names are compared the way Excel does, ignoring case.
|
|
@@ -248,6 +453,14 @@ export class Book {
|
|
|
248
453
|
* Sheet titles, in tab order.
|
|
249
454
|
*/
|
|
250
455
|
sheetNames(): string[];
|
|
456
|
+
/**
|
|
457
|
+
* Whether a sheet is locked, and whether the lock has a password.
|
|
458
|
+
*/
|
|
459
|
+
sheetProtection(sheet: number): ProtectionInfo;
|
|
460
|
+
/**
|
|
461
|
+
* How the sheet is frozen and shown.
|
|
462
|
+
*/
|
|
463
|
+
sheetView(sheet: number): SheetViewInfo;
|
|
251
464
|
/**
|
|
252
465
|
* Whether a sheet has a tab: `"visible"`, `"hidden"` or `"veryHidden"`.
|
|
253
466
|
*
|
|
@@ -255,9 +468,33 @@ export class Book {
|
|
|
255
468
|
* what the index of every other call counts.
|
|
256
469
|
*/
|
|
257
470
|
sheetVisibility(sheet: number): string;
|
|
471
|
+
/**
|
|
472
|
+
* The tables of a sheet: what a structured reference like `Sales[Amount]`
|
|
473
|
+
* names.
|
|
474
|
+
*/
|
|
475
|
+
tables(sheet: number): SheetTable[];
|
|
258
476
|
/**
|
|
259
477
|
* The used range of a sheet as `A1:D9`, or `undefined` if it holds
|
|
260
478
|
* nothing. This is the rectangle to walk; the sheet itself is sparse.
|
|
261
479
|
*/
|
|
262
480
|
usedRange(sheet: number): string | undefined;
|
|
481
|
+
/**
|
|
482
|
+
* The used range of a sheet as `"A1:D20"` without walking the rows;
|
|
483
|
+
* `undefined` for an empty sheet.
|
|
484
|
+
*
|
|
485
|
+
* Rows are exact, columns an upper bound: removing a cell never narrows
|
|
486
|
+
* them. `usedRange` answers the same until a cell in an edge column is
|
|
487
|
+
* removed, and walks the rows after that to give the exact rectangle.
|
|
488
|
+
*/
|
|
489
|
+
usedRangeHint(sheet: number): string | undefined;
|
|
490
|
+
/**
|
|
491
|
+
* Whether that password unlocks the sheet. `false` for a sheet with no
|
|
492
|
+
* password on it, and for a hash this crate cannot check.
|
|
493
|
+
*/
|
|
494
|
+
verifySheetPassword(sheet: number, password: string): boolean;
|
|
495
|
+
/**
|
|
496
|
+
* Whether the workbook's structure is locked, and whether behind a
|
|
497
|
+
* password.
|
|
498
|
+
*/
|
|
499
|
+
workbookProtection(): ProtectionInfo;
|
|
263
500
|
}
|
package/excelerate.js
CHANGED
|
@@ -42,6 +42,34 @@ class Book {
|
|
|
42
42
|
}
|
|
43
43
|
return ret[0] >>> 0;
|
|
44
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* The array formulas of a sheet, as the areas they cover: `["B2:B4"]`.
|
|
47
|
+
* The formula itself is on the top left cell of each.
|
|
48
|
+
* @param {number} sheet
|
|
49
|
+
* @returns {string[]}
|
|
50
|
+
*/
|
|
51
|
+
arrayFormulas(sheet) {
|
|
52
|
+
const ret = wasm.book_arrayFormulas(this.__wbg_ptr, sheet);
|
|
53
|
+
if (ret[3]) {
|
|
54
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
55
|
+
}
|
|
56
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]);
|
|
57
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
58
|
+
return v1;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* The autofilter over a sheet, or `undefined` when it has none. What the
|
|
62
|
+
* filter hides is a property of each row - see `rowHidden`.
|
|
63
|
+
* @param {number} sheet
|
|
64
|
+
* @returns {SheetAutoFilter | undefined}
|
|
65
|
+
*/
|
|
66
|
+
autoFilter(sheet) {
|
|
67
|
+
const ret = wasm.book_autoFilter(this.__wbg_ptr, sheet);
|
|
68
|
+
if (ret[2]) {
|
|
69
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
70
|
+
}
|
|
71
|
+
return takeFromExternrefTable0(ret[0]);
|
|
72
|
+
}
|
|
45
73
|
/**
|
|
46
74
|
* Whether a cell is bold.
|
|
47
75
|
*
|
|
@@ -150,6 +178,19 @@ class Book {
|
|
|
150
178
|
}
|
|
151
179
|
return takeFromExternrefTable0(ret[0]);
|
|
152
180
|
}
|
|
181
|
+
/**
|
|
182
|
+
* The charts on a sheet. `kinds` names the plots drawn in each -
|
|
183
|
+
* `barChart`, `lineChart` - and a combination chart has more than one.
|
|
184
|
+
* @param {number} sheet
|
|
185
|
+
* @returns {SheetChart[]}
|
|
186
|
+
*/
|
|
187
|
+
charts(sheet) {
|
|
188
|
+
const ret = wasm.book_charts(this.__wbg_ptr, sheet);
|
|
189
|
+
if (ret[2]) {
|
|
190
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
191
|
+
}
|
|
192
|
+
return takeFromExternrefTable0(ret[0]);
|
|
193
|
+
}
|
|
153
194
|
/**
|
|
154
195
|
* Empties a cell, style and all.
|
|
155
196
|
* @param {number} sheet
|
|
@@ -190,6 +231,79 @@ class Book {
|
|
|
190
231
|
}
|
|
191
232
|
return ret[0];
|
|
192
233
|
}
|
|
234
|
+
/**
|
|
235
|
+
* The width of a column in characters, or `undefined` when the sheet
|
|
236
|
+
* leaves it to the default. `column` is 1-based.
|
|
237
|
+
* @param {number} sheet
|
|
238
|
+
* @param {number} column
|
|
239
|
+
* @returns {number | undefined}
|
|
240
|
+
*/
|
|
241
|
+
columnWidth(sheet, column) {
|
|
242
|
+
const ret = wasm.book_columnWidth(this.__wbg_ptr, sheet, column);
|
|
243
|
+
if (ret[3]) {
|
|
244
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
245
|
+
}
|
|
246
|
+
return ret[0] === 0 ? undefined : ret[1];
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* The notes on a sheet, in address order.
|
|
250
|
+
* @param {number} sheet
|
|
251
|
+
* @returns {SheetComment[]}
|
|
252
|
+
*/
|
|
253
|
+
comments(sheet) {
|
|
254
|
+
const ret = wasm.book_comments(this.__wbg_ptr, sheet);
|
|
255
|
+
if (ret[2]) {
|
|
256
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
257
|
+
}
|
|
258
|
+
return takeFromExternrefTable0(ret[0]);
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* The conditional formatting of a sheet, block by block. The formatting
|
|
262
|
+
* each rule applies is not modelled here - it lives in the workbook's
|
|
263
|
+
* differential styles - but what the rule tests is.
|
|
264
|
+
* @param {number} sheet
|
|
265
|
+
* @returns {SheetConditionalFormat[]}
|
|
266
|
+
*/
|
|
267
|
+
conditionalFormats(sheet) {
|
|
268
|
+
const ret = wasm.book_conditionalFormats(this.__wbg_ptr, sheet);
|
|
269
|
+
if (ret[2]) {
|
|
270
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
271
|
+
}
|
|
272
|
+
return takeFromExternrefTable0(ret[0]);
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* The rules limiting what cells accept: the dropdown lists, the ranges,
|
|
276
|
+
* the dates.
|
|
277
|
+
* @param {number} sheet
|
|
278
|
+
* @returns {SheetValidation[]}
|
|
279
|
+
*/
|
|
280
|
+
dataValidations(sheet) {
|
|
281
|
+
const ret = wasm.book_dataValidations(this.__wbg_ptr, sheet);
|
|
282
|
+
if (ret[2]) {
|
|
283
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
284
|
+
}
|
|
285
|
+
return takeFromExternrefTable0(ret[0]);
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* The names the workbook defines: what `=Total` and `Print_Area` stand
|
|
289
|
+
* for. `sheet` is set on a name local to one sheet.
|
|
290
|
+
* @returns {WorkbookName[]}
|
|
291
|
+
*/
|
|
292
|
+
definedNames() {
|
|
293
|
+
const ret = wasm.book_definedNames(this.__wbg_ptr);
|
|
294
|
+
return ret;
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* The other workbooks this one reads, in the order `[1]Sheet1!A1` counts
|
|
298
|
+
* them. A path is `undefined` where the file does not name one.
|
|
299
|
+
* @returns {any[]}
|
|
300
|
+
*/
|
|
301
|
+
externalBooks() {
|
|
302
|
+
const ret = wasm.book_externalBooks(this.__wbg_ptr);
|
|
303
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]);
|
|
304
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
305
|
+
return v1;
|
|
306
|
+
}
|
|
193
307
|
/**
|
|
194
308
|
* Reads an xlsx package from its bytes.
|
|
195
309
|
* @param {Uint8Array} bytes
|
|
@@ -355,6 +469,40 @@ class Book {
|
|
|
355
469
|
}
|
|
356
470
|
return takeFromExternrefTable0(ret[0]);
|
|
357
471
|
}
|
|
472
|
+
/**
|
|
473
|
+
* The styles of a rectangle in one call: each distinct style once, and a
|
|
474
|
+
* grid of indexes into them. `cellStyle` per cell costs a crossing and a
|
|
475
|
+
* whole style object per cell; a formatted table of ten thousand cells
|
|
476
|
+
* usually has a dozen styles.
|
|
477
|
+
* @param {number} sheet
|
|
478
|
+
* @param {string} range
|
|
479
|
+
* @returns {RangeStyles}
|
|
480
|
+
*/
|
|
481
|
+
getRangeStyles(sheet, range) {
|
|
482
|
+
const ptr0 = passStringToWasm0(range, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
483
|
+
const len0 = WASM_VECTOR_LEN;
|
|
484
|
+
const ret = wasm.book_getRangeStyles(this.__wbg_ptr, sheet, ptr0, len0);
|
|
485
|
+
if (ret[2]) {
|
|
486
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
487
|
+
}
|
|
488
|
+
return takeFromExternrefTable0(ret[0]);
|
|
489
|
+
}
|
|
490
|
+
/**
|
|
491
|
+
* The same by numbers, as `getRangeAt` takes them.
|
|
492
|
+
* @param {number} sheet
|
|
493
|
+
* @param {number} row
|
|
494
|
+
* @param {number} column
|
|
495
|
+
* @param {number} rows
|
|
496
|
+
* @param {number} columns
|
|
497
|
+
* @returns {RangeStyles}
|
|
498
|
+
*/
|
|
499
|
+
getRangeStylesAt(sheet, row, column, rows, columns) {
|
|
500
|
+
const ret = wasm.book_getRangeStylesAt(this.__wbg_ptr, sheet, row, column, rows, columns);
|
|
501
|
+
if (ret[2]) {
|
|
502
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
503
|
+
}
|
|
504
|
+
return takeFromExternrefTable0(ret[0]);
|
|
505
|
+
}
|
|
358
506
|
/**
|
|
359
507
|
* A whole row in one crossing of the boundary: values, displayed text,
|
|
360
508
|
* bold and indent, plus whether the row is hidden.
|
|
@@ -378,6 +526,47 @@ class Book {
|
|
|
378
526
|
}
|
|
379
527
|
return takeFromExternrefTable0(ret[0]);
|
|
380
528
|
}
|
|
529
|
+
/**
|
|
530
|
+
* The hyperlinks of a sheet. `external` tells a URL from a jump inside
|
|
531
|
+
* the workbook.
|
|
532
|
+
* @param {number} sheet
|
|
533
|
+
* @returns {SheetHyperlink[]}
|
|
534
|
+
*/
|
|
535
|
+
hyperlinks(sheet) {
|
|
536
|
+
const ret = wasm.book_hyperlinks(this.__wbg_ptr, sheet);
|
|
537
|
+
if (ret[2]) {
|
|
538
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
539
|
+
}
|
|
540
|
+
return takeFromExternrefTable0(ret[0]);
|
|
541
|
+
}
|
|
542
|
+
/**
|
|
543
|
+
* The bytes of one picture, by its position in `images`.
|
|
544
|
+
* @param {number} sheet
|
|
545
|
+
* @param {number} index
|
|
546
|
+
* @returns {Uint8Array}
|
|
547
|
+
*/
|
|
548
|
+
imageData(sheet, index) {
|
|
549
|
+
const ret = wasm.book_imageData(this.__wbg_ptr, sheet, index);
|
|
550
|
+
if (ret[3]) {
|
|
551
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
552
|
+
}
|
|
553
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
554
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
555
|
+
return v1;
|
|
556
|
+
}
|
|
557
|
+
/**
|
|
558
|
+
* The pictures on a sheet, without their bytes: `imageData` fetches those
|
|
559
|
+
* for the one that is wanted.
|
|
560
|
+
* @param {number} sheet
|
|
561
|
+
* @returns {SheetImage[]}
|
|
562
|
+
*/
|
|
563
|
+
images(sheet) {
|
|
564
|
+
const ret = wasm.book_images(this.__wbg_ptr, sheet);
|
|
565
|
+
if (ret[2]) {
|
|
566
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
567
|
+
}
|
|
568
|
+
return takeFromExternrefTable0(ret[0]);
|
|
569
|
+
}
|
|
381
570
|
/**
|
|
382
571
|
* The merged areas of a sheet, as `"A1:C1"` strings in the order the file
|
|
383
572
|
* lists them.
|
|
@@ -418,6 +607,20 @@ class Book {
|
|
|
418
607
|
BookFinalization.register(this, this.__wbg_ptr, this);
|
|
419
608
|
return this;
|
|
420
609
|
}
|
|
610
|
+
/**
|
|
611
|
+
* The pivot reports laid out on a sheet. The numbers they show are cells
|
|
612
|
+
* like any others; this says where a report sits and how wide its axes
|
|
613
|
+
* are.
|
|
614
|
+
* @param {number} sheet
|
|
615
|
+
* @returns {SheetPivotTable[]}
|
|
616
|
+
*/
|
|
617
|
+
pivotTables(sheet) {
|
|
618
|
+
const ret = wasm.book_pivotTables(this.__wbg_ptr, sheet);
|
|
619
|
+
if (ret[2]) {
|
|
620
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
621
|
+
}
|
|
622
|
+
return takeFromExternrefTable0(ret[0]);
|
|
623
|
+
}
|
|
421
624
|
/**
|
|
422
625
|
* Reads a workbook of any format this crate supports, working the format
|
|
423
626
|
* out from the bytes themselves.
|
|
@@ -442,6 +645,26 @@ class Book {
|
|
|
442
645
|
}
|
|
443
646
|
return Book.__wrap(ret[0]);
|
|
444
647
|
}
|
|
648
|
+
/**
|
|
649
|
+
* Reads CSV with the guesses overridden: the delimiter, whether a row
|
|
650
|
+
* that produced no cell is skipped, whether an empty field becomes an
|
|
651
|
+
* empty string rather than no cell at all.
|
|
652
|
+
*
|
|
653
|
+
* `Book.read` guesses all of this from the bytes, which is right for a
|
|
654
|
+
* file of unknown origin; this is for one whose shape you already know.
|
|
655
|
+
* @param {Uint8Array} bytes
|
|
656
|
+
* @param {CsvOptions} options
|
|
657
|
+
* @returns {Book}
|
|
658
|
+
*/
|
|
659
|
+
static readCsv(bytes, options) {
|
|
660
|
+
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
|
|
661
|
+
const len0 = WASM_VECTOR_LEN;
|
|
662
|
+
const ret = wasm.book_readCsv(ptr0, len0, options);
|
|
663
|
+
if (ret[2]) {
|
|
664
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
665
|
+
}
|
|
666
|
+
return Book.__wrap(ret[0]);
|
|
667
|
+
}
|
|
445
668
|
/**
|
|
446
669
|
* Renames a sheet.
|
|
447
670
|
* @param {number} sheet
|
|
@@ -455,6 +678,20 @@ class Book {
|
|
|
455
678
|
throw takeFromExternrefTable0(ret[0]);
|
|
456
679
|
}
|
|
457
680
|
}
|
|
681
|
+
/**
|
|
682
|
+
* The height of a row in points, or `undefined` when the sheet leaves it
|
|
683
|
+
* to the default. `row` is the number a user sees.
|
|
684
|
+
* @param {number} sheet
|
|
685
|
+
* @param {number} row
|
|
686
|
+
* @returns {number | undefined}
|
|
687
|
+
*/
|
|
688
|
+
rowHeight(sheet, row) {
|
|
689
|
+
const ret = wasm.book_rowHeight(this.__wbg_ptr, sheet, row);
|
|
690
|
+
if (ret[3]) {
|
|
691
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
692
|
+
}
|
|
693
|
+
return ret[0] === 0 ? undefined : ret[1];
|
|
694
|
+
}
|
|
458
695
|
/**
|
|
459
696
|
* Whether a row is hidden. `row` is the number a user sees.
|
|
460
697
|
* @param {number} sheet
|
|
@@ -548,6 +785,18 @@ class Book {
|
|
|
548
785
|
throw takeFromExternrefTable0(ret[0]);
|
|
549
786
|
}
|
|
550
787
|
}
|
|
788
|
+
/**
|
|
789
|
+
* The drawn shapes of a sheet, text and all.
|
|
790
|
+
* @param {number} sheet
|
|
791
|
+
* @returns {SheetShape[]}
|
|
792
|
+
*/
|
|
793
|
+
shapes(sheet) {
|
|
794
|
+
const ret = wasm.book_shapes(this.__wbg_ptr, sheet);
|
|
795
|
+
if (ret[2]) {
|
|
796
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
797
|
+
}
|
|
798
|
+
return takeFromExternrefTable0(ret[0]);
|
|
799
|
+
}
|
|
551
800
|
/**
|
|
552
801
|
* The tab index of a sheet by name, or `undefined` when there is none.
|
|
553
802
|
* Names are compared the way Excel does, ignoring case.
|
|
@@ -570,6 +819,30 @@ class Book {
|
|
|
570
819
|
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
571
820
|
return v1;
|
|
572
821
|
}
|
|
822
|
+
/**
|
|
823
|
+
* Whether a sheet is locked, and whether the lock has a password.
|
|
824
|
+
* @param {number} sheet
|
|
825
|
+
* @returns {ProtectionInfo}
|
|
826
|
+
*/
|
|
827
|
+
sheetProtection(sheet) {
|
|
828
|
+
const ret = wasm.book_sheetProtection(this.__wbg_ptr, sheet);
|
|
829
|
+
if (ret[2]) {
|
|
830
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
831
|
+
}
|
|
832
|
+
return takeFromExternrefTable0(ret[0]);
|
|
833
|
+
}
|
|
834
|
+
/**
|
|
835
|
+
* How the sheet is frozen and shown.
|
|
836
|
+
* @param {number} sheet
|
|
837
|
+
* @returns {SheetViewInfo}
|
|
838
|
+
*/
|
|
839
|
+
sheetView(sheet) {
|
|
840
|
+
const ret = wasm.book_sheetView(this.__wbg_ptr, sheet);
|
|
841
|
+
if (ret[2]) {
|
|
842
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
843
|
+
}
|
|
844
|
+
return takeFromExternrefTable0(ret[0]);
|
|
845
|
+
}
|
|
573
846
|
/**
|
|
574
847
|
* Whether a sheet has a tab: `"visible"`, `"hidden"` or `"veryHidden"`.
|
|
575
848
|
*
|
|
@@ -596,6 +869,19 @@ class Book {
|
|
|
596
869
|
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
597
870
|
}
|
|
598
871
|
}
|
|
872
|
+
/**
|
|
873
|
+
* The tables of a sheet: what a structured reference like `Sales[Amount]`
|
|
874
|
+
* names.
|
|
875
|
+
* @param {number} sheet
|
|
876
|
+
* @returns {SheetTable[]}
|
|
877
|
+
*/
|
|
878
|
+
tables(sheet) {
|
|
879
|
+
const ret = wasm.book_tables(this.__wbg_ptr, sheet);
|
|
880
|
+
if (ret[2]) {
|
|
881
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
882
|
+
}
|
|
883
|
+
return takeFromExternrefTable0(ret[0]);
|
|
884
|
+
}
|
|
599
885
|
/**
|
|
600
886
|
* The used range of a sheet as `A1:D9`, or `undefined` if it holds
|
|
601
887
|
* nothing. This is the rectangle to walk; the sheet itself is sparse.
|
|
@@ -611,6 +897,53 @@ class Book {
|
|
|
611
897
|
}
|
|
612
898
|
return v1;
|
|
613
899
|
}
|
|
900
|
+
/**
|
|
901
|
+
* The used range of a sheet as `"A1:D20"` without walking the rows;
|
|
902
|
+
* `undefined` for an empty sheet.
|
|
903
|
+
*
|
|
904
|
+
* Rows are exact, columns an upper bound: removing a cell never narrows
|
|
905
|
+
* them. `usedRange` answers the same until a cell in an edge column is
|
|
906
|
+
* removed, and walks the rows after that to give the exact rectangle.
|
|
907
|
+
* @param {number} sheet
|
|
908
|
+
* @returns {string | undefined}
|
|
909
|
+
*/
|
|
910
|
+
usedRangeHint(sheet) {
|
|
911
|
+
const ret = wasm.book_usedRangeHint(this.__wbg_ptr, sheet);
|
|
912
|
+
if (ret[3]) {
|
|
913
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
914
|
+
}
|
|
915
|
+
let v1;
|
|
916
|
+
if (ret[0] !== 0) {
|
|
917
|
+
v1 = getStringFromWasm0(ret[0], ret[1]);
|
|
918
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
919
|
+
}
|
|
920
|
+
return v1;
|
|
921
|
+
}
|
|
922
|
+
/**
|
|
923
|
+
* Whether that password unlocks the sheet. `false` for a sheet with no
|
|
924
|
+
* password on it, and for a hash this crate cannot check.
|
|
925
|
+
* @param {number} sheet
|
|
926
|
+
* @param {string} password
|
|
927
|
+
* @returns {boolean}
|
|
928
|
+
*/
|
|
929
|
+
verifySheetPassword(sheet, password) {
|
|
930
|
+
const ptr0 = passStringToWasm0(password, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
931
|
+
const len0 = WASM_VECTOR_LEN;
|
|
932
|
+
const ret = wasm.book_verifySheetPassword(this.__wbg_ptr, sheet, ptr0, len0);
|
|
933
|
+
if (ret[2]) {
|
|
934
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
935
|
+
}
|
|
936
|
+
return ret[0] !== 0;
|
|
937
|
+
}
|
|
938
|
+
/**
|
|
939
|
+
* Whether the workbook's structure is locked, and whether behind a
|
|
940
|
+
* password.
|
|
941
|
+
* @returns {ProtectionInfo}
|
|
942
|
+
*/
|
|
943
|
+
workbookProtection() {
|
|
944
|
+
const ret = wasm.book_workbookProtection(this.__wbg_ptr);
|
|
945
|
+
return ret;
|
|
946
|
+
}
|
|
614
947
|
}
|
|
615
948
|
if (Symbol.dispose) Book.prototype[Symbol.dispose] = Book.prototype.free;
|
|
616
949
|
exports.Book = Book;
|
|
@@ -626,6 +959,10 @@ function __wbg_get_imports() {
|
|
|
626
959
|
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
627
960
|
return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
|
|
628
961
|
},
|
|
962
|
+
__wbg___wbindgen_is_falsy_b7464e97ddc1b7a4: function(arg0) {
|
|
963
|
+
const ret = !arg0;
|
|
964
|
+
return ret;
|
|
965
|
+
},
|
|
629
966
|
__wbg___wbindgen_is_null_7d13f41e1a2d5140: function(arg0) {
|
|
630
967
|
const ret = arg0 === null;
|
|
631
968
|
return ret;
|
|
@@ -655,6 +992,10 @@ function __wbg_get_imports() {
|
|
|
655
992
|
const ret = arg0.call(arg1, arg2);
|
|
656
993
|
return ret;
|
|
657
994
|
}, arguments); },
|
|
995
|
+
__wbg_get_971a0c45d172643f: function() { return handleError(function (arg0, arg1) {
|
|
996
|
+
const ret = Reflect.get(arg0, arg1);
|
|
997
|
+
return ret;
|
|
998
|
+
}, arguments); },
|
|
658
999
|
__wbg_get_unchecked_e20b893aeafc3fca: function(arg0, arg1) {
|
|
659
1000
|
const ret = arg0[arg1 >>> 0];
|
|
660
1001
|
return ret;
|
package/excelerate_bg.wasm
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rosperitus/excelerate-reader",
|
|
3
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.
|
|
4
|
+
"version": "0.12.3",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|