@rosperitus/excelerate 0.12.3 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -74,11 +74,12 @@ type CellValue = number | string | boolean | null;
74
74
  type CellGrid = CellValue[][];
75
75
  type CopyOrigin = "before" | "after" | "none"; // whose formatting new rows take
76
76
  type SortKeys = (number | string)[]; // 2 = column B, "-Amount" = header, largest first
77
+ type Progress = { stage: "reading" | "writing" | "recalculating"; done: number;
78
+ total: number | null; what: string; fraction: number | null };
77
79
 
78
80
  class Book {
79
81
  constructor();
80
- static fromXlsx(bytes: Uint8Array): Book;
81
- static read(bytes: Uint8Array, name?: string | null, maxExpanded?: number | null): Book;
82
+ static read(bytes: Uint8Array, name?: string | null, maxExpanded?: number | null, onProgress?: (p: Progress) => void): Book;
82
83
  static readCsv(bytes: Uint8Array, options: CsvOptions): Book; // shape stated, not guessed
83
84
 
84
85
  // Sheets
@@ -112,6 +113,8 @@ class Book {
112
113
  getFormattedAt(sheet: number, row: number, column: number): string;
113
114
  getRangeAt(sheet: number, row: number, column: number, rows: number, columns: number): CellGrid;
114
115
  setRangeAt(sheet: number, row: number, column: number, values: CellGrid): void;
116
+ getRangeStylesAt(sheet: number, row: number, column: number, rows: number, columns: number): RangeStyles;
117
+ setRangeStylesAt(sheet: number, row: number, column: number, styles: RangeStylesPatch): void;
115
118
  recalculateCellAt(sheet: number, row: number, column: number): boolean;
116
119
  recalculateFromAt(sheet: number, row: number, column: number): number;
117
120
 
@@ -165,10 +168,14 @@ class Book {
165
168
  imageData(sheet: number, index: number): Uint8Array;
166
169
  shapes(sheet: number): SheetShape[];
167
170
 
168
- // Style, written as a patch over what the cell has
171
+ // Style: read whole, written as a patch over what the cell has
172
+ cellStyle(sheet: number, address: string): CellStyle; // numberFormat, font, fill, borders, alignment
173
+ cellStyleAt(sheet: number, row: number, column: number): CellStyle;
169
174
  setCellStyle(sheet: number, address: string, patch: CellStylePatch): void;
170
175
  setCellStyleAt(sheet: number, row: number, column: number, patch: CellStylePatch): void;
171
176
  setRangeStyle(sheet: number, range: string, patch: CellStylePatch): void;
177
+ getRichText(sheet: number, address: string): TextRun[] | null; // [{ text, font }]
178
+ setRichText(sheet: number, address: string, runs: TextRun[]): void;
172
179
 
173
180
  // Notes, links, tables
174
181
  setComment(sheet: number, address: string, author: string, text: string): void;
@@ -180,8 +187,7 @@ class Book {
180
187
 
181
188
  // The saved view
182
189
  sheetView(sheet: number): SheetViewInfo;
183
- freezePanes(sheet: number, rows: number, columns: number): void; // (0, 1, 0) pins the header
184
- unfreezePanes(sheet: number): void;
190
+ freezePanes(sheet: number, rows: number, columns: number): void; // (0, 1, 0) pins the header, (0, 0, 0) unfreezes
185
191
  setZoom(sheet: number, percent?: number): void;
186
192
  setShowGridLines(sheet: number, show: boolean, headers?: boolean): void;
187
193
 
@@ -209,18 +215,22 @@ class Book {
209
215
 
210
216
  // Calculation
211
217
  evaluate(sheet: number, address: string, formula: string): CellValue;
212
- recalculate(sheet?: number | null): number;
218
+ recalculate(sheet?: number | null, onProgress?: (p: Progress) => void): number;
213
219
  recalculateCell(sheet: number, address: string): boolean;
214
220
  recalculateFrom(sheet: number, address: string): number;
215
221
  recalculateFromMany(sheet: number, addresses: string[]): number;
216
222
 
223
+ // Functions of your own, for names no built-in claims
224
+ registerFunction(name: string, fn: (...args: (CellValue | CellGrid)[]) => CellValue | CellGrid): void;
225
+ unregisterFunction(name: string): boolean;
226
+ registeredFunctions(): string[];
227
+
217
228
  // Output
218
- toXlsx(): Uint8Array;
229
+ toXlsx(onProgress?: (p: Progress) => void): Uint8Array;
219
230
  toOds(): Uint8Array;
220
231
  toXls(): Uint8Array;
221
232
  toHtml(sheet?: number | null, fragment?: boolean | null): string;
222
- toCsv(sheet: number): string;
223
- toCsvWith(sheet: number, options: CsvOptions): string; // a delimiter of your own
233
+ toCsv(sheet: number, options?: CsvOptions): string; // { delimiter: ";" } for a delimiter of your own
224
234
 
225
235
  free(): void;
226
236
  }
@@ -273,6 +283,14 @@ missing sheet, a truncated package.
273
283
  - **Charts, pictures and shapes are read-only here.** `charts`, `images` and
274
284
  `shapes` describe what a sheet carries; the parts themselves travel through
275
285
  a write byte for byte.
286
+ - **Functions of your own.** `book.registerFunction("MYTOTAL", (range) =>
287
+ range.flat().reduce((a, b) => a + (b ?? 0), 0))` - arguments arrive
288
+ evaluated, a range as a grid. A built-in name stays the built-in's, an
289
+ unregistered one reads `#NAME?`, and a function that throws gives
290
+ `#VALUE!` rather than an exception out of the formula.
291
+ - **Progress.** `Book.read`, `toXlsx` and `recalculate` take a callback last;
292
+ it gets `{ stage, done, total, what, fraction }` per sheet, part or formula.
293
+ `total` is `null` while a read has not reached the workbook part yet.
276
294
  - **Cached results.** A formula cell read from a file carries whatever the app
277
295
  that saved it computed. Call `recalculate()` before relying on those numbers.
278
296
 
package/excelerate.d.ts CHANGED
@@ -6,6 +6,15 @@
6
6
  * what is left out keeps the value the cell had, so `{ font: { bold: true } }`
7
7
  * makes a cell bold without touching its number format.
8
8
  */
9
+ /**
10
+ * What `setDocumentProperties` takes: a named field is set, `null` clears it,
11
+ * a missing one stays. `custom` replaces the whole list; `type` is optional.
12
+ */
13
+ export type DocumentPropertiesPatch = Partial<
14
+ Record<Exclude<keyof DocumentProperties, "custom">, string | null>
15
+ > & {
16
+ custom?: { name: string; value: string | number | boolean; type?: CustomProperty["type"] }[];
17
+ };
9
18
  export interface CellStylePatch {
10
19
  numberFormat?: string;
11
20
  font?: Partial<{
@@ -88,6 +97,33 @@ export interface SheetViewInfo {
88
97
  rightToLeft: boolean;
89
98
  topLeftCell: string | null;
90
99
  }
100
+ /** One of the user's own document properties. */
101
+ export interface CustomProperty {
102
+ name: string;
103
+ type: "text" | "integer" | "number" | "boolean" | "date";
104
+ value: string | number | boolean;
105
+ }
106
+ /** Title, author, dates and the user's fields, as `documentProperties` returns them. Dates are ISO 8601. */
107
+ export interface DocumentProperties {
108
+ title: string | null;
109
+ subject: string | null;
110
+ creator: string | null;
111
+ keywords: string | null;
112
+ description: string | null;
113
+ lastModifiedBy: string | null;
114
+ category: string | null;
115
+ contentStatus: string | null;
116
+ language: string | null;
117
+ identifier: string | null;
118
+ revision: string | null;
119
+ version: string | null;
120
+ created: string | null;
121
+ modified: string | null;
122
+ lastPrinted: string | null;
123
+ company: string | null;
124
+ manager: string | null;
125
+ custom: CustomProperty[];
126
+ }
91
127
  /** A name that stands for a formula, as `definedNames` returns it. */
92
128
  export interface WorkbookName {
93
129
  name: string;
@@ -113,7 +149,7 @@ export interface SheetConditionalFormat {
113
149
  /** The autofilter over a range, as `autoFilter` returns it. */
114
150
  export interface SheetAutoFilter {
115
151
  range: string;
116
- columns: { colId: number; kind: "values" | "custom" | "dynamic" | "top10" | "none" }[];
152
+ columns: { colId: number; kind: "values" | "custom" | "dynamic" | "top10" | "color" | "icon" | "none" }[];
117
153
  }
118
154
  /** A pivot report on the sheet, as `pivotTables` returns it. */
119
155
  export interface SheetPivotTable {
@@ -182,6 +218,22 @@ export interface SheetShape {
182
218
  * a theme colour carries its tint as `theme:4@-0.25`.
183
219
  */
184
220
  export type StyleColor = string | null;
221
+ /**
222
+ * What a run of formatted text changes about the cell's font; a field left
223
+ * out is the cell's own. `size` in points.
224
+ */
225
+ export interface RunFont {
226
+ name?: string;
227
+ size?: number;
228
+ bold?: boolean;
229
+ italic?: boolean;
230
+ underline?: string;
231
+ strike?: boolean;
232
+ color?: StyleColor;
233
+ script?: "superscript" | "subscript" | "baseline";
234
+ }
235
+ /** One run of formatted text, as `getRichText` returns it. */
236
+ export interface TextRun { text: string; font?: RunFont | null }
185
237
  /** One side of a cell's border. */
186
238
  export interface BorderSide { style: string; color: StyleColor }
187
239
  /** How a cell is painted, as `cellStyle` returns it. */
@@ -346,6 +398,12 @@ export class Book {
346
398
  * for. `sheet` is set on a name local to one sheet.
347
399
  */
348
400
  definedNames(): WorkbookName[];
401
+ /**
402
+ * What Excel shows under File > Info: every text field is a string or
403
+ * `null`, dates in ISO 8601. `custom` lists the user's own fields with
404
+ * their type: `text`, `integer`, `number`, `boolean` or `date`.
405
+ */
406
+ documentProperties(): DocumentProperties;
349
407
  /**
350
408
  * Evaluates a formula (with or without the leading `=`) as if it sat in
351
409
  * `address` of `sheet`, and returns its result.
@@ -375,22 +433,17 @@ export class Book {
375
433
  fillSeries(sheet: number, range: string, direction: "down" | "right" | "up" | "left"): void;
376
434
  /**
377
435
  * Freezes the first `rows` rows and `columns` columns, so they stay put
378
- * while the rest scrolls. `freezePanes(0, 1, 0)` pins the header row.
436
+ * while the rest scrolls. `freezePanes(0, 1, 0)` pins the header row;
437
+ * `freezePanes(0, 0, 0)` unfreezes.
379
438
  */
380
439
  freezePanes(sheet: number, rows: number, columns: number): void;
381
- /**
382
- * Reads an xlsx package from its bytes.
383
- */
384
- static fromXlsx(bytes: Uint8Array): Book;
385
440
  /**
386
441
  * The value at `address` on sheet `sheet`, as a JS number, string, boolean
387
442
  * or `null`. A formula cell gives its cached result, not its text.
388
443
  */
389
444
  get(sheet: number, address: string): CellValue;
390
445
  /**
391
- * The same by 1-based row and column, the numbers `ROW()` and `COLUMN()`
392
- * return: `getAt(0, 4, 2)` is `B4`. Saves formatting an address only to
393
- * parse it again.
446
+ * The same by 1-based row and column.
394
447
  */
395
448
  getAt(sheet: number, row: number, column: number): CellValue;
396
449
  /**
@@ -432,6 +485,16 @@ export class Book {
432
485
  * The same by numbers, as `getRangeAt` takes them.
433
486
  */
434
487
  getRangeStylesAt(sheet: number, row: number, column: number, rows: number, columns: number): RangeStyles;
488
+ /**
489
+ * The runs of a cell's formatted text: `{ text, font }` each, `font`
490
+ * naming only what the run changes about the cell's font, or `null` for
491
+ * a run in the cell's own. `null` for a cell without formatted text.
492
+ */
493
+ getRichText(sheet: number, address: string): TextRun[] | null;
494
+ /**
495
+ * The same by 1-based row and column.
496
+ */
497
+ getRichTextAt(sheet: number, row: number, column: number): TextRun[] | null;
435
498
  /**
436
499
  * A whole row in one crossing of the boundary: values, displayed text,
437
500
  * bold and indent, plus whether the row is hidden.
@@ -464,7 +527,7 @@ export class Book {
464
527
  * `"right"` - Excel's "Insert Cells", which moves part of a row rather
465
528
  * than the whole of it. `copyOrigin` works as in `insertRows`.
466
529
  */
467
- insertCells(sheet: number, range: string, shift: string, copyOrigin?: "before" | "after" | "none"): void;
530
+ insertCells(sheet: number, range: string, shift: "down" | "right", copyOrigin?: "before" | "after" | "none"): void;
468
531
  /**
469
532
  * Inserts `count` columns to the left of column `at`, 1-based.
470
533
  * `copyOrigin` works as in `insertRows`, with left and right.
@@ -621,7 +684,7 @@ export class Book {
621
684
  * Removes the cells of a range, pulling the rest back over the hole from
622
685
  * below (`"up"`) or from the right (`"left"`).
623
686
  */
624
- removeCells(sheet: number, range: string, shift: string): void;
687
+ removeCells(sheet: number, range: string, shift: "up" | "left"): void;
625
688
  /**
626
689
  * Removes `count` columns from column `at`, 1-based.
627
690
  */
@@ -675,7 +738,7 @@ export class Book {
675
738
  * Writes a value: a number, boolean, or string. A string starting with `=`
676
739
  * becomes a formula.
677
740
  */
678
- set(index: number, address: string, value: CellValue): void;
741
+ set(sheet: number, address: string, value: CellValue): void;
679
742
  /**
680
743
  * Sets that tab.
681
744
  */
@@ -729,6 +792,13 @@ export class Book {
729
792
  * name local to that sheet instead of the workbook.
730
793
  */
731
794
  setDefinedName(name: string, formula: string, sheet?: number | null): void;
795
+ /**
796
+ * Changes the fields the patch names and leaves the rest: a string sets
797
+ * one, `null` clears it. `custom`, when given, replaces the list; a
798
+ * field's type is taken from `type` or else from the value (a whole
799
+ * number is an integer).
800
+ */
801
+ setDocumentProperties(patch: DocumentPropertiesPatch): void;
732
802
  /**
733
803
  * Puts a link over a cell or a block of them.
734
804
  *
@@ -763,6 +833,16 @@ export class Book {
763
833
  * The same with the corner given as 1-based row and column.
764
834
  */
765
835
  setRangeStylesAt(sheet: number, row: number, column: number, styles: RangeStylesPatch): void;
836
+ /**
837
+ * Writes formatted text: runs as `getRichText` returns them, each with
838
+ * its own text and the part of the font it changes (`font` may be left
839
+ * out or `null` for the cell's own).
840
+ */
841
+ setRichText(sheet: number, address: string, runs: TextRun[]): void;
842
+ /**
843
+ * The same by 1-based row and column.
844
+ */
845
+ setRichTextAt(sheet: number, row: number, column: number, runs: TextRun[]): void;
766
846
  /**
767
847
  * Sets the height of a row in points, or gives it back to the sheet
768
848
  * default with `undefined`. `row` is the number a user sees.
@@ -843,14 +923,11 @@ export class Book {
843
923
  */
844
924
  tables(sheet: number): SheetTable[];
845
925
  /**
846
- * One sheet as CSV, comma-separated.
926
+ * One sheet as CSV, comma-separated unless `options.delimiter` says
927
+ * otherwise - a semicolon for a locale where the comma is the decimal
928
+ * mark.
847
929
  */
848
- toCsv(sheet: number): string;
849
- /**
850
- * The same with the delimiter stated - a semicolon for a locale where the
851
- * comma is the decimal mark.
852
- */
853
- toCsvWith(sheet: number, options: CsvOptions): string;
930
+ toCsv(sheet: number, options?: CsvOptions): string;
854
931
  /**
855
932
  * The workbook as an HTML page, or one sheet of it. `fragment` leaves out
856
933
  * the `<html>` wrapper, for embedding in a page that already has one.
@@ -863,18 +940,15 @@ export class Book {
863
940
  /**
864
941
  * The workbook as a BIFF8 `.xls` file.
865
942
  *
866
- * The format cannot hold a formula as text, so every formula is written
867
- * as its last computed value; call `recalculate` first if that matters.
943
+ * Formulas are written as tokens with their cached result; what BIFF8
944
+ * cannot hold - a structured reference, a row past 65536 - is written as
945
+ * the value, so call `recalculate` first if the cache is stale.
868
946
  */
869
947
  toXls(): Uint8Array;
870
948
  /**
871
949
  * The workbook as an xlsx package.
872
950
  */
873
951
  toXlsx(on_progress?: Function | null): Uint8Array;
874
- /**
875
- * Unfreezes the panes. The same as `freezePanes(sheet, 0, 0)`.
876
- */
877
- unfreezePanes(sheet: number): void;
878
952
  /**
879
953
  * Takes a merge back out. Answers whether there was one.
880
954
  */
package/excelerate.js CHANGED
@@ -336,6 +336,16 @@ class Book {
336
336
  const ret = wasm.book_definedNames(this.__wbg_ptr);
337
337
  return ret;
338
338
  }
339
+ /**
340
+ * What Excel shows under File > Info: every text field is a string or
341
+ * `null`, dates in ISO 8601. `custom` lists the user's own fields with
342
+ * their type: `text`, `integer`, `number`, `boolean` or `date`.
343
+ * @returns {DocumentProperties}
344
+ */
345
+ documentProperties() {
346
+ const ret = wasm.book_documentProperties(this.__wbg_ptr);
347
+ return ret;
348
+ }
339
349
  /**
340
350
  * Evaluates a formula (with or without the leading `=`) as if it sat in
341
351
  * `address` of `sheet`, and returns its result.
@@ -415,7 +425,8 @@ class Book {
415
425
  }
416
426
  /**
417
427
  * 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.
428
+ * while the rest scrolls. `freezePanes(0, 1, 0)` pins the header row;
429
+ * `freezePanes(0, 0, 0)` unfreezes.
419
430
  * @param {number} sheet
420
431
  * @param {number} rows
421
432
  * @param {number} columns
@@ -426,20 +437,6 @@ class Book {
426
437
  throw takeFromExternrefTable0(ret[0]);
427
438
  }
428
439
  }
429
- /**
430
- * Reads an xlsx package from its bytes.
431
- * @param {Uint8Array} bytes
432
- * @returns {Book}
433
- */
434
- static fromXlsx(bytes) {
435
- const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
436
- const len0 = WASM_VECTOR_LEN;
437
- const ret = wasm.book_fromXlsx(ptr0, len0);
438
- if (ret[2]) {
439
- throw takeFromExternrefTable0(ret[1]);
440
- }
441
- return Book.__wrap(ret[0]);
442
- }
443
440
  /**
444
441
  * The value at `address` on sheet `sheet`, as a JS number, string, boolean
445
442
  * or `null`. A formula cell gives its cached result, not its text.
@@ -457,9 +454,7 @@ class Book {
457
454
  return takeFromExternrefTable0(ret[0]);
458
455
  }
459
456
  /**
460
- * The same by 1-based row and column, the numbers `ROW()` and `COLUMN()`
461
- * return: `getAt(0, 4, 2)` is `B4`. Saves formatting an address only to
462
- * parse it again.
457
+ * The same by 1-based row and column.
463
458
  * @param {number} sheet
464
459
  * @param {number} row
465
460
  * @param {number} column
@@ -625,6 +620,37 @@ class Book {
625
620
  }
626
621
  return takeFromExternrefTable0(ret[0]);
627
622
  }
623
+ /**
624
+ * The runs of a cell's formatted text: `{ text, font }` each, `font`
625
+ * naming only what the run changes about the cell's font, or `null` for
626
+ * a run in the cell's own. `null` for a cell without formatted text.
627
+ * @param {number} sheet
628
+ * @param {string} address
629
+ * @returns {TextRun[] | null}
630
+ */
631
+ getRichText(sheet, address) {
632
+ const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
633
+ const len0 = WASM_VECTOR_LEN;
634
+ const ret = wasm.book_getRichText(this.__wbg_ptr, sheet, ptr0, len0);
635
+ if (ret[2]) {
636
+ throw takeFromExternrefTable0(ret[1]);
637
+ }
638
+ return takeFromExternrefTable0(ret[0]);
639
+ }
640
+ /**
641
+ * The same by 1-based row and column.
642
+ * @param {number} sheet
643
+ * @param {number} row
644
+ * @param {number} column
645
+ * @returns {TextRun[] | null}
646
+ */
647
+ getRichTextAt(sheet, row, column) {
648
+ const ret = wasm.book_getRichTextAt(this.__wbg_ptr, sheet, row, column);
649
+ if (ret[2]) {
650
+ throw takeFromExternrefTable0(ret[1]);
651
+ }
652
+ return takeFromExternrefTable0(ret[0]);
653
+ }
628
654
  /**
629
655
  * A whole row in one crossing of the boundary: values, displayed text,
630
656
  * bold and indent, plus whether the row is hidden.
@@ -695,7 +721,7 @@ class Book {
695
721
  * than the whole of it. `copyOrigin` works as in `insertRows`.
696
722
  * @param {number} sheet
697
723
  * @param {string} range
698
- * @param {string} shift
724
+ * @param {"down" | "right"} shift
699
725
  * @param {"before" | "after" | "none"} [copyOrigin]
700
726
  */
701
727
  insertCells(sheet, range, shift, copyOrigin) {
@@ -1064,7 +1090,7 @@ class Book {
1064
1090
  * below (`"up"`) or from the right (`"left"`).
1065
1091
  * @param {number} sheet
1066
1092
  * @param {string} range
1067
- * @param {string} shift
1093
+ * @param {"up" | "left"} shift
1068
1094
  */
1069
1095
  removeCells(sheet, range, shift) {
1070
1096
  const ptr0 = passStringToWasm0(range, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
@@ -1227,14 +1253,14 @@ class Book {
1227
1253
  /**
1228
1254
  * Writes a value: a number, boolean, or string. A string starting with `=`
1229
1255
  * becomes a formula.
1230
- * @param {number} index
1256
+ * @param {number} sheet
1231
1257
  * @param {string} address
1232
1258
  * @param {CellValue} value
1233
1259
  */
1234
- set(index, address, value) {
1260
+ set(sheet, address, value) {
1235
1261
  const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1236
1262
  const len0 = WASM_VECTOR_LEN;
1237
- const ret = wasm.book_set(this.__wbg_ptr, index, ptr0, len0, value);
1263
+ const ret = wasm.book_set(this.__wbg_ptr, sheet, ptr0, len0, value);
1238
1264
  if (ret[1]) {
1239
1265
  throw takeFromExternrefTable0(ret[0]);
1240
1266
  }
@@ -1369,6 +1395,19 @@ class Book {
1369
1395
  throw takeFromExternrefTable0(ret[0]);
1370
1396
  }
1371
1397
  }
1398
+ /**
1399
+ * Changes the fields the patch names and leaves the rest: a string sets
1400
+ * one, `null` clears it. `custom`, when given, replaces the list; a
1401
+ * field's type is taken from `type` or else from the value (a whole
1402
+ * number is an integer).
1403
+ * @param {DocumentPropertiesPatch} patch
1404
+ */
1405
+ setDocumentProperties(patch) {
1406
+ const ret = wasm.book_setDocumentProperties(this.__wbg_ptr, patch);
1407
+ if (ret[1]) {
1408
+ throw takeFromExternrefTable0(ret[0]);
1409
+ }
1410
+ }
1372
1411
  /**
1373
1412
  * Puts a link over a cell or a block of them.
1374
1413
  *
@@ -1470,6 +1509,35 @@ class Book {
1470
1509
  throw takeFromExternrefTable0(ret[0]);
1471
1510
  }
1472
1511
  }
1512
+ /**
1513
+ * Writes formatted text: runs as `getRichText` returns them, each with
1514
+ * its own text and the part of the font it changes (`font` may be left
1515
+ * out or `null` for the cell's own).
1516
+ * @param {number} sheet
1517
+ * @param {string} address
1518
+ * @param {TextRun[]} runs
1519
+ */
1520
+ setRichText(sheet, address, runs) {
1521
+ const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1522
+ const len0 = WASM_VECTOR_LEN;
1523
+ const ret = wasm.book_setRichText(this.__wbg_ptr, sheet, ptr0, len0, runs);
1524
+ if (ret[1]) {
1525
+ throw takeFromExternrefTable0(ret[0]);
1526
+ }
1527
+ }
1528
+ /**
1529
+ * The same by 1-based row and column.
1530
+ * @param {number} sheet
1531
+ * @param {number} row
1532
+ * @param {number} column
1533
+ * @param {TextRun[]} runs
1534
+ */
1535
+ setRichTextAt(sheet, row, column, runs) {
1536
+ const ret = wasm.book_setRichTextAt(this.__wbg_ptr, sheet, row, column, runs);
1537
+ if (ret[1]) {
1538
+ throw takeFromExternrefTable0(ret[0]);
1539
+ }
1540
+ }
1473
1541
  /**
1474
1542
  * Sets the height of a row in points, or gives it back to the sheet
1475
1543
  * default with `undefined`. `row` is the number a user sees.
@@ -1674,40 +1742,18 @@ class Book {
1674
1742
  return takeFromExternrefTable0(ret[0]);
1675
1743
  }
1676
1744
  /**
1677
- * One sheet as CSV, comma-separated.
1678
- * @param {number} sheet
1679
- * @returns {string}
1680
- */
1681
- toCsv(sheet) {
1682
- let deferred2_0;
1683
- let deferred2_1;
1684
- try {
1685
- const ret = wasm.book_toCsv(this.__wbg_ptr, sheet);
1686
- var ptr1 = ret[0];
1687
- var len1 = ret[1];
1688
- if (ret[3]) {
1689
- ptr1 = 0; len1 = 0;
1690
- throw takeFromExternrefTable0(ret[2]);
1691
- }
1692
- deferred2_0 = ptr1;
1693
- deferred2_1 = len1;
1694
- return getStringFromWasm0(ptr1, len1);
1695
- } finally {
1696
- wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
1697
- }
1698
- }
1699
- /**
1700
- * The same with the delimiter stated - a semicolon for a locale where the
1701
- * comma is the decimal mark.
1745
+ * One sheet as CSV, comma-separated unless `options.delimiter` says
1746
+ * otherwise - a semicolon for a locale where the comma is the decimal
1747
+ * mark.
1702
1748
  * @param {number} sheet
1703
- * @param {CsvOptions} options
1749
+ * @param {CsvOptions} [options]
1704
1750
  * @returns {string}
1705
1751
  */
1706
- toCsvWith(sheet, options) {
1752
+ toCsv(sheet, options) {
1707
1753
  let deferred2_0;
1708
1754
  let deferred2_1;
1709
1755
  try {
1710
- const ret = wasm.book_toCsvWith(this.__wbg_ptr, sheet, options);
1756
+ const ret = wasm.book_toCsv(this.__wbg_ptr, sheet, options);
1711
1757
  var ptr1 = ret[0];
1712
1758
  var len1 = ret[1];
1713
1759
  if (ret[3]) {
@@ -1762,8 +1808,9 @@ class Book {
1762
1808
  /**
1763
1809
  * The workbook as a BIFF8 `.xls` file.
1764
1810
  *
1765
- * The format cannot hold a formula as text, so every formula is written
1766
- * as its last computed value; call `recalculate` first if that matters.
1811
+ * Formulas are written as tokens with their cached result; what BIFF8
1812
+ * cannot hold - a structured reference, a row past 65536 - is written as
1813
+ * the value, so call `recalculate` first if the cache is stale.
1767
1814
  * @returns {Uint8Array}
1768
1815
  */
1769
1816
  toXls() {
@@ -1789,16 +1836,6 @@ class Book {
1789
1836
  wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1790
1837
  return v1;
1791
1838
  }
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
1839
  /**
1803
1840
  * Takes a merge back out. Answers whether there was one.
1804
1841
  * @param {number} sheet
@@ -1960,6 +1997,10 @@ function __wbg_get_imports() {
1960
1997
  const ret = arg0.call(arg1, arg2);
1961
1998
  return ret;
1962
1999
  }, arguments); },
2000
+ __wbg_from_74f3d90e0ff11240: function(arg0) {
2001
+ const ret = Array.from(arg0);
2002
+ return ret;
2003
+ },
1963
2004
  __wbg_getRandomValues_436a51d0629d84e1: function() { return handleError(function (arg0, arg1) {
1964
2005
  globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
1965
2006
  }, arguments); },
Binary file
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@rosperitus/excelerate",
3
3
  "description": "Read, write and recalculate spreadsheets: xlsx, xls, ods, csv, html, and a 518-function formula engine",
4
- "version": "0.12.3",
4
+ "version": "0.14.0",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",