@rosperitus/excelerate 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/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,77 @@ 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
+ * Copies the first row of a range into the rows below it, as Ctrl+D.
371
+ * @param {number} sheet
372
+ * @param {string} range
373
+ */
374
+ fillDown(sheet, range) {
375
+ const ptr0 = passStringToWasm0(range, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
376
+ const len0 = WASM_VECTOR_LEN;
377
+ const ret = wasm.book_fillDown(this.__wbg_ptr, sheet, ptr0, len0);
378
+ if (ret[1]) {
379
+ throw takeFromExternrefTable0(ret[0]);
380
+ }
381
+ }
382
+ /**
383
+ * Copies the first column of a range into the columns to its right, as
384
+ * Ctrl+R.
385
+ * @param {number} sheet
386
+ * @param {string} range
387
+ */
388
+ fillRight(sheet, range) {
389
+ const ptr0 = passStringToWasm0(range, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
390
+ const len0 = WASM_VECTOR_LEN;
391
+ const ret = wasm.book_fillRight(this.__wbg_ptr, sheet, ptr0, len0);
392
+ if (ret[1]) {
393
+ throw takeFromExternrefTable0(ret[0]);
394
+ }
395
+ }
396
+ /**
397
+ * Continues what the first cells of a range start, as dragging the fill
398
+ * handle does: `1, 2` goes on `3, 4`, `Кв1` to `Кв2`, `Jan` to `Feb`, a
399
+ * date by a day; anything else repeats. `"down"` fills each column,
400
+ * `"right"` each row; `"up"` and `"left"` run the series back from the
401
+ * last cells.
402
+ * @param {number} sheet
403
+ * @param {string} range
404
+ * @param {"down" | "right" | "up" | "left"} direction
405
+ */
406
+ fillSeries(sheet, range, direction) {
407
+ const ptr0 = passStringToWasm0(range, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
408
+ const len0 = WASM_VECTOR_LEN;
409
+ const ptr1 = passStringToWasm0(direction, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
410
+ const len1 = WASM_VECTOR_LEN;
411
+ const ret = wasm.book_fillSeries(this.__wbg_ptr, sheet, ptr0, len0, ptr1, len1);
412
+ if (ret[1]) {
413
+ throw takeFromExternrefTable0(ret[0]);
414
+ }
415
+ }
416
+ /**
417
+ * Freezes the first `rows` rows and `columns` columns, so they stay put
418
+ * while the rest scrolls. `freezePanes(0, 1, 0)` pins the header row.
419
+ * @param {number} sheet
420
+ * @param {number} rows
421
+ * @param {number} columns
422
+ */
423
+ freezePanes(sheet, rows, columns) {
424
+ const ret = wasm.book_freezePanes(this.__wbg_ptr, sheet, rows, columns);
425
+ if (ret[1]) {
426
+ throw takeFromExternrefTable0(ret[0]);
427
+ }
428
+ }
212
429
  /**
213
430
  * Reads an xlsx package from its bytes.
214
431
  * @param {Uint8Array} bytes
@@ -374,6 +591,40 @@ class Book {
374
591
  }
375
592
  return takeFromExternrefTable0(ret[0]);
376
593
  }
594
+ /**
595
+ * The styles of a rectangle in one call: each distinct style once, and a
596
+ * grid of indexes into them. `cellStyle` per cell costs a crossing and a
597
+ * whole style object per cell; a formatted table of ten thousand cells
598
+ * usually has a dozen styles.
599
+ * @param {number} sheet
600
+ * @param {string} range
601
+ * @returns {RangeStyles}
602
+ */
603
+ getRangeStyles(sheet, range) {
604
+ const ptr0 = passStringToWasm0(range, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
605
+ const len0 = WASM_VECTOR_LEN;
606
+ const ret = wasm.book_getRangeStyles(this.__wbg_ptr, sheet, ptr0, len0);
607
+ if (ret[2]) {
608
+ throw takeFromExternrefTable0(ret[1]);
609
+ }
610
+ return takeFromExternrefTable0(ret[0]);
611
+ }
612
+ /**
613
+ * The same by numbers, as `getRangeAt` takes them.
614
+ * @param {number} sheet
615
+ * @param {number} row
616
+ * @param {number} column
617
+ * @param {number} rows
618
+ * @param {number} columns
619
+ * @returns {RangeStyles}
620
+ */
621
+ getRangeStylesAt(sheet, row, column, rows, columns) {
622
+ const ret = wasm.book_getRangeStylesAt(this.__wbg_ptr, sheet, row, column, rows, columns);
623
+ if (ret[2]) {
624
+ throw takeFromExternrefTable0(ret[1]);
625
+ }
626
+ return takeFromExternrefTable0(ret[0]);
627
+ }
377
628
  /**
378
629
  * A whole row in one crossing of the boundary: values, displayed text,
379
630
  * bold and indent, plus whether the row is hidden.
@@ -397,6 +648,119 @@ class Book {
397
648
  }
398
649
  return takeFromExternrefTable0(ret[0]);
399
650
  }
651
+ /**
652
+ * The hyperlinks of a sheet. `external` tells a URL from a jump inside
653
+ * the workbook.
654
+ * @param {number} sheet
655
+ * @returns {SheetHyperlink[]}
656
+ */
657
+ hyperlinks(sheet) {
658
+ const ret = wasm.book_hyperlinks(this.__wbg_ptr, sheet);
659
+ if (ret[2]) {
660
+ throw takeFromExternrefTable0(ret[1]);
661
+ }
662
+ return takeFromExternrefTable0(ret[0]);
663
+ }
664
+ /**
665
+ * The bytes of one picture, by its position in `images`.
666
+ * @param {number} sheet
667
+ * @param {number} index
668
+ * @returns {Uint8Array}
669
+ */
670
+ imageData(sheet, index) {
671
+ const ret = wasm.book_imageData(this.__wbg_ptr, sheet, index);
672
+ if (ret[3]) {
673
+ throw takeFromExternrefTable0(ret[2]);
674
+ }
675
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
676
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
677
+ return v1;
678
+ }
679
+ /**
680
+ * The pictures on a sheet, without their bytes: `imageData` fetches those
681
+ * for the one that is wanted.
682
+ * @param {number} sheet
683
+ * @returns {SheetImage[]}
684
+ */
685
+ images(sheet) {
686
+ const ret = wasm.book_images(this.__wbg_ptr, sheet);
687
+ if (ret[2]) {
688
+ throw takeFromExternrefTable0(ret[1]);
689
+ }
690
+ return takeFromExternrefTable0(ret[0]);
691
+ }
692
+ /**
693
+ * Inserts blank cells over a range, pushing what was there `"down"` or
694
+ * `"right"` - Excel's "Insert Cells", which moves part of a row rather
695
+ * than the whole of it. `copyOrigin` works as in `insertRows`.
696
+ * @param {number} sheet
697
+ * @param {string} range
698
+ * @param {string} shift
699
+ * @param {"before" | "after" | "none"} [copyOrigin]
700
+ */
701
+ insertCells(sheet, range, shift, copyOrigin) {
702
+ const ptr0 = passStringToWasm0(range, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
703
+ const len0 = WASM_VECTOR_LEN;
704
+ const ptr1 = passStringToWasm0(shift, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
705
+ const len1 = WASM_VECTOR_LEN;
706
+ var ptr2 = isLikeNone(copyOrigin) ? 0 : passStringToWasm0(copyOrigin, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
707
+ var len2 = WASM_VECTOR_LEN;
708
+ const ret = wasm.book_insertCells(this.__wbg_ptr, sheet, ptr0, len0, ptr1, len1, ptr2, len2);
709
+ if (ret[1]) {
710
+ throw takeFromExternrefTable0(ret[0]);
711
+ }
712
+ }
713
+ /**
714
+ * Inserts `count` columns to the left of column `at`, 1-based.
715
+ * `copyOrigin` works as in `insertRows`, with left and right.
716
+ * @param {number} sheet
717
+ * @param {number} at
718
+ * @param {number} count
719
+ * @param {"before" | "after" | "none"} [copyOrigin]
720
+ */
721
+ insertColumns(sheet, at, count, copyOrigin) {
722
+ var ptr0 = isLikeNone(copyOrigin) ? 0 : passStringToWasm0(copyOrigin, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
723
+ var len0 = WASM_VECTOR_LEN;
724
+ const ret = wasm.book_insertColumns(this.__wbg_ptr, sheet, at, count, ptr0, len0);
725
+ if (ret[1]) {
726
+ throw takeFromExternrefTable0(ret[0]);
727
+ }
728
+ }
729
+ /**
730
+ * Inserts `count` rows above row `at`, moving everything below down.
731
+ * `copyOrigin` - `"before"` (the row above), `"after"` (the row below)
732
+ * or `"none"` - says whose formatting the new rows take. Left out, it is
733
+ * `"before"`, as in Excel.
734
+ *
735
+ * Formulas across the whole workbook follow the cells they read, and so
736
+ * do merges, links, validations, tables and drawings. `at` is the number
737
+ * a user sees.
738
+ * @param {number} sheet
739
+ * @param {number} at
740
+ * @param {number} count
741
+ * @param {"before" | "after" | "none"} [copyOrigin]
742
+ */
743
+ insertRows(sheet, at, count, copyOrigin) {
744
+ var ptr0 = isLikeNone(copyOrigin) ? 0 : passStringToWasm0(copyOrigin, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
745
+ var len0 = WASM_VECTOR_LEN;
746
+ const ret = wasm.book_insertRows(this.__wbg_ptr, sheet, at, count, ptr0, len0);
747
+ if (ret[1]) {
748
+ throw takeFromExternrefTable0(ret[0]);
749
+ }
750
+ }
751
+ /**
752
+ * Merges a block of cells: `merge(0, "A1:C1")`.
753
+ * @param {number} sheet
754
+ * @param {string} range
755
+ */
756
+ merge(sheet, range) {
757
+ const ptr0 = passStringToWasm0(range, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
758
+ const len0 = WASM_VECTOR_LEN;
759
+ const ret = wasm.book_merge(this.__wbg_ptr, sheet, ptr0, len0);
760
+ if (ret[1]) {
761
+ throw takeFromExternrefTable0(ret[0]);
762
+ }
763
+ }
400
764
  /**
401
765
  * The merged areas of a sheet, as `"A1:C1"` strings in the order the file
402
766
  * lists them.
@@ -428,6 +792,40 @@ class Book {
428
792
  }
429
793
  return takeFromExternrefTable0(ret[0]);
430
794
  }
795
+ /**
796
+ * Moves a rectangle of cells, leaving the source empty.
797
+ *
798
+ * A moved formula keeps reading the cells it read; the formulas elsewhere
799
+ * that read *these* cells follow them instead, as they do when Excel cuts
800
+ * and pastes.
801
+ * @param {number} sheet
802
+ * @param {string} range
803
+ * @param {string} to
804
+ * @param {number | null} [to_sheet]
805
+ */
806
+ moveRange(sheet, range, to, to_sheet) {
807
+ const ptr0 = passStringToWasm0(range, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
808
+ const len0 = WASM_VECTOR_LEN;
809
+ const ptr1 = passStringToWasm0(to, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
810
+ const len1 = WASM_VECTOR_LEN;
811
+ const ret = wasm.book_moveRange(this.__wbg_ptr, sheet, ptr0, len0, ptr1, len1, isLikeNone(to_sheet) ? Number.MAX_SAFE_INTEGER : (to_sheet) >>> 0);
812
+ if (ret[1]) {
813
+ throw takeFromExternrefTable0(ret[0]);
814
+ }
815
+ }
816
+ /**
817
+ * Moves a sheet along the tab bar. Formulas are untouched - a sheet is
818
+ * named, not numbered - but every index moves, this one included, so read
819
+ * `sheetIndex` again afterwards.
820
+ * @param {number} from
821
+ * @param {number} to
822
+ */
823
+ moveSheet(from, to) {
824
+ const ret = wasm.book_moveSheet(this.__wbg_ptr, from, to);
825
+ if (ret[1]) {
826
+ throw takeFromExternrefTable0(ret[0]);
827
+ }
828
+ }
431
829
  /**
432
830
  * A new workbook with one empty sheet.
433
831
  */
@@ -438,29 +836,95 @@ class Book {
438
836
  return this;
439
837
  }
440
838
  /**
441
- * Reads a workbook of any format this crate supports, working the format
442
- * out from the bytes themselves.
443
- *
444
- * `name` is the file name they came from, if the caller has one: it
445
- * settles what the bytes cannot say (a `.csv` against a `.html`) and names
446
- * the sheet of a SYLK file.
447
- * @param {Uint8Array} bytes
448
- * @param {string | null} [name]
449
- * @param {number | null} [max_expanded]
450
- * @param {Function | null} [on_progress]
451
- * @returns {Book}
839
+ * The pivot reports laid out on a sheet. The numbers they show are cells
840
+ * like any others; this says where a report sits and how wide its axes
841
+ * are.
842
+ * @param {number} sheet
843
+ * @returns {SheetPivotTable[]}
452
844
  */
453
- static read(bytes, name, max_expanded, on_progress) {
454
- const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
455
- const len0 = WASM_VECTOR_LEN;
456
- var ptr1 = isLikeNone(name) ? 0 : passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
457
- var len1 = WASM_VECTOR_LEN;
845
+ pivotTables(sheet) {
846
+ const ret = wasm.book_pivotTables(this.__wbg_ptr, sheet);
847
+ if (ret[2]) {
848
+ throw takeFromExternrefTable0(ret[1]);
849
+ }
850
+ return takeFromExternrefTable0(ret[0]);
851
+ }
852
+ /**
853
+ * Locks a sheet against editing, optionally behind a password.
854
+ *
855
+ * This is the lock Excel offers under "Protect Sheet": it stops a user
856
+ * editing, it does not encrypt anything. The password is stored as Excel
857
+ * stores it - SHA-512 over a random salt, 100,000 spins - and
858
+ * `verifySheetPassword` checks it back.
859
+ * @param {number} sheet
860
+ * @param {string | null} [password]
861
+ */
862
+ protectSheet(sheet, password) {
863
+ var ptr0 = isLikeNone(password) ? 0 : passStringToWasm0(password, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
864
+ var len0 = WASM_VECTOR_LEN;
865
+ const ret = wasm.book_protectSheet(this.__wbg_ptr, sheet, ptr0, len0);
866
+ if (ret[1]) {
867
+ throw takeFromExternrefTable0(ret[0]);
868
+ }
869
+ }
870
+ /**
871
+ * Locks the structure of the workbook: which sheets there are, and their
872
+ * order. `windows` locks the window layout as well.
873
+ * @param {string | null} [password]
874
+ * @param {boolean | null} [windows]
875
+ */
876
+ protectWorkbook(password, windows) {
877
+ var ptr0 = isLikeNone(password) ? 0 : passStringToWasm0(password, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
878
+ var len0 = WASM_VECTOR_LEN;
879
+ const ret = wasm.book_protectWorkbook(this.__wbg_ptr, ptr0, len0, isLikeNone(windows) ? 0xFFFFFF : windows ? 1 : 0);
880
+ if (ret[1]) {
881
+ throw takeFromExternrefTable0(ret[0]);
882
+ }
883
+ }
884
+ /**
885
+ * Reads a workbook of any format this crate supports, working the format
886
+ * out from the bytes themselves.
887
+ *
888
+ * `name` is the file name they came from, if the caller has one: it
889
+ * settles what the bytes cannot say (a `.csv` against a `.html`) and names
890
+ * the sheet of a SYLK file.
891
+ * @param {Uint8Array} bytes
892
+ * @param {string | null} [name]
893
+ * @param {number | null} [max_expanded]
894
+ * @param {Function | null} [on_progress]
895
+ * @returns {Book}
896
+ */
897
+ static read(bytes, name, max_expanded, on_progress) {
898
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
899
+ const len0 = WASM_VECTOR_LEN;
900
+ var ptr1 = isLikeNone(name) ? 0 : passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
901
+ var len1 = WASM_VECTOR_LEN;
458
902
  const ret = wasm.book_read(ptr0, len0, ptr1, len1, !isLikeNone(max_expanded), isLikeNone(max_expanded) ? 0 : max_expanded, isLikeNone(on_progress) ? 0 : addToExternrefTable0(on_progress));
459
903
  if (ret[2]) {
460
904
  throw takeFromExternrefTable0(ret[1]);
461
905
  }
462
906
  return Book.__wrap(ret[0]);
463
907
  }
908
+ /**
909
+ * Reads CSV with the guesses overridden: the delimiter, whether a row
910
+ * that produced no cell is skipped, whether an empty field becomes an
911
+ * empty string rather than no cell at all.
912
+ *
913
+ * `Book.read` guesses all of this from the bytes, which is right for a
914
+ * file of unknown origin; this is for one whose shape you already know.
915
+ * @param {Uint8Array} bytes
916
+ * @param {CsvOptions} options
917
+ * @returns {Book}
918
+ */
919
+ static readCsv(bytes, options) {
920
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
921
+ const len0 = WASM_VECTOR_LEN;
922
+ const ret = wasm.book_readCsv(ptr0, len0, options);
923
+ if (ret[2]) {
924
+ throw takeFromExternrefTable0(ret[1]);
925
+ }
926
+ return Book.__wrap(ret[0]);
927
+ }
464
928
  /**
465
929
  * Recomputes every formula and stores the results beside them, so that
466
930
  * `get` and `toCsv` show this engine's answers rather than the cache the
@@ -595,6 +1059,117 @@ class Book {
595
1059
  wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
596
1060
  return v1;
597
1061
  }
1062
+ /**
1063
+ * Removes the cells of a range, pulling the rest back over the hole from
1064
+ * below (`"up"`) or from the right (`"left"`).
1065
+ * @param {number} sheet
1066
+ * @param {string} range
1067
+ * @param {string} shift
1068
+ */
1069
+ removeCells(sheet, range, shift) {
1070
+ const ptr0 = passStringToWasm0(range, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1071
+ const len0 = WASM_VECTOR_LEN;
1072
+ const ptr1 = passStringToWasm0(shift, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1073
+ const len1 = WASM_VECTOR_LEN;
1074
+ const ret = wasm.book_removeCells(this.__wbg_ptr, sheet, ptr0, len0, ptr1, len1);
1075
+ if (ret[1]) {
1076
+ throw takeFromExternrefTable0(ret[0]);
1077
+ }
1078
+ }
1079
+ /**
1080
+ * Removes `count` columns from column `at`, 1-based.
1081
+ * @param {number} sheet
1082
+ * @param {number} at
1083
+ * @param {number} count
1084
+ */
1085
+ removeColumns(sheet, at, count) {
1086
+ const ret = wasm.book_removeColumns(this.__wbg_ptr, sheet, at, count);
1087
+ if (ret[1]) {
1088
+ throw takeFromExternrefTable0(ret[0]);
1089
+ }
1090
+ }
1091
+ /**
1092
+ * Takes a note off a cell. Answers whether there was one.
1093
+ * @param {number} sheet
1094
+ * @param {string} address
1095
+ * @returns {boolean}
1096
+ */
1097
+ removeComment(sheet, address) {
1098
+ const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1099
+ const len0 = WASM_VECTOR_LEN;
1100
+ const ret = wasm.book_removeComment(this.__wbg_ptr, sheet, ptr0, len0);
1101
+ if (ret[2]) {
1102
+ throw takeFromExternrefTable0(ret[1]);
1103
+ }
1104
+ return ret[0] !== 0;
1105
+ }
1106
+ /**
1107
+ * Removes a defined name. Answers whether there was one.
1108
+ * @param {string} name
1109
+ * @param {number | null} [sheet]
1110
+ * @returns {boolean}
1111
+ */
1112
+ removeDefinedName(name, sheet) {
1113
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1114
+ const len0 = WASM_VECTOR_LEN;
1115
+ const ret = wasm.book_removeDefinedName(this.__wbg_ptr, ptr0, len0, isLikeNone(sheet) ? Number.MAX_SAFE_INTEGER : (sheet) >>> 0);
1116
+ return ret !== 0;
1117
+ }
1118
+ /**
1119
+ * Takes the link off a range. Answers whether there was one.
1120
+ * @param {number} sheet
1121
+ * @param {string} range
1122
+ * @returns {boolean}
1123
+ */
1124
+ removeHyperlink(sheet, range) {
1125
+ const ptr0 = passStringToWasm0(range, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1126
+ const len0 = WASM_VECTOR_LEN;
1127
+ const ret = wasm.book_removeHyperlink(this.__wbg_ptr, sheet, ptr0, len0);
1128
+ if (ret[2]) {
1129
+ throw takeFromExternrefTable0(ret[1]);
1130
+ }
1131
+ return ret[0] !== 0;
1132
+ }
1133
+ /**
1134
+ * Removes `count` rows from row `at` down. A formula that read a removed
1135
+ * cell reads `#REF!` afterwards.
1136
+ * @param {number} sheet
1137
+ * @param {number} at
1138
+ * @param {number} count
1139
+ */
1140
+ removeRows(sheet, at, count) {
1141
+ const ret = wasm.book_removeRows(this.__wbg_ptr, sheet, at, count);
1142
+ if (ret[1]) {
1143
+ throw takeFromExternrefTable0(ret[0]);
1144
+ }
1145
+ }
1146
+ /**
1147
+ * Removes a sheet. References to it from anywhere in the workbook become
1148
+ * `#REF!`, the way Excel writes them, and the sheets after it shift down
1149
+ * by one index.
1150
+ * @param {number} sheet
1151
+ */
1152
+ removeSheet(sheet) {
1153
+ const ret = wasm.book_removeSheet(this.__wbg_ptr, sheet);
1154
+ if (ret[1]) {
1155
+ throw takeFromExternrefTable0(ret[0]);
1156
+ }
1157
+ }
1158
+ /**
1159
+ * Removes a table by name. Answers whether there was one.
1160
+ * @param {number} sheet
1161
+ * @param {string} name
1162
+ * @returns {boolean}
1163
+ */
1164
+ removeTable(sheet, name) {
1165
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1166
+ const len0 = WASM_VECTOR_LEN;
1167
+ const ret = wasm.book_removeTable(this.__wbg_ptr, sheet, ptr0, len0);
1168
+ if (ret[2]) {
1169
+ throw takeFromExternrefTable0(ret[1]);
1170
+ }
1171
+ return ret[0] !== 0;
1172
+ }
598
1173
  /**
599
1174
  * Renames a sheet.
600
1175
  * @param {number} sheet
@@ -608,6 +1183,20 @@ class Book {
608
1183
  throw takeFromExternrefTable0(ret[0]);
609
1184
  }
610
1185
  }
1186
+ /**
1187
+ * The height of a row in points, or `undefined` when the sheet leaves it
1188
+ * to the default. `row` is the number a user sees.
1189
+ * @param {number} sheet
1190
+ * @param {number} row
1191
+ * @returns {number | undefined}
1192
+ */
1193
+ rowHeight(sheet, row) {
1194
+ const ret = wasm.book_rowHeight(this.__wbg_ptr, sheet, row);
1195
+ if (ret[3]) {
1196
+ throw takeFromExternrefTable0(ret[2]);
1197
+ }
1198
+ return ret[0] === 0 ? undefined : ret[1];
1199
+ }
611
1200
  /**
612
1201
  * Whether a row is hidden. `row` is the number a user sees.
613
1202
  * @param {number} sheet
@@ -673,6 +1262,139 @@ class Book {
673
1262
  throw takeFromExternrefTable0(ret[0]);
674
1263
  }
675
1264
  }
1265
+ /**
1266
+ * Paints a cell: a number format, a font, a fill, borders, alignment, or
1267
+ * any part of those.
1268
+ *
1269
+ * The patch is laid over the style the cell has, so a field left out
1270
+ * keeps what was there - `{ font: { bold: true } }` does not reset the
1271
+ * number format. Equal styles share one entry in the workbook's table,
1272
+ * so painting a column costs one style, not one per cell.
1273
+ *
1274
+ * ```js
1275
+ * book.setCellStyle(0, "B2", {
1276
+ * numberFormat: "#,##0.00",
1277
+ * font: { bold: true, color: "#FF1F4E79" },
1278
+ * fill: { pattern: "solid", foreground: "#FFFFE699" },
1279
+ * alignment: { horizontal: "right" },
1280
+ * });
1281
+ * ```
1282
+ * @param {number} sheet
1283
+ * @param {string} address
1284
+ * @param {CellStylePatch} patch
1285
+ */
1286
+ setCellStyle(sheet, address, patch) {
1287
+ const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1288
+ const len0 = WASM_VECTOR_LEN;
1289
+ const ret = wasm.book_setCellStyle(this.__wbg_ptr, sheet, ptr0, len0, patch);
1290
+ if (ret[1]) {
1291
+ throw takeFromExternrefTable0(ret[0]);
1292
+ }
1293
+ }
1294
+ /**
1295
+ * The same by 1-based row and column.
1296
+ * @param {number} sheet
1297
+ * @param {number} row
1298
+ * @param {number} column
1299
+ * @param {CellStylePatch} patch
1300
+ */
1301
+ setCellStyleAt(sheet, row, column, patch) {
1302
+ const ret = wasm.book_setCellStyleAt(this.__wbg_ptr, sheet, row, column, patch);
1303
+ if (ret[1]) {
1304
+ throw takeFromExternrefTable0(ret[0]);
1305
+ }
1306
+ }
1307
+ /**
1308
+ * Hides a column, or shows it again. `column` is 1-based.
1309
+ * @param {number} sheet
1310
+ * @param {number} column
1311
+ * @param {boolean} hidden
1312
+ */
1313
+ setColumnHidden(sheet, column, hidden) {
1314
+ const ret = wasm.book_setColumnHidden(this.__wbg_ptr, sheet, column, hidden);
1315
+ if (ret[1]) {
1316
+ throw takeFromExternrefTable0(ret[0]);
1317
+ }
1318
+ }
1319
+ /**
1320
+ * Sets the width of a column in characters of the default font, or gives
1321
+ * it back to the sheet default with `undefined`. `column` is 1-based.
1322
+ *
1323
+ * A run of columns that covered this one is split around it, so the
1324
+ * neighbours keep the width they had.
1325
+ * @param {number} sheet
1326
+ * @param {number} column
1327
+ * @param {number | null} [width]
1328
+ */
1329
+ setColumnWidth(sheet, column, width) {
1330
+ const ret = wasm.book_setColumnWidth(this.__wbg_ptr, sheet, column, !isLikeNone(width), isLikeNone(width) ? 0 : width);
1331
+ if (ret[1]) {
1332
+ throw takeFromExternrefTable0(ret[0]);
1333
+ }
1334
+ }
1335
+ /**
1336
+ * Puts a note on a cell, replacing any note already there.
1337
+ * @param {number} sheet
1338
+ * @param {string} address
1339
+ * @param {string} author
1340
+ * @param {string} text
1341
+ */
1342
+ setComment(sheet, address, author, text) {
1343
+ const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1344
+ const len0 = WASM_VECTOR_LEN;
1345
+ const ptr1 = passStringToWasm0(author, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1346
+ const len1 = WASM_VECTOR_LEN;
1347
+ const ptr2 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1348
+ const len2 = WASM_VECTOR_LEN;
1349
+ const ret = wasm.book_setComment(this.__wbg_ptr, sheet, ptr0, len0, ptr1, len1, ptr2, len2);
1350
+ if (ret[1]) {
1351
+ throw takeFromExternrefTable0(ret[0]);
1352
+ }
1353
+ }
1354
+ /**
1355
+ * Defines a name, replacing one of the same name. `formula` is what it
1356
+ * stands for - `Sheet1!$A$1:$A$9` or a constant - and `sheet` makes the
1357
+ * name local to that sheet instead of the workbook.
1358
+ * @param {string} name
1359
+ * @param {string} formula
1360
+ * @param {number | null} [sheet]
1361
+ */
1362
+ setDefinedName(name, formula, sheet) {
1363
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1364
+ const len0 = WASM_VECTOR_LEN;
1365
+ const ptr1 = passStringToWasm0(formula, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1366
+ const len1 = WASM_VECTOR_LEN;
1367
+ const ret = wasm.book_setDefinedName(this.__wbg_ptr, ptr0, len0, ptr1, len1, isLikeNone(sheet) ? Number.MAX_SAFE_INTEGER : (sheet) >>> 0);
1368
+ if (ret[1]) {
1369
+ throw takeFromExternrefTable0(ret[0]);
1370
+ }
1371
+ }
1372
+ /**
1373
+ * Puts a link over a cell or a block of them.
1374
+ *
1375
+ * `target` is a URL or a file path unless `inside` is true, and then it
1376
+ * is a place in this workbook: `'Sheet 2'!A1`.
1377
+ * @param {number} sheet
1378
+ * @param {string} range
1379
+ * @param {string} target
1380
+ * @param {boolean | null} [inside]
1381
+ * @param {string | null} [display]
1382
+ * @param {string | null} [tooltip]
1383
+ */
1384
+ setHyperlink(sheet, range, target, inside, display, tooltip) {
1385
+ const ptr0 = passStringToWasm0(range, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1386
+ const len0 = WASM_VECTOR_LEN;
1387
+ const ptr1 = passStringToWasm0(target, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1388
+ const len1 = WASM_VECTOR_LEN;
1389
+ var ptr2 = isLikeNone(display) ? 0 : passStringToWasm0(display, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1390
+ var len2 = WASM_VECTOR_LEN;
1391
+ var ptr3 = isLikeNone(tooltip) ? 0 : passStringToWasm0(tooltip, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1392
+ var len3 = WASM_VECTOR_LEN;
1393
+ const ret = wasm.book_setHyperlink(this.__wbg_ptr, sheet, ptr0, len0, ptr1, len1, isLikeNone(inside) ? 0xFFFFFF : inside ? 1 : 0, ptr2, len2, ptr3, len3);
1394
+ if (ret[1]) {
1395
+ throw takeFromExternrefTable0(ret[0]);
1396
+ }
1397
+ }
676
1398
  /**
677
1399
  * Writes a rectangle of values with `at` as its top-left corner. Rows may
678
1400
  * differ in length; a `null` leaves its cell empty.
@@ -701,6 +1423,133 @@ class Book {
701
1423
  throw takeFromExternrefTable0(ret[0]);
702
1424
  }
703
1425
  }
1426
+ /**
1427
+ * The same over a rectangle: `setRangeStyle(0, "A1:D1", { font: { bold:
1428
+ * true } })`. Cells the range covers but the sheet has no value for are
1429
+ * created empty, which is what carries the style.
1430
+ * @param {number} sheet
1431
+ * @param {string} range
1432
+ * @param {CellStylePatch} patch
1433
+ */
1434
+ setRangeStyle(sheet, range, patch) {
1435
+ const ptr0 = passStringToWasm0(range, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1436
+ const len0 = WASM_VECTOR_LEN;
1437
+ const ret = wasm.book_setRangeStyle(this.__wbg_ptr, sheet, ptr0, len0, patch);
1438
+ if (ret[1]) {
1439
+ throw takeFromExternrefTable0(ret[0]);
1440
+ }
1441
+ }
1442
+ /**
1443
+ * Paints a rectangle cell by cell in one call, `at` its top-left corner:
1444
+ * `grid` points into `styles`, each a patch as `setCellStyle` takes it,
1445
+ * and `null` or `-1` leaves its cell alone. The output of
1446
+ * `getRangeStyles` goes back in unchanged, so a block's formatting can be
1447
+ * read, edited in JS and written back - or copied somewhere else.
1448
+ * @param {number} sheet
1449
+ * @param {string} at
1450
+ * @param {RangeStylesPatch} styles
1451
+ */
1452
+ setRangeStyles(sheet, at, styles) {
1453
+ const ptr0 = passStringToWasm0(at, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1454
+ const len0 = WASM_VECTOR_LEN;
1455
+ const ret = wasm.book_setRangeStyles(this.__wbg_ptr, sheet, ptr0, len0, styles);
1456
+ if (ret[1]) {
1457
+ throw takeFromExternrefTable0(ret[0]);
1458
+ }
1459
+ }
1460
+ /**
1461
+ * The same with the corner given as 1-based row and column.
1462
+ * @param {number} sheet
1463
+ * @param {number} row
1464
+ * @param {number} column
1465
+ * @param {RangeStylesPatch} styles
1466
+ */
1467
+ setRangeStylesAt(sheet, row, column, styles) {
1468
+ const ret = wasm.book_setRangeStylesAt(this.__wbg_ptr, sheet, row, column, styles);
1469
+ if (ret[1]) {
1470
+ throw takeFromExternrefTable0(ret[0]);
1471
+ }
1472
+ }
1473
+ /**
1474
+ * Sets the height of a row in points, or gives it back to the sheet
1475
+ * default with `undefined`. `row` is the number a user sees.
1476
+ * @param {number} sheet
1477
+ * @param {number} row
1478
+ * @param {number | null} [height]
1479
+ */
1480
+ setRowHeight(sheet, row, height) {
1481
+ const ret = wasm.book_setRowHeight(this.__wbg_ptr, sheet, row, !isLikeNone(height), isLikeNone(height) ? 0 : height);
1482
+ if (ret[1]) {
1483
+ throw takeFromExternrefTable0(ret[0]);
1484
+ }
1485
+ }
1486
+ /**
1487
+ * Hides a row, or shows it again.
1488
+ * @param {number} sheet
1489
+ * @param {number} row
1490
+ * @param {boolean} hidden
1491
+ */
1492
+ setRowHidden(sheet, row, hidden) {
1493
+ const ret = wasm.book_setRowHidden(this.__wbg_ptr, sheet, row, hidden);
1494
+ if (ret[1]) {
1495
+ throw takeFromExternrefTable0(ret[0]);
1496
+ }
1497
+ }
1498
+ /**
1499
+ * Gives a sheet a tab or takes it away: `"visible"`, `"hidden"` or
1500
+ * `"veryHidden"`.
1501
+ *
1502
+ * A very hidden sheet is not in the dialog Excel offers for unhiding one.
1503
+ * Either way the sheet keeps its index, which is what every other call
1504
+ * counts.
1505
+ * @param {number} sheet
1506
+ * @param {string} state
1507
+ */
1508
+ setSheetVisibility(sheet, state) {
1509
+ const ptr0 = passStringToWasm0(state, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1510
+ const len0 = WASM_VECTOR_LEN;
1511
+ const ret = wasm.book_setSheetVisibility(this.__wbg_ptr, sheet, ptr0, len0);
1512
+ if (ret[1]) {
1513
+ throw takeFromExternrefTable0(ret[0]);
1514
+ }
1515
+ }
1516
+ /**
1517
+ * Shows or hides the grid lines, and the row and column headings with
1518
+ * `headers`.
1519
+ * @param {number} sheet
1520
+ * @param {boolean} show
1521
+ * @param {boolean | null} [headers]
1522
+ */
1523
+ setShowGridLines(sheet, show, headers) {
1524
+ const ret = wasm.book_setShowGridLines(this.__wbg_ptr, sheet, show, isLikeNone(headers) ? 0xFFFFFF : headers ? 1 : 0);
1525
+ if (ret[1]) {
1526
+ throw takeFromExternrefTable0(ret[0]);
1527
+ }
1528
+ }
1529
+ /**
1530
+ * The zoom a reader opens the sheet at, in percent; `undefined` gives it
1531
+ * back to 100.
1532
+ * @param {number} sheet
1533
+ * @param {number | null} [percent]
1534
+ */
1535
+ setZoom(sheet, percent) {
1536
+ const ret = wasm.book_setZoom(this.__wbg_ptr, sheet, isLikeNone(percent) ? Number.MAX_SAFE_INTEGER : (percent) >>> 0);
1537
+ if (ret[1]) {
1538
+ throw takeFromExternrefTable0(ret[0]);
1539
+ }
1540
+ }
1541
+ /**
1542
+ * The drawn shapes of a sheet, text and all.
1543
+ * @param {number} sheet
1544
+ * @returns {SheetShape[]}
1545
+ */
1546
+ shapes(sheet) {
1547
+ const ret = wasm.book_shapes(this.__wbg_ptr, sheet);
1548
+ if (ret[2]) {
1549
+ throw takeFromExternrefTable0(ret[1]);
1550
+ }
1551
+ return takeFromExternrefTable0(ret[0]);
1552
+ }
704
1553
  /**
705
1554
  * The tab index of a sheet by name, or `undefined` when there is none.
706
1555
  * Names are compared the way Excel does, ignoring case.
@@ -723,6 +1572,30 @@ class Book {
723
1572
  wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
724
1573
  return v1;
725
1574
  }
1575
+ /**
1576
+ * Whether a sheet is locked, and whether the lock has a password.
1577
+ * @param {number} sheet
1578
+ * @returns {ProtectionInfo}
1579
+ */
1580
+ sheetProtection(sheet) {
1581
+ const ret = wasm.book_sheetProtection(this.__wbg_ptr, sheet);
1582
+ if (ret[2]) {
1583
+ throw takeFromExternrefTable0(ret[1]);
1584
+ }
1585
+ return takeFromExternrefTable0(ret[0]);
1586
+ }
1587
+ /**
1588
+ * How the sheet is frozen and shown.
1589
+ * @param {number} sheet
1590
+ * @returns {SheetViewInfo}
1591
+ */
1592
+ sheetView(sheet) {
1593
+ const ret = wasm.book_sheetView(this.__wbg_ptr, sheet);
1594
+ if (ret[2]) {
1595
+ throw takeFromExternrefTable0(ret[1]);
1596
+ }
1597
+ return takeFromExternrefTable0(ret[0]);
1598
+ }
726
1599
  /**
727
1600
  * Whether a sheet has a tab: `"visible"`, `"hidden"` or `"veryHidden"`.
728
1601
  *
@@ -750,7 +1623,58 @@ class Book {
750
1623
  }
751
1624
  }
752
1625
  /**
753
- * One sheet as CSV.
1626
+ * Sorts the rows of a range, or its columns. A key is a column number of
1627
+ * the sheet, 1-based (a row number when sorting columns), or the text of
1628
+ * a header when `options.header` says the first line is one; a minus
1629
+ * sorts it largest first: `[2, -4]`, `["Region", "-Amount"]`. The first
1630
+ * key decides first.
1631
+ *
1632
+ * ```js
1633
+ * book.sortRange(0, "A1:D100", ["Region", "-Amount"], { header: true });
1634
+ * ```
1635
+ * @param {number} sheet
1636
+ * @param {string} range
1637
+ * @param {SortKeys} keys
1638
+ * @param {SortRangeOptions} [options]
1639
+ */
1640
+ sortRange(sheet, range, keys, options) {
1641
+ const ptr0 = passStringToWasm0(range, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1642
+ const len0 = WASM_VECTOR_LEN;
1643
+ const ret = wasm.book_sortRange(this.__wbg_ptr, sheet, ptr0, len0, keys, options);
1644
+ if (ret[1]) {
1645
+ throw takeFromExternrefTable0(ret[0]);
1646
+ }
1647
+ }
1648
+ /**
1649
+ * Sorts the data rows of a table, found by name anywhere in the book;
1650
+ * its header and totals rows stay put. Keys name its columns, as in
1651
+ * `sortRange`: `book.sortTable("Sales", ["-Amount"])`.
1652
+ * @param {string} name
1653
+ * @param {SortKeys} keys
1654
+ */
1655
+ sortTable(name, keys) {
1656
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1657
+ const len0 = WASM_VECTOR_LEN;
1658
+ const ret = wasm.book_sortTable(this.__wbg_ptr, ptr0, len0, keys);
1659
+ if (ret[1]) {
1660
+ throw takeFromExternrefTable0(ret[0]);
1661
+ }
1662
+ }
1663
+ /**
1664
+ * The tables of a sheet: what a structured reference like `Sales[Amount]`
1665
+ * names.
1666
+ * @param {number} sheet
1667
+ * @returns {SheetTable[]}
1668
+ */
1669
+ tables(sheet) {
1670
+ const ret = wasm.book_tables(this.__wbg_ptr, sheet);
1671
+ if (ret[2]) {
1672
+ throw takeFromExternrefTable0(ret[1]);
1673
+ }
1674
+ return takeFromExternrefTable0(ret[0]);
1675
+ }
1676
+ /**
1677
+ * One sheet as CSV, comma-separated.
754
1678
  * @param {number} sheet
755
1679
  * @returns {string}
756
1680
  */
@@ -772,6 +1696,31 @@ class Book {
772
1696
  wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
773
1697
  }
774
1698
  }
1699
+ /**
1700
+ * The same with the delimiter stated - a semicolon for a locale where the
1701
+ * comma is the decimal mark.
1702
+ * @param {number} sheet
1703
+ * @param {CsvOptions} options
1704
+ * @returns {string}
1705
+ */
1706
+ toCsvWith(sheet, options) {
1707
+ let deferred2_0;
1708
+ let deferred2_1;
1709
+ try {
1710
+ const ret = wasm.book_toCsvWith(this.__wbg_ptr, sheet, options);
1711
+ var ptr1 = ret[0];
1712
+ var len1 = ret[1];
1713
+ if (ret[3]) {
1714
+ ptr1 = 0; len1 = 0;
1715
+ throw takeFromExternrefTable0(ret[2]);
1716
+ }
1717
+ deferred2_0 = ptr1;
1718
+ deferred2_1 = len1;
1719
+ return getStringFromWasm0(ptr1, len1);
1720
+ } finally {
1721
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
1722
+ }
1723
+ }
775
1724
  /**
776
1725
  * The workbook as an HTML page, or one sheet of it. `fragment` leaves out
777
1726
  * the `<html>` wrapper, for embedding in a page that already has one.
@@ -840,6 +1789,47 @@ class Book {
840
1789
  wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
841
1790
  return v1;
842
1791
  }
1792
+ /**
1793
+ * Unfreezes the panes. The same as `freezePanes(sheet, 0, 0)`.
1794
+ * @param {number} sheet
1795
+ */
1796
+ unfreezePanes(sheet) {
1797
+ const ret = wasm.book_unfreezePanes(this.__wbg_ptr, sheet);
1798
+ if (ret[1]) {
1799
+ throw takeFromExternrefTable0(ret[0]);
1800
+ }
1801
+ }
1802
+ /**
1803
+ * Takes a merge back out. Answers whether there was one.
1804
+ * @param {number} sheet
1805
+ * @param {string} range
1806
+ * @returns {boolean}
1807
+ */
1808
+ unmerge(sheet, range) {
1809
+ const ptr0 = passStringToWasm0(range, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1810
+ const len0 = WASM_VECTOR_LEN;
1811
+ const ret = wasm.book_unmerge(this.__wbg_ptr, sheet, ptr0, len0);
1812
+ if (ret[2]) {
1813
+ throw takeFromExternrefTable0(ret[1]);
1814
+ }
1815
+ return ret[0] !== 0;
1816
+ }
1817
+ /**
1818
+ * Unlocks a sheet, password and all.
1819
+ * @param {number} sheet
1820
+ */
1821
+ unprotectSheet(sheet) {
1822
+ const ret = wasm.book_unprotectSheet(this.__wbg_ptr, sheet);
1823
+ if (ret[1]) {
1824
+ throw takeFromExternrefTable0(ret[0]);
1825
+ }
1826
+ }
1827
+ /**
1828
+ * Unlocks the workbook.
1829
+ */
1830
+ unprotectWorkbook() {
1831
+ wasm.book_unprotectWorkbook(this.__wbg_ptr);
1832
+ }
843
1833
  /**
844
1834
  * Forgets a function registered earlier; answers whether there was one.
845
1835
  * @param {string} name
@@ -866,6 +1856,53 @@ class Book {
866
1856
  }
867
1857
  return v1;
868
1858
  }
1859
+ /**
1860
+ * The used range of a sheet as `"A1:D20"` without walking the rows;
1861
+ * `undefined` for an empty sheet.
1862
+ *
1863
+ * Rows are exact, columns an upper bound: removing a cell never narrows
1864
+ * them. `usedRange` answers the same until a cell in an edge column is
1865
+ * removed, and walks the rows after that to give the exact rectangle.
1866
+ * @param {number} sheet
1867
+ * @returns {string | undefined}
1868
+ */
1869
+ usedRangeHint(sheet) {
1870
+ const ret = wasm.book_usedRangeHint(this.__wbg_ptr, sheet);
1871
+ if (ret[3]) {
1872
+ throw takeFromExternrefTable0(ret[2]);
1873
+ }
1874
+ let v1;
1875
+ if (ret[0] !== 0) {
1876
+ v1 = getStringFromWasm0(ret[0], ret[1]);
1877
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1878
+ }
1879
+ return v1;
1880
+ }
1881
+ /**
1882
+ * Whether that password unlocks the sheet. `false` for a sheet with no
1883
+ * password on it, and for a hash this crate cannot check.
1884
+ * @param {number} sheet
1885
+ * @param {string} password
1886
+ * @returns {boolean}
1887
+ */
1888
+ verifySheetPassword(sheet, password) {
1889
+ const ptr0 = passStringToWasm0(password, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1890
+ const len0 = WASM_VECTOR_LEN;
1891
+ const ret = wasm.book_verifySheetPassword(this.__wbg_ptr, sheet, ptr0, len0);
1892
+ if (ret[2]) {
1893
+ throw takeFromExternrefTable0(ret[1]);
1894
+ }
1895
+ return ret[0] !== 0;
1896
+ }
1897
+ /**
1898
+ * Whether the workbook's structure is locked, and whether behind a
1899
+ * password.
1900
+ * @returns {ProtectionInfo}
1901
+ */
1902
+ workbookProtection() {
1903
+ const ret = wasm.book_workbookProtection(this.__wbg_ptr);
1904
+ return ret;
1905
+ }
869
1906
  }
870
1907
  if (Symbol.dispose) Book.prototype[Symbol.dispose] = Book.prototype.free;
871
1908
  exports.Book = Book;
@@ -881,10 +1918,19 @@ function __wbg_get_imports() {
881
1918
  const ret = typeof(v) === 'boolean' ? v : undefined;
882
1919
  return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
883
1920
  },
1921
+ __wbg___wbindgen_is_falsy_b7464e97ddc1b7a4: function(arg0) {
1922
+ const ret = !arg0;
1923
+ return ret;
1924
+ },
884
1925
  __wbg___wbindgen_is_null_7d13f41e1a2d5140: function(arg0) {
885
1926
  const ret = arg0 === null;
886
1927
  return ret;
887
1928
  },
1929
+ __wbg___wbindgen_is_object_a2790eb24c211ea0: function(arg0) {
1930
+ const val = arg0;
1931
+ const ret = typeof(val) === 'object' && val !== null;
1932
+ return ret;
1933
+ },
888
1934
  __wbg___wbindgen_is_undefined_6cff064c44e0d823: function(arg0) {
889
1935
  const ret = arg0 === undefined;
890
1936
  return ret;
@@ -921,6 +1967,10 @@ function __wbg_get_imports() {
921
1967
  const ret = arg0.getTime();
922
1968
  return ret;
923
1969
  },
1970
+ __wbg_get_971a0c45d172643f: function() { return handleError(function (arg0, arg1) {
1971
+ const ret = Reflect.get(arg0, arg1);
1972
+ return ret;
1973
+ }, arguments); },
924
1974
  __wbg_get_unchecked_e20b893aeafc3fca: function(arg0, arg1) {
925
1975
  const ret = arg0[arg1 >>> 0];
926
1976
  return ret;