@rosperitus/excelerate 0.11.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 +91 -1
- package/excelerate.d.ts +469 -1
- package/excelerate.js +915 -28
- package/excelerate_bg.wasm +0 -0
- package/package.json +1 -1
package/excelerate.js
CHANGED
|
@@ -42,6 +42,55 @@ class Book {
|
|
|
42
42
|
}
|
|
43
43
|
return ret[0] >>> 0;
|
|
44
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* Draws a table over a range, the thing `Sales[Amount]` names.
|
|
47
|
+
*
|
|
48
|
+
* The first row of the range is the header unless `headerRow` says
|
|
49
|
+
* otherwise, and the column names are read from it. The name must be
|
|
50
|
+
* unique in the workbook, as Excel requires.
|
|
51
|
+
* @param {number} sheet
|
|
52
|
+
* @param {string} name
|
|
53
|
+
* @param {string} range
|
|
54
|
+
* @param {boolean | null} [header_row]
|
|
55
|
+
*/
|
|
56
|
+
addTable(sheet, name, range, header_row) {
|
|
57
|
+
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
58
|
+
const len0 = WASM_VECTOR_LEN;
|
|
59
|
+
const ptr1 = passStringToWasm0(range, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
60
|
+
const len1 = WASM_VECTOR_LEN;
|
|
61
|
+
const ret = wasm.book_addTable(this.__wbg_ptr, sheet, ptr0, len0, ptr1, len1, isLikeNone(header_row) ? 0xFFFFFF : header_row ? 1 : 0);
|
|
62
|
+
if (ret[1]) {
|
|
63
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* The array formulas of a sheet, as the areas they cover: `["B2:B4"]`.
|
|
68
|
+
* The formula itself is on the top left cell of each.
|
|
69
|
+
* @param {number} sheet
|
|
70
|
+
* @returns {string[]}
|
|
71
|
+
*/
|
|
72
|
+
arrayFormulas(sheet) {
|
|
73
|
+
const ret = wasm.book_arrayFormulas(this.__wbg_ptr, sheet);
|
|
74
|
+
if (ret[3]) {
|
|
75
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
76
|
+
}
|
|
77
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]);
|
|
78
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
79
|
+
return v1;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* The autofilter over a sheet, or `undefined` when it has none. What the
|
|
83
|
+
* filter hides is a property of each row - see `rowHidden`.
|
|
84
|
+
* @param {number} sheet
|
|
85
|
+
* @returns {SheetAutoFilter | undefined}
|
|
86
|
+
*/
|
|
87
|
+
autoFilter(sheet) {
|
|
88
|
+
const ret = wasm.book_autoFilter(this.__wbg_ptr, sheet);
|
|
89
|
+
if (ret[2]) {
|
|
90
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
91
|
+
}
|
|
92
|
+
return takeFromExternrefTable0(ret[0]);
|
|
93
|
+
}
|
|
45
94
|
/**
|
|
46
95
|
* Whether a cell is bold.
|
|
47
96
|
*
|
|
@@ -150,6 +199,19 @@ class Book {
|
|
|
150
199
|
}
|
|
151
200
|
return takeFromExternrefTable0(ret[0]);
|
|
152
201
|
}
|
|
202
|
+
/**
|
|
203
|
+
* The charts on a sheet. `kinds` names the plots drawn in each -
|
|
204
|
+
* `barChart`, `lineChart` - and a combination chart has more than one.
|
|
205
|
+
* @param {number} sheet
|
|
206
|
+
* @returns {SheetChart[]}
|
|
207
|
+
*/
|
|
208
|
+
charts(sheet) {
|
|
209
|
+
const ret = wasm.book_charts(this.__wbg_ptr, sheet);
|
|
210
|
+
if (ret[2]) {
|
|
211
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
212
|
+
}
|
|
213
|
+
return takeFromExternrefTable0(ret[0]);
|
|
214
|
+
}
|
|
153
215
|
/**
|
|
154
216
|
* Empties a cell, style and all.
|
|
155
217
|
* @param {number} sheet
|
|
@@ -190,6 +252,90 @@ class Book {
|
|
|
190
252
|
}
|
|
191
253
|
return ret[0];
|
|
192
254
|
}
|
|
255
|
+
/**
|
|
256
|
+
* The width of a column in characters, or `undefined` when the sheet
|
|
257
|
+
* leaves it to the default. `column` is 1-based.
|
|
258
|
+
* @param {number} sheet
|
|
259
|
+
* @param {number} column
|
|
260
|
+
* @returns {number | undefined}
|
|
261
|
+
*/
|
|
262
|
+
columnWidth(sheet, column) {
|
|
263
|
+
const ret = wasm.book_columnWidth(this.__wbg_ptr, sheet, column);
|
|
264
|
+
if (ret[3]) {
|
|
265
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
266
|
+
}
|
|
267
|
+
return ret[0] === 0 ? undefined : ret[1];
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* The notes on a sheet, in address order.
|
|
271
|
+
* @param {number} sheet
|
|
272
|
+
* @returns {SheetComment[]}
|
|
273
|
+
*/
|
|
274
|
+
comments(sheet) {
|
|
275
|
+
const ret = wasm.book_comments(this.__wbg_ptr, sheet);
|
|
276
|
+
if (ret[2]) {
|
|
277
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
278
|
+
}
|
|
279
|
+
return takeFromExternrefTable0(ret[0]);
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* The conditional formatting of a sheet, block by block. The formatting
|
|
283
|
+
* each rule applies is not modelled here - it lives in the workbook's
|
|
284
|
+
* differential styles - but what the rule tests is.
|
|
285
|
+
* @param {number} sheet
|
|
286
|
+
* @returns {SheetConditionalFormat[]}
|
|
287
|
+
*/
|
|
288
|
+
conditionalFormats(sheet) {
|
|
289
|
+
const ret = wasm.book_conditionalFormats(this.__wbg_ptr, sheet);
|
|
290
|
+
if (ret[2]) {
|
|
291
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
292
|
+
}
|
|
293
|
+
return takeFromExternrefTable0(ret[0]);
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Copies a rectangle of cells so its top left corner lands on `to`,
|
|
297
|
+
* rewriting the formulas as Excel rewrites a copied formula: `=A1` one
|
|
298
|
+
* row down reads `=A2`, `$A$1` stays put.
|
|
299
|
+
*
|
|
300
|
+
* `toSheet` defaults to the sheet copied from. A cell the source leaves
|
|
301
|
+
* empty empties the target, the way pasting a block does.
|
|
302
|
+
* @param {number} sheet
|
|
303
|
+
* @param {string} range
|
|
304
|
+
* @param {string} to
|
|
305
|
+
* @param {number | null} [to_sheet]
|
|
306
|
+
*/
|
|
307
|
+
copyRange(sheet, range, to, to_sheet) {
|
|
308
|
+
const ptr0 = passStringToWasm0(range, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
309
|
+
const len0 = WASM_VECTOR_LEN;
|
|
310
|
+
const ptr1 = passStringToWasm0(to, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
311
|
+
const len1 = WASM_VECTOR_LEN;
|
|
312
|
+
const ret = wasm.book_copyRange(this.__wbg_ptr, sheet, ptr0, len0, ptr1, len1, isLikeNone(to_sheet) ? Number.MAX_SAFE_INTEGER : (to_sheet) >>> 0);
|
|
313
|
+
if (ret[1]) {
|
|
314
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* The rules limiting what cells accept: the dropdown lists, the ranges,
|
|
319
|
+
* the dates.
|
|
320
|
+
* @param {number} sheet
|
|
321
|
+
* @returns {SheetValidation[]}
|
|
322
|
+
*/
|
|
323
|
+
dataValidations(sheet) {
|
|
324
|
+
const ret = wasm.book_dataValidations(this.__wbg_ptr, sheet);
|
|
325
|
+
if (ret[2]) {
|
|
326
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
327
|
+
}
|
|
328
|
+
return takeFromExternrefTable0(ret[0]);
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* The names the workbook defines: what `=Total` and `Print_Area` stand
|
|
332
|
+
* for. `sheet` is set on a name local to one sheet.
|
|
333
|
+
* @returns {WorkbookName[]}
|
|
334
|
+
*/
|
|
335
|
+
definedNames() {
|
|
336
|
+
const ret = wasm.book_definedNames(this.__wbg_ptr);
|
|
337
|
+
return ret;
|
|
338
|
+
}
|
|
193
339
|
/**
|
|
194
340
|
* Evaluates a formula (with or without the leading `=`) as if it sat in
|
|
195
341
|
* `address` of `sheet`, and returns its result.
|
|
@@ -209,6 +355,30 @@ class Book {
|
|
|
209
355
|
}
|
|
210
356
|
return takeFromExternrefTable0(ret[0]);
|
|
211
357
|
}
|
|
358
|
+
/**
|
|
359
|
+
* The other workbooks this one reads, in the order `[1]Sheet1!A1` counts
|
|
360
|
+
* them. A path is `undefined` where the file does not name one.
|
|
361
|
+
* @returns {any[]}
|
|
362
|
+
*/
|
|
363
|
+
externalBooks() {
|
|
364
|
+
const ret = wasm.book_externalBooks(this.__wbg_ptr);
|
|
365
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]);
|
|
366
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
367
|
+
return v1;
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* Freezes the first `rows` rows and `columns` columns, so they stay put
|
|
371
|
+
* while the rest scrolls. `freezePanes(0, 1, 0)` pins the header row.
|
|
372
|
+
* @param {number} sheet
|
|
373
|
+
* @param {number} rows
|
|
374
|
+
* @param {number} columns
|
|
375
|
+
*/
|
|
376
|
+
freezePanes(sheet, rows, columns) {
|
|
377
|
+
const ret = wasm.book_freezePanes(this.__wbg_ptr, sheet, rows, columns);
|
|
378
|
+
if (ret[1]) {
|
|
379
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
212
382
|
/**
|
|
213
383
|
* Reads an xlsx package from its bytes.
|
|
214
384
|
* @param {Uint8Array} bytes
|
|
@@ -397,6 +567,106 @@ class Book {
|
|
|
397
567
|
}
|
|
398
568
|
return takeFromExternrefTable0(ret[0]);
|
|
399
569
|
}
|
|
570
|
+
/**
|
|
571
|
+
* The hyperlinks of a sheet. `external` tells a URL from a jump inside
|
|
572
|
+
* the workbook.
|
|
573
|
+
* @param {number} sheet
|
|
574
|
+
* @returns {SheetHyperlink[]}
|
|
575
|
+
*/
|
|
576
|
+
hyperlinks(sheet) {
|
|
577
|
+
const ret = wasm.book_hyperlinks(this.__wbg_ptr, sheet);
|
|
578
|
+
if (ret[2]) {
|
|
579
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
580
|
+
}
|
|
581
|
+
return takeFromExternrefTable0(ret[0]);
|
|
582
|
+
}
|
|
583
|
+
/**
|
|
584
|
+
* The bytes of one picture, by its position in `images`.
|
|
585
|
+
* @param {number} sheet
|
|
586
|
+
* @param {number} index
|
|
587
|
+
* @returns {Uint8Array}
|
|
588
|
+
*/
|
|
589
|
+
imageData(sheet, index) {
|
|
590
|
+
const ret = wasm.book_imageData(this.__wbg_ptr, sheet, index);
|
|
591
|
+
if (ret[3]) {
|
|
592
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
593
|
+
}
|
|
594
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
595
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
596
|
+
return v1;
|
|
597
|
+
}
|
|
598
|
+
/**
|
|
599
|
+
* The pictures on a sheet, without their bytes: `imageData` fetches those
|
|
600
|
+
* for the one that is wanted.
|
|
601
|
+
* @param {number} sheet
|
|
602
|
+
* @returns {SheetImage[]}
|
|
603
|
+
*/
|
|
604
|
+
images(sheet) {
|
|
605
|
+
const ret = wasm.book_images(this.__wbg_ptr, sheet);
|
|
606
|
+
if (ret[2]) {
|
|
607
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
608
|
+
}
|
|
609
|
+
return takeFromExternrefTable0(ret[0]);
|
|
610
|
+
}
|
|
611
|
+
/**
|
|
612
|
+
* Inserts blank cells over a range, pushing what was there `"down"` or
|
|
613
|
+
* `"right"` - Excel's "Insert Cells", which moves part of a row rather
|
|
614
|
+
* than the whole of it.
|
|
615
|
+
* @param {number} sheet
|
|
616
|
+
* @param {string} range
|
|
617
|
+
* @param {string} shift
|
|
618
|
+
*/
|
|
619
|
+
insertCells(sheet, range, shift) {
|
|
620
|
+
const ptr0 = passStringToWasm0(range, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
621
|
+
const len0 = WASM_VECTOR_LEN;
|
|
622
|
+
const ptr1 = passStringToWasm0(shift, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
623
|
+
const len1 = WASM_VECTOR_LEN;
|
|
624
|
+
const ret = wasm.book_insertCells(this.__wbg_ptr, sheet, ptr0, len0, ptr1, len1);
|
|
625
|
+
if (ret[1]) {
|
|
626
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
/**
|
|
630
|
+
* Inserts `count` columns to the left of column `at`, 1-based.
|
|
631
|
+
* @param {number} sheet
|
|
632
|
+
* @param {number} at
|
|
633
|
+
* @param {number} count
|
|
634
|
+
*/
|
|
635
|
+
insertColumns(sheet, at, count) {
|
|
636
|
+
const ret = wasm.book_insertColumns(this.__wbg_ptr, sheet, at, count);
|
|
637
|
+
if (ret[1]) {
|
|
638
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
/**
|
|
642
|
+
* Inserts `count` rows above row `at`, moving everything below down.
|
|
643
|
+
*
|
|
644
|
+
* Formulas across the whole workbook follow the cells they read, and so
|
|
645
|
+
* do merges, links, validations, tables and drawings. `at` is the number
|
|
646
|
+
* a user sees.
|
|
647
|
+
* @param {number} sheet
|
|
648
|
+
* @param {number} at
|
|
649
|
+
* @param {number} count
|
|
650
|
+
*/
|
|
651
|
+
insertRows(sheet, at, count) {
|
|
652
|
+
const ret = wasm.book_insertRows(this.__wbg_ptr, sheet, at, count);
|
|
653
|
+
if (ret[1]) {
|
|
654
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
/**
|
|
658
|
+
* Merges a block of cells: `merge(0, "A1:C1")`.
|
|
659
|
+
* @param {number} sheet
|
|
660
|
+
* @param {string} range
|
|
661
|
+
*/
|
|
662
|
+
merge(sheet, range) {
|
|
663
|
+
const ptr0 = passStringToWasm0(range, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
664
|
+
const len0 = WASM_VECTOR_LEN;
|
|
665
|
+
const ret = wasm.book_merge(this.__wbg_ptr, sheet, ptr0, len0);
|
|
666
|
+
if (ret[1]) {
|
|
667
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
668
|
+
}
|
|
669
|
+
}
|
|
400
670
|
/**
|
|
401
671
|
* The merged areas of a sheet, as `"A1:C1"` strings in the order the file
|
|
402
672
|
* lists them.
|
|
@@ -428,6 +698,40 @@ class Book {
|
|
|
428
698
|
}
|
|
429
699
|
return takeFromExternrefTable0(ret[0]);
|
|
430
700
|
}
|
|
701
|
+
/**
|
|
702
|
+
* Moves a rectangle of cells, leaving the source empty.
|
|
703
|
+
*
|
|
704
|
+
* A moved formula keeps reading the cells it read; the formulas elsewhere
|
|
705
|
+
* that read *these* cells follow them instead, as they do when Excel cuts
|
|
706
|
+
* and pastes.
|
|
707
|
+
* @param {number} sheet
|
|
708
|
+
* @param {string} range
|
|
709
|
+
* @param {string} to
|
|
710
|
+
* @param {number | null} [to_sheet]
|
|
711
|
+
*/
|
|
712
|
+
moveRange(sheet, range, to, to_sheet) {
|
|
713
|
+
const ptr0 = passStringToWasm0(range, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
714
|
+
const len0 = WASM_VECTOR_LEN;
|
|
715
|
+
const ptr1 = passStringToWasm0(to, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
716
|
+
const len1 = WASM_VECTOR_LEN;
|
|
717
|
+
const ret = wasm.book_moveRange(this.__wbg_ptr, sheet, ptr0, len0, ptr1, len1, isLikeNone(to_sheet) ? Number.MAX_SAFE_INTEGER : (to_sheet) >>> 0);
|
|
718
|
+
if (ret[1]) {
|
|
719
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
/**
|
|
723
|
+
* Moves a sheet along the tab bar. Formulas are untouched - a sheet is
|
|
724
|
+
* named, not numbered - but every index moves, this one included, so read
|
|
725
|
+
* `sheetIndex` again afterwards.
|
|
726
|
+
* @param {number} from
|
|
727
|
+
* @param {number} to
|
|
728
|
+
*/
|
|
729
|
+
moveSheet(from, to) {
|
|
730
|
+
const ret = wasm.book_moveSheet(this.__wbg_ptr, from, to);
|
|
731
|
+
if (ret[1]) {
|
|
732
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
733
|
+
}
|
|
734
|
+
}
|
|
431
735
|
/**
|
|
432
736
|
* A new workbook with one empty sheet.
|
|
433
737
|
*/
|
|
@@ -437,6 +741,52 @@ class Book {
|
|
|
437
741
|
BookFinalization.register(this, this.__wbg_ptr, this);
|
|
438
742
|
return this;
|
|
439
743
|
}
|
|
744
|
+
/**
|
|
745
|
+
* The pivot reports laid out on a sheet. The numbers they show are cells
|
|
746
|
+
* like any others; this says where a report sits and how wide its axes
|
|
747
|
+
* are.
|
|
748
|
+
* @param {number} sheet
|
|
749
|
+
* @returns {SheetPivotTable[]}
|
|
750
|
+
*/
|
|
751
|
+
pivotTables(sheet) {
|
|
752
|
+
const ret = wasm.book_pivotTables(this.__wbg_ptr, sheet);
|
|
753
|
+
if (ret[2]) {
|
|
754
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
755
|
+
}
|
|
756
|
+
return takeFromExternrefTable0(ret[0]);
|
|
757
|
+
}
|
|
758
|
+
/**
|
|
759
|
+
* Locks a sheet against editing, optionally behind a password.
|
|
760
|
+
*
|
|
761
|
+
* This is the lock Excel offers under "Protect Sheet": it stops a user
|
|
762
|
+
* editing, it does not encrypt anything. The password is stored as Excel
|
|
763
|
+
* stores it - SHA-512 over a random salt, 100,000 spins - and
|
|
764
|
+
* `verifySheetPassword` checks it back.
|
|
765
|
+
* @param {number} sheet
|
|
766
|
+
* @param {string | null} [password]
|
|
767
|
+
*/
|
|
768
|
+
protectSheet(sheet, password) {
|
|
769
|
+
var ptr0 = isLikeNone(password) ? 0 : passStringToWasm0(password, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
770
|
+
var len0 = WASM_VECTOR_LEN;
|
|
771
|
+
const ret = wasm.book_protectSheet(this.__wbg_ptr, sheet, ptr0, len0);
|
|
772
|
+
if (ret[1]) {
|
|
773
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
/**
|
|
777
|
+
* Locks the structure of the workbook: which sheets there are, and their
|
|
778
|
+
* order. `windows` locks the window layout as well.
|
|
779
|
+
* @param {string | null} [password]
|
|
780
|
+
* @param {boolean | null} [windows]
|
|
781
|
+
*/
|
|
782
|
+
protectWorkbook(password, windows) {
|
|
783
|
+
var ptr0 = isLikeNone(password) ? 0 : passStringToWasm0(password, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
784
|
+
var len0 = WASM_VECTOR_LEN;
|
|
785
|
+
const ret = wasm.book_protectWorkbook(this.__wbg_ptr, ptr0, len0, isLikeNone(windows) ? 0xFFFFFF : windows ? 1 : 0);
|
|
786
|
+
if (ret[1]) {
|
|
787
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
788
|
+
}
|
|
789
|
+
}
|
|
440
790
|
/**
|
|
441
791
|
* Reads a workbook of any format this crate supports, working the format
|
|
442
792
|
* out from the bytes themselves.
|
|
@@ -461,6 +811,26 @@ class Book {
|
|
|
461
811
|
}
|
|
462
812
|
return Book.__wrap(ret[0]);
|
|
463
813
|
}
|
|
814
|
+
/**
|
|
815
|
+
* Reads CSV with the guesses overridden: the delimiter, whether a row
|
|
816
|
+
* that produced no cell is skipped, whether an empty field becomes an
|
|
817
|
+
* empty string rather than no cell at all.
|
|
818
|
+
*
|
|
819
|
+
* `Book.read` guesses all of this from the bytes, which is right for a
|
|
820
|
+
* file of unknown origin; this is for one whose shape you already know.
|
|
821
|
+
* @param {Uint8Array} bytes
|
|
822
|
+
* @param {CsvOptions} options
|
|
823
|
+
* @returns {Book}
|
|
824
|
+
*/
|
|
825
|
+
static readCsv(bytes, options) {
|
|
826
|
+
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
|
|
827
|
+
const len0 = WASM_VECTOR_LEN;
|
|
828
|
+
const ret = wasm.book_readCsv(ptr0, len0, options);
|
|
829
|
+
if (ret[2]) {
|
|
830
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
831
|
+
}
|
|
832
|
+
return Book.__wrap(ret[0]);
|
|
833
|
+
}
|
|
464
834
|
/**
|
|
465
835
|
* Recomputes every formula and stores the results beside them, so that
|
|
466
836
|
* `get` and `toCsv` show this engine's answers rather than the cache the
|
|
@@ -596,53 +966,178 @@ class Book {
|
|
|
596
966
|
return v1;
|
|
597
967
|
}
|
|
598
968
|
/**
|
|
599
|
-
*
|
|
969
|
+
* Removes the cells of a range, pulling the rest back over the hole from
|
|
970
|
+
* below (`"up"`) or from the right (`"left"`).
|
|
600
971
|
* @param {number} sheet
|
|
601
|
-
* @param {string}
|
|
972
|
+
* @param {string} range
|
|
973
|
+
* @param {string} shift
|
|
602
974
|
*/
|
|
603
|
-
|
|
604
|
-
const ptr0 = passStringToWasm0(
|
|
975
|
+
removeCells(sheet, range, shift) {
|
|
976
|
+
const ptr0 = passStringToWasm0(range, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
605
977
|
const len0 = WASM_VECTOR_LEN;
|
|
606
|
-
const
|
|
978
|
+
const ptr1 = passStringToWasm0(shift, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
979
|
+
const len1 = WASM_VECTOR_LEN;
|
|
980
|
+
const ret = wasm.book_removeCells(this.__wbg_ptr, sheet, ptr0, len0, ptr1, len1);
|
|
607
981
|
if (ret[1]) {
|
|
608
982
|
throw takeFromExternrefTable0(ret[0]);
|
|
609
983
|
}
|
|
610
984
|
}
|
|
611
985
|
/**
|
|
612
|
-
*
|
|
986
|
+
* Removes `count` columns from column `at`, 1-based.
|
|
613
987
|
* @param {number} sheet
|
|
614
|
-
* @param {number}
|
|
615
|
-
* @
|
|
988
|
+
* @param {number} at
|
|
989
|
+
* @param {number} count
|
|
616
990
|
*/
|
|
617
|
-
|
|
618
|
-
const ret = wasm.
|
|
619
|
-
if (ret[
|
|
620
|
-
throw takeFromExternrefTable0(ret[
|
|
991
|
+
removeColumns(sheet, at, count) {
|
|
992
|
+
const ret = wasm.book_removeColumns(this.__wbg_ptr, sheet, at, count);
|
|
993
|
+
if (ret[1]) {
|
|
994
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
621
995
|
}
|
|
622
|
-
return ret[0] !== 0;
|
|
623
996
|
}
|
|
624
997
|
/**
|
|
625
|
-
*
|
|
626
|
-
* group, and so on. `row` is the number a user sees.
|
|
998
|
+
* Takes a note off a cell. Answers whether there was one.
|
|
627
999
|
* @param {number} sheet
|
|
628
|
-
* @param {
|
|
629
|
-
* @returns {
|
|
1000
|
+
* @param {string} address
|
|
1001
|
+
* @returns {boolean}
|
|
630
1002
|
*/
|
|
631
|
-
|
|
632
|
-
const
|
|
1003
|
+
removeComment(sheet, address) {
|
|
1004
|
+
const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1005
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1006
|
+
const ret = wasm.book_removeComment(this.__wbg_ptr, sheet, ptr0, len0);
|
|
633
1007
|
if (ret[2]) {
|
|
634
1008
|
throw takeFromExternrefTable0(ret[1]);
|
|
635
1009
|
}
|
|
636
|
-
return ret[0];
|
|
1010
|
+
return ret[0] !== 0;
|
|
637
1011
|
}
|
|
638
1012
|
/**
|
|
639
|
-
*
|
|
640
|
-
*
|
|
641
|
-
* @param {number}
|
|
642
|
-
* @
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
1013
|
+
* Removes a defined name. Answers whether there was one.
|
|
1014
|
+
* @param {string} name
|
|
1015
|
+
* @param {number | null} [sheet]
|
|
1016
|
+
* @returns {boolean}
|
|
1017
|
+
*/
|
|
1018
|
+
removeDefinedName(name, sheet) {
|
|
1019
|
+
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1020
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1021
|
+
const ret = wasm.book_removeDefinedName(this.__wbg_ptr, ptr0, len0, isLikeNone(sheet) ? Number.MAX_SAFE_INTEGER : (sheet) >>> 0);
|
|
1022
|
+
return ret !== 0;
|
|
1023
|
+
}
|
|
1024
|
+
/**
|
|
1025
|
+
* Takes the link off a range. Answers whether there was one.
|
|
1026
|
+
* @param {number} sheet
|
|
1027
|
+
* @param {string} range
|
|
1028
|
+
* @returns {boolean}
|
|
1029
|
+
*/
|
|
1030
|
+
removeHyperlink(sheet, range) {
|
|
1031
|
+
const ptr0 = passStringToWasm0(range, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1032
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1033
|
+
const ret = wasm.book_removeHyperlink(this.__wbg_ptr, sheet, ptr0, len0);
|
|
1034
|
+
if (ret[2]) {
|
|
1035
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1036
|
+
}
|
|
1037
|
+
return ret[0] !== 0;
|
|
1038
|
+
}
|
|
1039
|
+
/**
|
|
1040
|
+
* Removes `count` rows from row `at` down. A formula that read a removed
|
|
1041
|
+
* cell reads `#REF!` afterwards.
|
|
1042
|
+
* @param {number} sheet
|
|
1043
|
+
* @param {number} at
|
|
1044
|
+
* @param {number} count
|
|
1045
|
+
*/
|
|
1046
|
+
removeRows(sheet, at, count) {
|
|
1047
|
+
const ret = wasm.book_removeRows(this.__wbg_ptr, sheet, at, count);
|
|
1048
|
+
if (ret[1]) {
|
|
1049
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1050
|
+
}
|
|
1051
|
+
}
|
|
1052
|
+
/**
|
|
1053
|
+
* Removes a sheet. References to it from anywhere in the workbook become
|
|
1054
|
+
* `#REF!`, the way Excel writes them, and the sheets after it shift down
|
|
1055
|
+
* by one index.
|
|
1056
|
+
* @param {number} sheet
|
|
1057
|
+
*/
|
|
1058
|
+
removeSheet(sheet) {
|
|
1059
|
+
const ret = wasm.book_removeSheet(this.__wbg_ptr, sheet);
|
|
1060
|
+
if (ret[1]) {
|
|
1061
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
1064
|
+
/**
|
|
1065
|
+
* Removes a table by name. Answers whether there was one.
|
|
1066
|
+
* @param {number} sheet
|
|
1067
|
+
* @param {string} name
|
|
1068
|
+
* @returns {boolean}
|
|
1069
|
+
*/
|
|
1070
|
+
removeTable(sheet, name) {
|
|
1071
|
+
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1072
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1073
|
+
const ret = wasm.book_removeTable(this.__wbg_ptr, sheet, ptr0, len0);
|
|
1074
|
+
if (ret[2]) {
|
|
1075
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1076
|
+
}
|
|
1077
|
+
return ret[0] !== 0;
|
|
1078
|
+
}
|
|
1079
|
+
/**
|
|
1080
|
+
* Renames a sheet.
|
|
1081
|
+
* @param {number} sheet
|
|
1082
|
+
* @param {string} title
|
|
1083
|
+
*/
|
|
1084
|
+
renameSheet(sheet, title) {
|
|
1085
|
+
const ptr0 = passStringToWasm0(title, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1086
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1087
|
+
const ret = wasm.book_renameSheet(this.__wbg_ptr, sheet, ptr0, len0);
|
|
1088
|
+
if (ret[1]) {
|
|
1089
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1090
|
+
}
|
|
1091
|
+
}
|
|
1092
|
+
/**
|
|
1093
|
+
* The height of a row in points, or `undefined` when the sheet leaves it
|
|
1094
|
+
* to the default. `row` is the number a user sees.
|
|
1095
|
+
* @param {number} sheet
|
|
1096
|
+
* @param {number} row
|
|
1097
|
+
* @returns {number | undefined}
|
|
1098
|
+
*/
|
|
1099
|
+
rowHeight(sheet, row) {
|
|
1100
|
+
const ret = wasm.book_rowHeight(this.__wbg_ptr, sheet, row);
|
|
1101
|
+
if (ret[3]) {
|
|
1102
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1103
|
+
}
|
|
1104
|
+
return ret[0] === 0 ? undefined : ret[1];
|
|
1105
|
+
}
|
|
1106
|
+
/**
|
|
1107
|
+
* Whether a row is hidden. `row` is the number a user sees.
|
|
1108
|
+
* @param {number} sheet
|
|
1109
|
+
* @param {number} row
|
|
1110
|
+
* @returns {boolean}
|
|
1111
|
+
*/
|
|
1112
|
+
rowHidden(sheet, row) {
|
|
1113
|
+
const ret = wasm.book_rowHidden(this.__wbg_ptr, sheet, row);
|
|
1114
|
+
if (ret[2]) {
|
|
1115
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1116
|
+
}
|
|
1117
|
+
return ret[0] !== 0;
|
|
1118
|
+
}
|
|
1119
|
+
/**
|
|
1120
|
+
* How deeply a row is grouped: 0 when it is not, 1 for the outermost
|
|
1121
|
+
* group, and so on. `row` is the number a user sees.
|
|
1122
|
+
* @param {number} sheet
|
|
1123
|
+
* @param {number} row
|
|
1124
|
+
* @returns {number}
|
|
1125
|
+
*/
|
|
1126
|
+
rowLevel(sheet, row) {
|
|
1127
|
+
const ret = wasm.book_rowLevel(this.__wbg_ptr, sheet, row);
|
|
1128
|
+
if (ret[2]) {
|
|
1129
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1130
|
+
}
|
|
1131
|
+
return ret[0];
|
|
1132
|
+
}
|
|
1133
|
+
/**
|
|
1134
|
+
* Writes a value: a number, boolean, or string. A string starting with `=`
|
|
1135
|
+
* becomes a formula.
|
|
1136
|
+
* @param {number} index
|
|
1137
|
+
* @param {string} address
|
|
1138
|
+
* @param {CellValue} value
|
|
1139
|
+
*/
|
|
1140
|
+
set(index, address, value) {
|
|
646
1141
|
const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
647
1142
|
const len0 = WASM_VECTOR_LEN;
|
|
648
1143
|
const ret = wasm.book_set(this.__wbg_ptr, index, ptr0, len0, value);
|
|
@@ -673,6 +1168,139 @@ class Book {
|
|
|
673
1168
|
throw takeFromExternrefTable0(ret[0]);
|
|
674
1169
|
}
|
|
675
1170
|
}
|
|
1171
|
+
/**
|
|
1172
|
+
* Paints a cell: a number format, a font, a fill, borders, alignment, or
|
|
1173
|
+
* any part of those.
|
|
1174
|
+
*
|
|
1175
|
+
* The patch is laid over the style the cell has, so a field left out
|
|
1176
|
+
* keeps what was there - `{ font: { bold: true } }` does not reset the
|
|
1177
|
+
* number format. Equal styles share one entry in the workbook's table,
|
|
1178
|
+
* so painting a column costs one style, not one per cell.
|
|
1179
|
+
*
|
|
1180
|
+
* ```js
|
|
1181
|
+
* book.setCellStyle(0, "B2", {
|
|
1182
|
+
* numberFormat: "#,##0.00",
|
|
1183
|
+
* font: { bold: true, color: "#FF1F4E79" },
|
|
1184
|
+
* fill: { pattern: "solid", foreground: "#FFFFE699" },
|
|
1185
|
+
* alignment: { horizontal: "right" },
|
|
1186
|
+
* });
|
|
1187
|
+
* ```
|
|
1188
|
+
* @param {number} sheet
|
|
1189
|
+
* @param {string} address
|
|
1190
|
+
* @param {CellStylePatch} patch
|
|
1191
|
+
*/
|
|
1192
|
+
setCellStyle(sheet, address, patch) {
|
|
1193
|
+
const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1194
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1195
|
+
const ret = wasm.book_setCellStyle(this.__wbg_ptr, sheet, ptr0, len0, patch);
|
|
1196
|
+
if (ret[1]) {
|
|
1197
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1198
|
+
}
|
|
1199
|
+
}
|
|
1200
|
+
/**
|
|
1201
|
+
* The same by 1-based row and column.
|
|
1202
|
+
* @param {number} sheet
|
|
1203
|
+
* @param {number} row
|
|
1204
|
+
* @param {number} column
|
|
1205
|
+
* @param {CellStylePatch} patch
|
|
1206
|
+
*/
|
|
1207
|
+
setCellStyleAt(sheet, row, column, patch) {
|
|
1208
|
+
const ret = wasm.book_setCellStyleAt(this.__wbg_ptr, sheet, row, column, patch);
|
|
1209
|
+
if (ret[1]) {
|
|
1210
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1211
|
+
}
|
|
1212
|
+
}
|
|
1213
|
+
/**
|
|
1214
|
+
* Hides a column, or shows it again. `column` is 1-based.
|
|
1215
|
+
* @param {number} sheet
|
|
1216
|
+
* @param {number} column
|
|
1217
|
+
* @param {boolean} hidden
|
|
1218
|
+
*/
|
|
1219
|
+
setColumnHidden(sheet, column, hidden) {
|
|
1220
|
+
const ret = wasm.book_setColumnHidden(this.__wbg_ptr, sheet, column, hidden);
|
|
1221
|
+
if (ret[1]) {
|
|
1222
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1223
|
+
}
|
|
1224
|
+
}
|
|
1225
|
+
/**
|
|
1226
|
+
* Sets the width of a column in characters of the default font, or gives
|
|
1227
|
+
* it back to the sheet default with `undefined`. `column` is 1-based.
|
|
1228
|
+
*
|
|
1229
|
+
* A run of columns that covered this one is split around it, so the
|
|
1230
|
+
* neighbours keep the width they had.
|
|
1231
|
+
* @param {number} sheet
|
|
1232
|
+
* @param {number} column
|
|
1233
|
+
* @param {number | null} [width]
|
|
1234
|
+
*/
|
|
1235
|
+
setColumnWidth(sheet, column, width) {
|
|
1236
|
+
const ret = wasm.book_setColumnWidth(this.__wbg_ptr, sheet, column, !isLikeNone(width), isLikeNone(width) ? 0 : width);
|
|
1237
|
+
if (ret[1]) {
|
|
1238
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1239
|
+
}
|
|
1240
|
+
}
|
|
1241
|
+
/**
|
|
1242
|
+
* Puts a note on a cell, replacing any note already there.
|
|
1243
|
+
* @param {number} sheet
|
|
1244
|
+
* @param {string} address
|
|
1245
|
+
* @param {string} author
|
|
1246
|
+
* @param {string} text
|
|
1247
|
+
*/
|
|
1248
|
+
setComment(sheet, address, author, text) {
|
|
1249
|
+
const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1250
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1251
|
+
const ptr1 = passStringToWasm0(author, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1252
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1253
|
+
const ptr2 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1254
|
+
const len2 = WASM_VECTOR_LEN;
|
|
1255
|
+
const ret = wasm.book_setComment(this.__wbg_ptr, sheet, ptr0, len0, ptr1, len1, ptr2, len2);
|
|
1256
|
+
if (ret[1]) {
|
|
1257
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1258
|
+
}
|
|
1259
|
+
}
|
|
1260
|
+
/**
|
|
1261
|
+
* Defines a name, replacing one of the same name. `formula` is what it
|
|
1262
|
+
* stands for - `Sheet1!$A$1:$A$9` or a constant - and `sheet` makes the
|
|
1263
|
+
* name local to that sheet instead of the workbook.
|
|
1264
|
+
* @param {string} name
|
|
1265
|
+
* @param {string} formula
|
|
1266
|
+
* @param {number | null} [sheet]
|
|
1267
|
+
*/
|
|
1268
|
+
setDefinedName(name, formula, sheet) {
|
|
1269
|
+
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1270
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1271
|
+
const ptr1 = passStringToWasm0(formula, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1272
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1273
|
+
const ret = wasm.book_setDefinedName(this.__wbg_ptr, ptr0, len0, ptr1, len1, isLikeNone(sheet) ? Number.MAX_SAFE_INTEGER : (sheet) >>> 0);
|
|
1274
|
+
if (ret[1]) {
|
|
1275
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1276
|
+
}
|
|
1277
|
+
}
|
|
1278
|
+
/**
|
|
1279
|
+
* Puts a link over a cell or a block of them.
|
|
1280
|
+
*
|
|
1281
|
+
* `target` is a URL or a file path unless `inside` is true, and then it
|
|
1282
|
+
* is a place in this workbook: `'Sheet 2'!A1`.
|
|
1283
|
+
* @param {number} sheet
|
|
1284
|
+
* @param {string} range
|
|
1285
|
+
* @param {string} target
|
|
1286
|
+
* @param {boolean | null} [inside]
|
|
1287
|
+
* @param {string | null} [display]
|
|
1288
|
+
* @param {string | null} [tooltip]
|
|
1289
|
+
*/
|
|
1290
|
+
setHyperlink(sheet, range, target, inside, display, tooltip) {
|
|
1291
|
+
const ptr0 = passStringToWasm0(range, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1292
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1293
|
+
const ptr1 = passStringToWasm0(target, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1294
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1295
|
+
var ptr2 = isLikeNone(display) ? 0 : passStringToWasm0(display, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1296
|
+
var len2 = WASM_VECTOR_LEN;
|
|
1297
|
+
var ptr3 = isLikeNone(tooltip) ? 0 : passStringToWasm0(tooltip, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1298
|
+
var len3 = WASM_VECTOR_LEN;
|
|
1299
|
+
const ret = wasm.book_setHyperlink(this.__wbg_ptr, sheet, ptr0, len0, ptr1, len1, isLikeNone(inside) ? 0xFFFFFF : inside ? 1 : 0, ptr2, len2, ptr3, len3);
|
|
1300
|
+
if (ret[1]) {
|
|
1301
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1302
|
+
}
|
|
1303
|
+
}
|
|
676
1304
|
/**
|
|
677
1305
|
* Writes a rectangle of values with `at` as its top-left corner. Rows may
|
|
678
1306
|
* differ in length; a `null` leaves its cell empty.
|
|
@@ -701,6 +1329,102 @@ class Book {
|
|
|
701
1329
|
throw takeFromExternrefTable0(ret[0]);
|
|
702
1330
|
}
|
|
703
1331
|
}
|
|
1332
|
+
/**
|
|
1333
|
+
* The same over a rectangle: `setRangeStyle(0, "A1:D1", { font: { bold:
|
|
1334
|
+
* true } })`. Cells the range covers but the sheet has no value for are
|
|
1335
|
+
* created empty, which is what carries the style.
|
|
1336
|
+
* @param {number} sheet
|
|
1337
|
+
* @param {string} range
|
|
1338
|
+
* @param {CellStylePatch} patch
|
|
1339
|
+
*/
|
|
1340
|
+
setRangeStyle(sheet, range, patch) {
|
|
1341
|
+
const ptr0 = passStringToWasm0(range, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1342
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1343
|
+
const ret = wasm.book_setRangeStyle(this.__wbg_ptr, sheet, ptr0, len0, patch);
|
|
1344
|
+
if (ret[1]) {
|
|
1345
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1346
|
+
}
|
|
1347
|
+
}
|
|
1348
|
+
/**
|
|
1349
|
+
* Sets the height of a row in points, or gives it back to the sheet
|
|
1350
|
+
* default with `undefined`. `row` is the number a user sees.
|
|
1351
|
+
* @param {number} sheet
|
|
1352
|
+
* @param {number} row
|
|
1353
|
+
* @param {number | null} [height]
|
|
1354
|
+
*/
|
|
1355
|
+
setRowHeight(sheet, row, height) {
|
|
1356
|
+
const ret = wasm.book_setRowHeight(this.__wbg_ptr, sheet, row, !isLikeNone(height), isLikeNone(height) ? 0 : height);
|
|
1357
|
+
if (ret[1]) {
|
|
1358
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1359
|
+
}
|
|
1360
|
+
}
|
|
1361
|
+
/**
|
|
1362
|
+
* Hides a row, or shows it again.
|
|
1363
|
+
* @param {number} sheet
|
|
1364
|
+
* @param {number} row
|
|
1365
|
+
* @param {boolean} hidden
|
|
1366
|
+
*/
|
|
1367
|
+
setRowHidden(sheet, row, hidden) {
|
|
1368
|
+
const ret = wasm.book_setRowHidden(this.__wbg_ptr, sheet, row, hidden);
|
|
1369
|
+
if (ret[1]) {
|
|
1370
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1371
|
+
}
|
|
1372
|
+
}
|
|
1373
|
+
/**
|
|
1374
|
+
* Gives a sheet a tab or takes it away: `"visible"`, `"hidden"` or
|
|
1375
|
+
* `"veryHidden"`.
|
|
1376
|
+
*
|
|
1377
|
+
* A very hidden sheet is not in the dialog Excel offers for unhiding one.
|
|
1378
|
+
* Either way the sheet keeps its index, which is what every other call
|
|
1379
|
+
* counts.
|
|
1380
|
+
* @param {number} sheet
|
|
1381
|
+
* @param {string} state
|
|
1382
|
+
*/
|
|
1383
|
+
setSheetVisibility(sheet, state) {
|
|
1384
|
+
const ptr0 = passStringToWasm0(state, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1385
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1386
|
+
const ret = wasm.book_setSheetVisibility(this.__wbg_ptr, sheet, ptr0, len0);
|
|
1387
|
+
if (ret[1]) {
|
|
1388
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1389
|
+
}
|
|
1390
|
+
}
|
|
1391
|
+
/**
|
|
1392
|
+
* Shows or hides the grid lines, and the row and column headings with
|
|
1393
|
+
* `headers`.
|
|
1394
|
+
* @param {number} sheet
|
|
1395
|
+
* @param {boolean} show
|
|
1396
|
+
* @param {boolean | null} [headers]
|
|
1397
|
+
*/
|
|
1398
|
+
setShowGridLines(sheet, show, headers) {
|
|
1399
|
+
const ret = wasm.book_setShowGridLines(this.__wbg_ptr, sheet, show, isLikeNone(headers) ? 0xFFFFFF : headers ? 1 : 0);
|
|
1400
|
+
if (ret[1]) {
|
|
1401
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1402
|
+
}
|
|
1403
|
+
}
|
|
1404
|
+
/**
|
|
1405
|
+
* The zoom a reader opens the sheet at, in percent; `undefined` gives it
|
|
1406
|
+
* back to 100.
|
|
1407
|
+
* @param {number} sheet
|
|
1408
|
+
* @param {number | null} [percent]
|
|
1409
|
+
*/
|
|
1410
|
+
setZoom(sheet, percent) {
|
|
1411
|
+
const ret = wasm.book_setZoom(this.__wbg_ptr, sheet, isLikeNone(percent) ? Number.MAX_SAFE_INTEGER : (percent) >>> 0);
|
|
1412
|
+
if (ret[1]) {
|
|
1413
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1414
|
+
}
|
|
1415
|
+
}
|
|
1416
|
+
/**
|
|
1417
|
+
* The drawn shapes of a sheet, text and all.
|
|
1418
|
+
* @param {number} sheet
|
|
1419
|
+
* @returns {SheetShape[]}
|
|
1420
|
+
*/
|
|
1421
|
+
shapes(sheet) {
|
|
1422
|
+
const ret = wasm.book_shapes(this.__wbg_ptr, sheet);
|
|
1423
|
+
if (ret[2]) {
|
|
1424
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1425
|
+
}
|
|
1426
|
+
return takeFromExternrefTable0(ret[0]);
|
|
1427
|
+
}
|
|
704
1428
|
/**
|
|
705
1429
|
* The tab index of a sheet by name, or `undefined` when there is none.
|
|
706
1430
|
* Names are compared the way Excel does, ignoring case.
|
|
@@ -723,6 +1447,30 @@ class Book {
|
|
|
723
1447
|
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
724
1448
|
return v1;
|
|
725
1449
|
}
|
|
1450
|
+
/**
|
|
1451
|
+
* Whether a sheet is locked, and whether the lock has a password.
|
|
1452
|
+
* @param {number} sheet
|
|
1453
|
+
* @returns {ProtectionInfo}
|
|
1454
|
+
*/
|
|
1455
|
+
sheetProtection(sheet) {
|
|
1456
|
+
const ret = wasm.book_sheetProtection(this.__wbg_ptr, sheet);
|
|
1457
|
+
if (ret[2]) {
|
|
1458
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1459
|
+
}
|
|
1460
|
+
return takeFromExternrefTable0(ret[0]);
|
|
1461
|
+
}
|
|
1462
|
+
/**
|
|
1463
|
+
* How the sheet is frozen and shown.
|
|
1464
|
+
* @param {number} sheet
|
|
1465
|
+
* @returns {SheetViewInfo}
|
|
1466
|
+
*/
|
|
1467
|
+
sheetView(sheet) {
|
|
1468
|
+
const ret = wasm.book_sheetView(this.__wbg_ptr, sheet);
|
|
1469
|
+
if (ret[2]) {
|
|
1470
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1471
|
+
}
|
|
1472
|
+
return takeFromExternrefTable0(ret[0]);
|
|
1473
|
+
}
|
|
726
1474
|
/**
|
|
727
1475
|
* Whether a sheet has a tab: `"visible"`, `"hidden"` or `"veryHidden"`.
|
|
728
1476
|
*
|
|
@@ -750,7 +1498,20 @@ class Book {
|
|
|
750
1498
|
}
|
|
751
1499
|
}
|
|
752
1500
|
/**
|
|
753
|
-
*
|
|
1501
|
+
* The tables of a sheet: what a structured reference like `Sales[Amount]`
|
|
1502
|
+
* names.
|
|
1503
|
+
* @param {number} sheet
|
|
1504
|
+
* @returns {SheetTable[]}
|
|
1505
|
+
*/
|
|
1506
|
+
tables(sheet) {
|
|
1507
|
+
const ret = wasm.book_tables(this.__wbg_ptr, sheet);
|
|
1508
|
+
if (ret[2]) {
|
|
1509
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1510
|
+
}
|
|
1511
|
+
return takeFromExternrefTable0(ret[0]);
|
|
1512
|
+
}
|
|
1513
|
+
/**
|
|
1514
|
+
* One sheet as CSV, comma-separated.
|
|
754
1515
|
* @param {number} sheet
|
|
755
1516
|
* @returns {string}
|
|
756
1517
|
*/
|
|
@@ -772,6 +1533,31 @@ class Book {
|
|
|
772
1533
|
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
773
1534
|
}
|
|
774
1535
|
}
|
|
1536
|
+
/**
|
|
1537
|
+
* The same with the delimiter stated - a semicolon for a locale where the
|
|
1538
|
+
* comma is the decimal mark.
|
|
1539
|
+
* @param {number} sheet
|
|
1540
|
+
* @param {CsvOptions} options
|
|
1541
|
+
* @returns {string}
|
|
1542
|
+
*/
|
|
1543
|
+
toCsvWith(sheet, options) {
|
|
1544
|
+
let deferred2_0;
|
|
1545
|
+
let deferred2_1;
|
|
1546
|
+
try {
|
|
1547
|
+
const ret = wasm.book_toCsvWith(this.__wbg_ptr, sheet, options);
|
|
1548
|
+
var ptr1 = ret[0];
|
|
1549
|
+
var len1 = ret[1];
|
|
1550
|
+
if (ret[3]) {
|
|
1551
|
+
ptr1 = 0; len1 = 0;
|
|
1552
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1553
|
+
}
|
|
1554
|
+
deferred2_0 = ptr1;
|
|
1555
|
+
deferred2_1 = len1;
|
|
1556
|
+
return getStringFromWasm0(ptr1, len1);
|
|
1557
|
+
} finally {
|
|
1558
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
1559
|
+
}
|
|
1560
|
+
}
|
|
775
1561
|
/**
|
|
776
1562
|
* The workbook as an HTML page, or one sheet of it. `fragment` leaves out
|
|
777
1563
|
* the `<html>` wrapper, for embedding in a page that already has one.
|
|
@@ -840,6 +1626,47 @@ class Book {
|
|
|
840
1626
|
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
841
1627
|
return v1;
|
|
842
1628
|
}
|
|
1629
|
+
/**
|
|
1630
|
+
* Unfreezes the panes. The same as `freezePanes(sheet, 0, 0)`.
|
|
1631
|
+
* @param {number} sheet
|
|
1632
|
+
*/
|
|
1633
|
+
unfreezePanes(sheet) {
|
|
1634
|
+
const ret = wasm.book_unfreezePanes(this.__wbg_ptr, sheet);
|
|
1635
|
+
if (ret[1]) {
|
|
1636
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1637
|
+
}
|
|
1638
|
+
}
|
|
1639
|
+
/**
|
|
1640
|
+
* Takes a merge back out. Answers whether there was one.
|
|
1641
|
+
* @param {number} sheet
|
|
1642
|
+
* @param {string} range
|
|
1643
|
+
* @returns {boolean}
|
|
1644
|
+
*/
|
|
1645
|
+
unmerge(sheet, range) {
|
|
1646
|
+
const ptr0 = passStringToWasm0(range, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1647
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1648
|
+
const ret = wasm.book_unmerge(this.__wbg_ptr, sheet, ptr0, len0);
|
|
1649
|
+
if (ret[2]) {
|
|
1650
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1651
|
+
}
|
|
1652
|
+
return ret[0] !== 0;
|
|
1653
|
+
}
|
|
1654
|
+
/**
|
|
1655
|
+
* Unlocks a sheet, password and all.
|
|
1656
|
+
* @param {number} sheet
|
|
1657
|
+
*/
|
|
1658
|
+
unprotectSheet(sheet) {
|
|
1659
|
+
const ret = wasm.book_unprotectSheet(this.__wbg_ptr, sheet);
|
|
1660
|
+
if (ret[1]) {
|
|
1661
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1662
|
+
}
|
|
1663
|
+
}
|
|
1664
|
+
/**
|
|
1665
|
+
* Unlocks the workbook.
|
|
1666
|
+
*/
|
|
1667
|
+
unprotectWorkbook() {
|
|
1668
|
+
wasm.book_unprotectWorkbook(this.__wbg_ptr);
|
|
1669
|
+
}
|
|
843
1670
|
/**
|
|
844
1671
|
* Forgets a function registered earlier; answers whether there was one.
|
|
845
1672
|
* @param {string} name
|
|
@@ -866,6 +1693,53 @@ class Book {
|
|
|
866
1693
|
}
|
|
867
1694
|
return v1;
|
|
868
1695
|
}
|
|
1696
|
+
/**
|
|
1697
|
+
* The used range of a sheet as `"A1:D20"`, taken from what the file says
|
|
1698
|
+
* rather than from walking the cells; `undefined` when it says nothing.
|
|
1699
|
+
*
|
|
1700
|
+
* A reader that only needs the shape of a sheet pays nothing for it;
|
|
1701
|
+
* `usedRange` walks every cell and answers for a sheet built in memory
|
|
1702
|
+
* too, where the file has nothing to say.
|
|
1703
|
+
* @param {number} sheet
|
|
1704
|
+
* @returns {string | undefined}
|
|
1705
|
+
*/
|
|
1706
|
+
usedRangeHint(sheet) {
|
|
1707
|
+
const ret = wasm.book_usedRangeHint(this.__wbg_ptr, sheet);
|
|
1708
|
+
if (ret[3]) {
|
|
1709
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1710
|
+
}
|
|
1711
|
+
let v1;
|
|
1712
|
+
if (ret[0] !== 0) {
|
|
1713
|
+
v1 = getStringFromWasm0(ret[0], ret[1]);
|
|
1714
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
1715
|
+
}
|
|
1716
|
+
return v1;
|
|
1717
|
+
}
|
|
1718
|
+
/**
|
|
1719
|
+
* Whether that password unlocks the sheet. `false` for a sheet with no
|
|
1720
|
+
* password on it, and for a hash this crate cannot check.
|
|
1721
|
+
* @param {number} sheet
|
|
1722
|
+
* @param {string} password
|
|
1723
|
+
* @returns {boolean}
|
|
1724
|
+
*/
|
|
1725
|
+
verifySheetPassword(sheet, password) {
|
|
1726
|
+
const ptr0 = passStringToWasm0(password, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1727
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1728
|
+
const ret = wasm.book_verifySheetPassword(this.__wbg_ptr, sheet, ptr0, len0);
|
|
1729
|
+
if (ret[2]) {
|
|
1730
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1731
|
+
}
|
|
1732
|
+
return ret[0] !== 0;
|
|
1733
|
+
}
|
|
1734
|
+
/**
|
|
1735
|
+
* Whether the workbook's structure is locked, and whether behind a
|
|
1736
|
+
* password.
|
|
1737
|
+
* @returns {ProtectionInfo}
|
|
1738
|
+
*/
|
|
1739
|
+
workbookProtection() {
|
|
1740
|
+
const ret = wasm.book_workbookProtection(this.__wbg_ptr);
|
|
1741
|
+
return ret;
|
|
1742
|
+
}
|
|
869
1743
|
}
|
|
870
1744
|
if (Symbol.dispose) Book.prototype[Symbol.dispose] = Book.prototype.free;
|
|
871
1745
|
exports.Book = Book;
|
|
@@ -881,10 +1755,19 @@ function __wbg_get_imports() {
|
|
|
881
1755
|
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
882
1756
|
return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
|
|
883
1757
|
},
|
|
1758
|
+
__wbg___wbindgen_is_falsy_b7464e97ddc1b7a4: function(arg0) {
|
|
1759
|
+
const ret = !arg0;
|
|
1760
|
+
return ret;
|
|
1761
|
+
},
|
|
884
1762
|
__wbg___wbindgen_is_null_7d13f41e1a2d5140: function(arg0) {
|
|
885
1763
|
const ret = arg0 === null;
|
|
886
1764
|
return ret;
|
|
887
1765
|
},
|
|
1766
|
+
__wbg___wbindgen_is_object_a2790eb24c211ea0: function(arg0) {
|
|
1767
|
+
const val = arg0;
|
|
1768
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
1769
|
+
return ret;
|
|
1770
|
+
},
|
|
888
1771
|
__wbg___wbindgen_is_undefined_6cff064c44e0d823: function(arg0) {
|
|
889
1772
|
const ret = arg0 === undefined;
|
|
890
1773
|
return ret;
|
|
@@ -921,6 +1804,10 @@ function __wbg_get_imports() {
|
|
|
921
1804
|
const ret = arg0.getTime();
|
|
922
1805
|
return ret;
|
|
923
1806
|
},
|
|
1807
|
+
__wbg_get_971a0c45d172643f: function() { return handleError(function (arg0, arg1) {
|
|
1808
|
+
const ret = Reflect.get(arg0, arg1);
|
|
1809
|
+
return ret;
|
|
1810
|
+
}, arguments); },
|
|
924
1811
|
__wbg_get_unchecked_e20b893aeafc3fca: function(arg0, arg1) {
|
|
925
1812
|
const ret = arg0[arg1 >>> 0];
|
|
926
1813
|
return ret;
|