@rosperitus/excelerate-reader 0.8.0 → 0.12.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 CHANGED
@@ -56,6 +56,34 @@ 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 walking the
60
+ cells - it repeats what the file says about its own shape - and `columnWidth`
61
+ and `rowHeight` come back `undefined` where the sheet leaves them to the
62
+ default.
63
+
64
+ ## What is on a sheet besides cells
65
+
66
+ ```js
67
+ book.comments(0); // [{ address: "B2", author: "Иванов", text: "сверить" }]
68
+ book.hyperlinks(0); // [{ range, target, external, display, tooltip }]
69
+ book.tables(0); // [{ name, displayName, range, columns, ... }]
70
+ book.charts(0); // [{ name, title, kinds: ["barChart"], seriesCount, anchor }]
71
+ book.images(0); // [{ name, format, byteLength, anchor }] - no bytes
72
+ book.imageData(0, 0); // Uint8Array, the picture itself
73
+ book.shapes(0); // [{ name, geometry, text, anchor }]
74
+ ```
75
+
76
+ An anchor is where the object sits, in the numbers a user sees:
77
+ `{ kind: "twoCell", row: 3, column: 2 }`. An absolute anchor is at a point on
78
+ the sheet rather than at a cell, so its row and column are `null`.
79
+
80
+ Beyond the cells, a file states rules and names, and those are here too:
81
+ `definedNames()`, `dataValidations(sheet)`, `conditionalFormats(sheet)`,
82
+ `autoFilter(sheet)`, `pivotTables(sheet)`, `arrayFormulas(sheet)`,
83
+ `externalBooks()`, `sheetView(sheet)` (frozen rows and columns, zoom, grid
84
+ lines) and `sheetProtection(sheet)` with `verifySheetPassword`. `Book.readCsv`
85
+ reads CSV with the delimiter stated rather than guessed.
86
+
59
87
  ## Styles
60
88
 
61
89
  `cellStyle` answers with the number format, font, fill, borders and text
@@ -100,7 +128,10 @@ unusual - so raise it when you know where the file came from.
100
128
 
101
129
  ## What is not here
102
130
 
103
- Writing, in any format. Recalculation. Everything else the full package can do
131
+ Writing, in any format - including painting a cell, writing a note, a link or
132
+ a table. Recalculation. Editing the grid - inserting and
133
+ removing rows, columns and sheets - which only makes sense when the result can
134
+ be saved. Everything else the full package can do
104
135
  with a workbook once it is open - the reading side of it - is.
105
136
 
106
137
  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
@@ -70,6 +173,16 @@ export class Book {
70
173
  * Appends a sheet and returns its index.
71
174
  */
72
175
  addSheet(title: string): number;
176
+ /**
177
+ * The array formulas of a sheet, as the areas they cover: `["B2:B4"]`.
178
+ * The formula itself is on the top left cell of each.
179
+ */
180
+ arrayFormulas(sheet: number): string[];
181
+ /**
182
+ * The autofilter over a sheet, or `undefined` when it has none. What the
183
+ * filter hides is a property of each row - see `rowHidden`.
184
+ */
185
+ autoFilter(sheet: number): SheetAutoFilter | undefined;
73
186
  /**
74
187
  * Whether a cell is bold.
75
188
  *
@@ -110,6 +223,11 @@ export class Book {
110
223
  * The same by 1-based row and column.
111
224
  */
112
225
  cellStyleAt(sheet: number, row: number, column: number): CellStyle;
226
+ /**
227
+ * The charts on a sheet. `kinds` names the plots drawn in each -
228
+ * `barChart`, `lineChart` - and a combination chart has more than one.
229
+ */
230
+ charts(sheet: number): SheetChart[];
113
231
  /**
114
232
  * Empties a cell, style and all.
115
233
  */
@@ -122,6 +240,36 @@ export class Book {
122
240
  * The same for a column, named by its letters: `columnLevel(0, "C")`.
123
241
  */
124
242
  columnLevel(sheet: number, column: string): number;
243
+ /**
244
+ * The width of a column in characters, or `undefined` when the sheet
245
+ * leaves it to the default. `column` is 1-based.
246
+ */
247
+ columnWidth(sheet: number, column: number): number | undefined;
248
+ /**
249
+ * The notes on a sheet, in address order.
250
+ */
251
+ comments(sheet: number): SheetComment[];
252
+ /**
253
+ * The conditional formatting of a sheet, block by block. The formatting
254
+ * each rule applies is not modelled here - it lives in the workbook's
255
+ * differential styles - but what the rule tests is.
256
+ */
257
+ conditionalFormats(sheet: number): SheetConditionalFormat[];
258
+ /**
259
+ * The rules limiting what cells accept: the dropdown lists, the ranges,
260
+ * the dates.
261
+ */
262
+ dataValidations(sheet: number): SheetValidation[];
263
+ /**
264
+ * The names the workbook defines: what `=Total` and `Print_Area` stand
265
+ * for. `sheet` is set on a name local to one sheet.
266
+ */
267
+ definedNames(): WorkbookName[];
268
+ /**
269
+ * The other workbooks this one reads, in the order `[1]Sheet1!A1` counts
270
+ * them. A path is `undefined` where the file does not name one.
271
+ */
272
+ externalBooks(): any[];
125
273
  /**
126
274
  * Reads an xlsx package from its bytes.
127
275
  */
@@ -178,6 +326,20 @@ export class Book {
178
326
  * `null`; `getFormattedAt` still answers for the cells that need it.
179
327
  */
180
328
  getRowAt(sheet: number, row: number, formatted?: boolean | null): SheetRow;
329
+ /**
330
+ * The hyperlinks of a sheet. `external` tells a URL from a jump inside
331
+ * the workbook.
332
+ */
333
+ hyperlinks(sheet: number): SheetHyperlink[];
334
+ /**
335
+ * The bytes of one picture, by its position in `images`.
336
+ */
337
+ imageData(sheet: number, index: number): Uint8Array;
338
+ /**
339
+ * The pictures on a sheet, without their bytes: `imageData` fetches those
340
+ * for the one that is wanted.
341
+ */
342
+ images(sheet: number): SheetImage[];
181
343
  /**
182
344
  * The merged areas of a sheet, as `"A1:C1"` strings in the order the file
183
345
  * lists them.
@@ -195,6 +357,12 @@ export class Book {
195
357
  * A new workbook with one empty sheet.
196
358
  */
197
359
  constructor();
360
+ /**
361
+ * The pivot reports laid out on a sheet. The numbers they show are cells
362
+ * like any others; this says where a report sits and how wide its axes
363
+ * are.
364
+ */
365
+ pivotTables(sheet: number): SheetPivotTable[];
198
366
  /**
199
367
  * Reads a workbook of any format this crate supports, working the format
200
368
  * out from the bytes themselves.
@@ -204,10 +372,24 @@ export class Book {
204
372
  * the sheet of a SYLK file.
205
373
  */
206
374
  static read(bytes: Uint8Array, name?: string | null, max_expanded?: number | null, on_progress?: Function | null): Book;
375
+ /**
376
+ * Reads CSV with the guesses overridden: the delimiter, whether a row
377
+ * that produced no cell is skipped, whether an empty field becomes an
378
+ * empty string rather than no cell at all.
379
+ *
380
+ * `Book.read` guesses all of this from the bytes, which is right for a
381
+ * file of unknown origin; this is for one whose shape you already know.
382
+ */
383
+ static readCsv(bytes: Uint8Array, options: CsvOptions): Book;
207
384
  /**
208
385
  * Renames a sheet.
209
386
  */
210
387
  renameSheet(sheet: number, title: string): void;
388
+ /**
389
+ * The height of a row in points, or `undefined` when the sheet leaves it
390
+ * to the default. `row` is the number a user sees.
391
+ */
392
+ rowHeight(sheet: number, row: number): number | undefined;
211
393
  /**
212
394
  * Whether a row is hidden. `row` is the number a user sees.
213
395
  */
@@ -239,6 +421,10 @@ export class Book {
239
421
  * The same with the corner given as 1-based row and column.
240
422
  */
241
423
  setRangeAt(sheet: number, row: number, column: number, values: CellGrid): void;
424
+ /**
425
+ * The drawn shapes of a sheet, text and all.
426
+ */
427
+ shapes(sheet: number): SheetShape[];
242
428
  /**
243
429
  * The tab index of a sheet by name, or `undefined` when there is none.
244
430
  * Names are compared the way Excel does, ignoring case.
@@ -248,6 +434,14 @@ export class Book {
248
434
  * Sheet titles, in tab order.
249
435
  */
250
436
  sheetNames(): string[];
437
+ /**
438
+ * Whether a sheet is locked, and whether the lock has a password.
439
+ */
440
+ sheetProtection(sheet: number): ProtectionInfo;
441
+ /**
442
+ * How the sheet is frozen and shown.
443
+ */
444
+ sheetView(sheet: number): SheetViewInfo;
251
445
  /**
252
446
  * Whether a sheet has a tab: `"visible"`, `"hidden"` or `"veryHidden"`.
253
447
  *
@@ -255,9 +449,33 @@ export class Book {
255
449
  * what the index of every other call counts.
256
450
  */
257
451
  sheetVisibility(sheet: number): string;
452
+ /**
453
+ * The tables of a sheet: what a structured reference like `Sales[Amount]`
454
+ * names.
455
+ */
456
+ tables(sheet: number): SheetTable[];
258
457
  /**
259
458
  * The used range of a sheet as `A1:D9`, or `undefined` if it holds
260
459
  * nothing. This is the rectangle to walk; the sheet itself is sparse.
261
460
  */
262
461
  usedRange(sheet: number): string | undefined;
462
+ /**
463
+ * The used range of a sheet as `"A1:D20"`, taken from what the file says
464
+ * rather than from walking the cells; `undefined` when it says nothing.
465
+ *
466
+ * A reader that only needs the shape of a sheet pays nothing for it;
467
+ * `usedRange` walks every cell and answers for a sheet built in memory
468
+ * too, where the file has nothing to say.
469
+ */
470
+ usedRangeHint(sheet: number): string | undefined;
471
+ /**
472
+ * Whether that password unlocks the sheet. `false` for a sheet with no
473
+ * password on it, and for a hash this crate cannot check.
474
+ */
475
+ verifySheetPassword(sheet: number, password: string): boolean;
476
+ /**
477
+ * Whether the workbook's structure is locked, and whether behind a
478
+ * password.
479
+ */
480
+ workbookProtection(): ProtectionInfo;
263
481
  }
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
@@ -378,6 +492,47 @@ class Book {
378
492
  }
379
493
  return takeFromExternrefTable0(ret[0]);
380
494
  }
495
+ /**
496
+ * The hyperlinks of a sheet. `external` tells a URL from a jump inside
497
+ * the workbook.
498
+ * @param {number} sheet
499
+ * @returns {SheetHyperlink[]}
500
+ */
501
+ hyperlinks(sheet) {
502
+ const ret = wasm.book_hyperlinks(this.__wbg_ptr, sheet);
503
+ if (ret[2]) {
504
+ throw takeFromExternrefTable0(ret[1]);
505
+ }
506
+ return takeFromExternrefTable0(ret[0]);
507
+ }
508
+ /**
509
+ * The bytes of one picture, by its position in `images`.
510
+ * @param {number} sheet
511
+ * @param {number} index
512
+ * @returns {Uint8Array}
513
+ */
514
+ imageData(sheet, index) {
515
+ const ret = wasm.book_imageData(this.__wbg_ptr, sheet, index);
516
+ if (ret[3]) {
517
+ throw takeFromExternrefTable0(ret[2]);
518
+ }
519
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
520
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
521
+ return v1;
522
+ }
523
+ /**
524
+ * The pictures on a sheet, without their bytes: `imageData` fetches those
525
+ * for the one that is wanted.
526
+ * @param {number} sheet
527
+ * @returns {SheetImage[]}
528
+ */
529
+ images(sheet) {
530
+ const ret = wasm.book_images(this.__wbg_ptr, sheet);
531
+ if (ret[2]) {
532
+ throw takeFromExternrefTable0(ret[1]);
533
+ }
534
+ return takeFromExternrefTable0(ret[0]);
535
+ }
381
536
  /**
382
537
  * The merged areas of a sheet, as `"A1:C1"` strings in the order the file
383
538
  * lists them.
@@ -418,6 +573,20 @@ class Book {
418
573
  BookFinalization.register(this, this.__wbg_ptr, this);
419
574
  return this;
420
575
  }
576
+ /**
577
+ * The pivot reports laid out on a sheet. The numbers they show are cells
578
+ * like any others; this says where a report sits and how wide its axes
579
+ * are.
580
+ * @param {number} sheet
581
+ * @returns {SheetPivotTable[]}
582
+ */
583
+ pivotTables(sheet) {
584
+ const ret = wasm.book_pivotTables(this.__wbg_ptr, sheet);
585
+ if (ret[2]) {
586
+ throw takeFromExternrefTable0(ret[1]);
587
+ }
588
+ return takeFromExternrefTable0(ret[0]);
589
+ }
421
590
  /**
422
591
  * Reads a workbook of any format this crate supports, working the format
423
592
  * out from the bytes themselves.
@@ -442,6 +611,26 @@ class Book {
442
611
  }
443
612
  return Book.__wrap(ret[0]);
444
613
  }
614
+ /**
615
+ * Reads CSV with the guesses overridden: the delimiter, whether a row
616
+ * that produced no cell is skipped, whether an empty field becomes an
617
+ * empty string rather than no cell at all.
618
+ *
619
+ * `Book.read` guesses all of this from the bytes, which is right for a
620
+ * file of unknown origin; this is for one whose shape you already know.
621
+ * @param {Uint8Array} bytes
622
+ * @param {CsvOptions} options
623
+ * @returns {Book}
624
+ */
625
+ static readCsv(bytes, options) {
626
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
627
+ const len0 = WASM_VECTOR_LEN;
628
+ const ret = wasm.book_readCsv(ptr0, len0, options);
629
+ if (ret[2]) {
630
+ throw takeFromExternrefTable0(ret[1]);
631
+ }
632
+ return Book.__wrap(ret[0]);
633
+ }
445
634
  /**
446
635
  * Renames a sheet.
447
636
  * @param {number} sheet
@@ -455,6 +644,20 @@ class Book {
455
644
  throw takeFromExternrefTable0(ret[0]);
456
645
  }
457
646
  }
647
+ /**
648
+ * The height of a row in points, or `undefined` when the sheet leaves it
649
+ * to the default. `row` is the number a user sees.
650
+ * @param {number} sheet
651
+ * @param {number} row
652
+ * @returns {number | undefined}
653
+ */
654
+ rowHeight(sheet, row) {
655
+ const ret = wasm.book_rowHeight(this.__wbg_ptr, sheet, row);
656
+ if (ret[3]) {
657
+ throw takeFromExternrefTable0(ret[2]);
658
+ }
659
+ return ret[0] === 0 ? undefined : ret[1];
660
+ }
458
661
  /**
459
662
  * Whether a row is hidden. `row` is the number a user sees.
460
663
  * @param {number} sheet
@@ -548,6 +751,18 @@ class Book {
548
751
  throw takeFromExternrefTable0(ret[0]);
549
752
  }
550
753
  }
754
+ /**
755
+ * The drawn shapes of a sheet, text and all.
756
+ * @param {number} sheet
757
+ * @returns {SheetShape[]}
758
+ */
759
+ shapes(sheet) {
760
+ const ret = wasm.book_shapes(this.__wbg_ptr, sheet);
761
+ if (ret[2]) {
762
+ throw takeFromExternrefTable0(ret[1]);
763
+ }
764
+ return takeFromExternrefTable0(ret[0]);
765
+ }
551
766
  /**
552
767
  * The tab index of a sheet by name, or `undefined` when there is none.
553
768
  * Names are compared the way Excel does, ignoring case.
@@ -570,6 +785,30 @@ class Book {
570
785
  wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
571
786
  return v1;
572
787
  }
788
+ /**
789
+ * Whether a sheet is locked, and whether the lock has a password.
790
+ * @param {number} sheet
791
+ * @returns {ProtectionInfo}
792
+ */
793
+ sheetProtection(sheet) {
794
+ const ret = wasm.book_sheetProtection(this.__wbg_ptr, sheet);
795
+ if (ret[2]) {
796
+ throw takeFromExternrefTable0(ret[1]);
797
+ }
798
+ return takeFromExternrefTable0(ret[0]);
799
+ }
800
+ /**
801
+ * How the sheet is frozen and shown.
802
+ * @param {number} sheet
803
+ * @returns {SheetViewInfo}
804
+ */
805
+ sheetView(sheet) {
806
+ const ret = wasm.book_sheetView(this.__wbg_ptr, sheet);
807
+ if (ret[2]) {
808
+ throw takeFromExternrefTable0(ret[1]);
809
+ }
810
+ return takeFromExternrefTable0(ret[0]);
811
+ }
573
812
  /**
574
813
  * Whether a sheet has a tab: `"visible"`, `"hidden"` or `"veryHidden"`.
575
814
  *
@@ -596,6 +835,19 @@ class Book {
596
835
  wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
597
836
  }
598
837
  }
838
+ /**
839
+ * The tables of a sheet: what a structured reference like `Sales[Amount]`
840
+ * names.
841
+ * @param {number} sheet
842
+ * @returns {SheetTable[]}
843
+ */
844
+ tables(sheet) {
845
+ const ret = wasm.book_tables(this.__wbg_ptr, sheet);
846
+ if (ret[2]) {
847
+ throw takeFromExternrefTable0(ret[1]);
848
+ }
849
+ return takeFromExternrefTable0(ret[0]);
850
+ }
599
851
  /**
600
852
  * The used range of a sheet as `A1:D9`, or `undefined` if it holds
601
853
  * nothing. This is the rectangle to walk; the sheet itself is sparse.
@@ -611,6 +863,53 @@ class Book {
611
863
  }
612
864
  return v1;
613
865
  }
866
+ /**
867
+ * The used range of a sheet as `"A1:D20"`, taken from what the file says
868
+ * rather than from walking the cells; `undefined` when it says nothing.
869
+ *
870
+ * A reader that only needs the shape of a sheet pays nothing for it;
871
+ * `usedRange` walks every cell and answers for a sheet built in memory
872
+ * too, where the file has nothing to say.
873
+ * @param {number} sheet
874
+ * @returns {string | undefined}
875
+ */
876
+ usedRangeHint(sheet) {
877
+ const ret = wasm.book_usedRangeHint(this.__wbg_ptr, sheet);
878
+ if (ret[3]) {
879
+ throw takeFromExternrefTable0(ret[2]);
880
+ }
881
+ let v1;
882
+ if (ret[0] !== 0) {
883
+ v1 = getStringFromWasm0(ret[0], ret[1]);
884
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
885
+ }
886
+ return v1;
887
+ }
888
+ /**
889
+ * Whether that password unlocks the sheet. `false` for a sheet with no
890
+ * password on it, and for a hash this crate cannot check.
891
+ * @param {number} sheet
892
+ * @param {string} password
893
+ * @returns {boolean}
894
+ */
895
+ verifySheetPassword(sheet, password) {
896
+ const ptr0 = passStringToWasm0(password, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
897
+ const len0 = WASM_VECTOR_LEN;
898
+ const ret = wasm.book_verifySheetPassword(this.__wbg_ptr, sheet, ptr0, len0);
899
+ if (ret[2]) {
900
+ throw takeFromExternrefTable0(ret[1]);
901
+ }
902
+ return ret[0] !== 0;
903
+ }
904
+ /**
905
+ * Whether the workbook's structure is locked, and whether behind a
906
+ * password.
907
+ * @returns {ProtectionInfo}
908
+ */
909
+ workbookProtection() {
910
+ const ret = wasm.book_workbookProtection(this.__wbg_ptr);
911
+ return ret;
912
+ }
614
913
  }
615
914
  if (Symbol.dispose) Book.prototype[Symbol.dispose] = Book.prototype.free;
616
915
  exports.Book = Book;
@@ -626,6 +925,10 @@ function __wbg_get_imports() {
626
925
  const ret = typeof(v) === 'boolean' ? v : undefined;
627
926
  return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
628
927
  },
928
+ __wbg___wbindgen_is_falsy_b7464e97ddc1b7a4: function(arg0) {
929
+ const ret = !arg0;
930
+ return ret;
931
+ },
629
932
  __wbg___wbindgen_is_null_7d13f41e1a2d5140: function(arg0) {
630
933
  const ret = arg0 === null;
631
934
  return ret;
@@ -655,6 +958,10 @@ function __wbg_get_imports() {
655
958
  const ret = arg0.call(arg1, arg2);
656
959
  return ret;
657
960
  }, arguments); },
961
+ __wbg_get_971a0c45d172643f: function() { return handleError(function (arg0, arg1) {
962
+ const ret = Reflect.get(arg0, arg1);
963
+ return ret;
964
+ }, arguments); },
658
965
  __wbg_get_unchecked_e20b893aeafc3fca: function(arg0, arg1) {
659
966
  const ret = arg0[arg1 >>> 0];
660
967
  return ret;
Binary file
package/package.json CHANGED
@@ -1,11 +1,11 @@
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.8.0",
4
+ "version": "0.12.0",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
8
- "url": "git+https://github.com/rosperitus/excelerate.git"
8
+ "url": "https://github.com/rosperitus/excelerate"
9
9
  },
10
10
  "files": [
11
11
  "excelerate_bg.wasm",
@@ -13,21 +13,16 @@
13
13
  "excelerate.d.ts"
14
14
  ],
15
15
  "main": "excelerate.js",
16
- "homepage": "https://github.com/rosperitus/excelerate#readme",
16
+ "homepage": "https://github.com/rosperitus/excelerate",
17
17
  "types": "excelerate.d.ts",
18
18
  "keywords": [
19
19
  "xlsx",
20
- "xls",
21
- "ods",
22
- "csv",
23
20
  "spreadsheet",
24
21
  "excel",
25
- "reader"
22
+ "ods",
23
+ "formula"
26
24
  ],
27
25
  "publishConfig": {
28
26
  "access": "public"
29
- },
30
- "bugs": {
31
- "url": "https://github.com/rosperitus/excelerate/issues"
32
27
  }
33
28
  }