@rosperitus/excelerate 0.13.0 → 0.15.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 +137 -9
- package/excelerate.d.ts +264 -4
- package/excelerate.js +268 -4
- package/excelerate_bg.wasm +0 -0
- package/index.d.ts +159 -0
- package/index.js +409 -0
- package/package.json +25 -5
- package/web/excelerate.d.ts +1345 -0
- package/web/excelerate.js +2519 -0
- package/web/excelerate_bg.wasm +0 -0
- package/web/excelerate_bg.wasm.d.ts +153 -0
- package/web/index.d.ts +160 -0
- package/web/index.js +406 -0
- package/web/package.json +4 -0
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.
|
|
@@ -413,6 +423,35 @@ class Book {
|
|
|
413
423
|
throw takeFromExternrefTable0(ret[0]);
|
|
414
424
|
}
|
|
415
425
|
}
|
|
426
|
+
/**
|
|
427
|
+
* Reads a workbook and hands sheet `sheet` over row by row, without
|
|
428
|
+
* building its grid: `callback(row, data)` gets the 1-based row number
|
|
429
|
+
* and what `getRowAt` would answer for it, and the row is dropped once
|
|
430
|
+
* the callback returns.
|
|
431
|
+
*
|
|
432
|
+
* The workbook comes back whole but for that sheet's cells. Only xlsx
|
|
433
|
+
* streams; any other format is read whole and then handed over the same
|
|
434
|
+
* way, so the callback sees the same rows but nothing is saved.
|
|
435
|
+
* A callback that throws is not called again, and what it threw comes
|
|
436
|
+
* out of `forEachRow` once the read is over.
|
|
437
|
+
* @param {Uint8Array} bytes
|
|
438
|
+
* @param {string | null | undefined} name
|
|
439
|
+
* @param {number} sheet
|
|
440
|
+
* @param {Function} callback
|
|
441
|
+
* @param {boolean | null} [formatted]
|
|
442
|
+
* @returns {Book}
|
|
443
|
+
*/
|
|
444
|
+
static forEachRow(bytes, name, sheet, callback, formatted) {
|
|
445
|
+
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
|
|
446
|
+
const len0 = WASM_VECTOR_LEN;
|
|
447
|
+
var ptr1 = isLikeNone(name) ? 0 : passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
448
|
+
var len1 = WASM_VECTOR_LEN;
|
|
449
|
+
const ret = wasm.book_forEachRow(ptr0, len0, ptr1, len1, sheet, callback, isLikeNone(formatted) ? 0xFFFFFF : formatted ? 1 : 0);
|
|
450
|
+
if (ret[2]) {
|
|
451
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
452
|
+
}
|
|
453
|
+
return Book.__wrap(ret[0]);
|
|
454
|
+
}
|
|
416
455
|
/**
|
|
417
456
|
* Freezes the first `rows` rows and `columns` columns, so they stay put
|
|
418
457
|
* while the rest scrolls. `freezePanes(0, 1, 0)` pins the header row;
|
|
@@ -610,6 +649,37 @@ class Book {
|
|
|
610
649
|
}
|
|
611
650
|
return takeFromExternrefTable0(ret[0]);
|
|
612
651
|
}
|
|
652
|
+
/**
|
|
653
|
+
* The runs of a cell's formatted text: `{ text, font }` each, `font`
|
|
654
|
+
* naming only what the run changes about the cell's font, or `null` for
|
|
655
|
+
* a run in the cell's own. `null` for a cell without formatted text.
|
|
656
|
+
* @param {number} sheet
|
|
657
|
+
* @param {string} address
|
|
658
|
+
* @returns {TextRun[] | null}
|
|
659
|
+
*/
|
|
660
|
+
getRichText(sheet, address) {
|
|
661
|
+
const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
662
|
+
const len0 = WASM_VECTOR_LEN;
|
|
663
|
+
const ret = wasm.book_getRichText(this.__wbg_ptr, sheet, ptr0, len0);
|
|
664
|
+
if (ret[2]) {
|
|
665
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
666
|
+
}
|
|
667
|
+
return takeFromExternrefTable0(ret[0]);
|
|
668
|
+
}
|
|
669
|
+
/**
|
|
670
|
+
* The same by 1-based row and column.
|
|
671
|
+
* @param {number} sheet
|
|
672
|
+
* @param {number} row
|
|
673
|
+
* @param {number} column
|
|
674
|
+
* @returns {TextRun[] | null}
|
|
675
|
+
*/
|
|
676
|
+
getRichTextAt(sheet, row, column) {
|
|
677
|
+
const ret = wasm.book_getRichTextAt(this.__wbg_ptr, sheet, row, column);
|
|
678
|
+
if (ret[2]) {
|
|
679
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
680
|
+
}
|
|
681
|
+
return takeFromExternrefTable0(ret[0]);
|
|
682
|
+
}
|
|
613
683
|
/**
|
|
614
684
|
* A whole row in one crossing of the boundary: values, displayed text,
|
|
615
685
|
* bold and indent, plus whether the row is hidden.
|
|
@@ -711,6 +781,20 @@ class Book {
|
|
|
711
781
|
throw takeFromExternrefTable0(ret[0]);
|
|
712
782
|
}
|
|
713
783
|
}
|
|
784
|
+
/**
|
|
785
|
+
* `insertRowsMany` for columns.
|
|
786
|
+
* @param {number} sheet
|
|
787
|
+
* @param {[number, number][]} places
|
|
788
|
+
* @param {"before" | "after" | "none"} [copyOrigin]
|
|
789
|
+
*/
|
|
790
|
+
insertColumnsMany(sheet, places, copyOrigin) {
|
|
791
|
+
var ptr0 = isLikeNone(copyOrigin) ? 0 : passStringToWasm0(copyOrigin, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
792
|
+
var len0 = WASM_VECTOR_LEN;
|
|
793
|
+
const ret = wasm.book_insertColumnsMany(this.__wbg_ptr, sheet, places, ptr0, len0);
|
|
794
|
+
if (ret[1]) {
|
|
795
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
796
|
+
}
|
|
797
|
+
}
|
|
714
798
|
/**
|
|
715
799
|
* Inserts `count` rows above row `at`, moving everything below down.
|
|
716
800
|
* `copyOrigin` - `"before"` (the row above), `"after"` (the row below)
|
|
@@ -733,6 +817,28 @@ class Book {
|
|
|
733
817
|
throw takeFromExternrefTable0(ret[0]);
|
|
734
818
|
}
|
|
735
819
|
}
|
|
820
|
+
/**
|
|
821
|
+
* Inserts rows at many places in one pass: `places` is `[at, count]`
|
|
822
|
+
* pairs, numbered as the sheet is before the call, in any order.
|
|
823
|
+
* `book.insertRowsMany(0, [[5, 1], [9, 1]])` puts a row above each of
|
|
824
|
+
* rows 5 and 9 - the old row 9, now row 10. Each new block takes its
|
|
825
|
+
* formatting from its own neighbour, as `copyOrigin` says.
|
|
826
|
+
*
|
|
827
|
+
* The result is that of the single inserts made from the bottom up, but
|
|
828
|
+
* the workbook is walked once rather than once per place: four thousand
|
|
829
|
+
* subtotal rows into forty thousand take milliseconds, not a minute.
|
|
830
|
+
* @param {number} sheet
|
|
831
|
+
* @param {[number, number][]} places
|
|
832
|
+
* @param {"before" | "after" | "none"} [copyOrigin]
|
|
833
|
+
*/
|
|
834
|
+
insertRowsMany(sheet, places, copyOrigin) {
|
|
835
|
+
var ptr0 = isLikeNone(copyOrigin) ? 0 : passStringToWasm0(copyOrigin, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
836
|
+
var len0 = WASM_VECTOR_LEN;
|
|
837
|
+
const ret = wasm.book_insertRowsMany(this.__wbg_ptr, sheet, places, ptr0, len0);
|
|
838
|
+
if (ret[1]) {
|
|
839
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
840
|
+
}
|
|
841
|
+
}
|
|
736
842
|
/**
|
|
737
843
|
* Merges a block of cells: `merge(0, "A1:C1")`.
|
|
738
844
|
* @param {number} sheet
|
|
@@ -872,19 +978,24 @@ class Book {
|
|
|
872
978
|
*
|
|
873
979
|
* `name` is the file name they came from, if the caller has one: it
|
|
874
980
|
* settles what the bytes cannot say (a `.csv` against a `.html`) and names
|
|
875
|
-
* the sheet of a SYLK file.
|
|
981
|
+
* the sheet of a SYLK file. `password` opens a workbook saved with a
|
|
982
|
+
* password to open; without it only one encrypted to be opened
|
|
983
|
+
* read-only reads.
|
|
876
984
|
* @param {Uint8Array} bytes
|
|
877
985
|
* @param {string | null} [name]
|
|
878
986
|
* @param {number | null} [max_expanded]
|
|
879
987
|
* @param {Function | null} [on_progress]
|
|
988
|
+
* @param {string | null} [password]
|
|
880
989
|
* @returns {Book}
|
|
881
990
|
*/
|
|
882
|
-
static read(bytes, name, max_expanded, on_progress) {
|
|
991
|
+
static read(bytes, name, max_expanded, on_progress, password) {
|
|
883
992
|
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
|
|
884
993
|
const len0 = WASM_VECTOR_LEN;
|
|
885
994
|
var ptr1 = isLikeNone(name) ? 0 : passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
886
995
|
var len1 = WASM_VECTOR_LEN;
|
|
887
|
-
|
|
996
|
+
var ptr2 = isLikeNone(password) ? 0 : passStringToWasm0(password, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
997
|
+
var len2 = WASM_VECTOR_LEN;
|
|
998
|
+
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), ptr2, len2);
|
|
888
999
|
if (ret[2]) {
|
|
889
1000
|
throw takeFromExternrefTable0(ret[1]);
|
|
890
1001
|
}
|
|
@@ -1073,6 +1184,17 @@ class Book {
|
|
|
1073
1184
|
throw takeFromExternrefTable0(ret[0]);
|
|
1074
1185
|
}
|
|
1075
1186
|
}
|
|
1187
|
+
/**
|
|
1188
|
+
* `removeRowsMany` for columns.
|
|
1189
|
+
* @param {number} sheet
|
|
1190
|
+
* @param {[number, number][]} places
|
|
1191
|
+
*/
|
|
1192
|
+
removeColumnsMany(sheet, places) {
|
|
1193
|
+
const ret = wasm.book_removeColumnsMany(this.__wbg_ptr, sheet, places);
|
|
1194
|
+
if (ret[1]) {
|
|
1195
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1196
|
+
}
|
|
1197
|
+
}
|
|
1076
1198
|
/**
|
|
1077
1199
|
* Takes a note off a cell. Answers whether there was one.
|
|
1078
1200
|
* @param {number} sheet
|
|
@@ -1128,6 +1250,18 @@ class Book {
|
|
|
1128
1250
|
throw takeFromExternrefTable0(ret[0]);
|
|
1129
1251
|
}
|
|
1130
1252
|
}
|
|
1253
|
+
/**
|
|
1254
|
+
* Removes rows at many places in one pass: `[at, count]` pairs, numbered
|
|
1255
|
+
* as the sheet is before the call. Blocks that overlap are merged.
|
|
1256
|
+
* @param {number} sheet
|
|
1257
|
+
* @param {[number, number][]} places
|
|
1258
|
+
*/
|
|
1259
|
+
removeRowsMany(sheet, places) {
|
|
1260
|
+
const ret = wasm.book_removeRowsMany(this.__wbg_ptr, sheet, places);
|
|
1261
|
+
if (ret[1]) {
|
|
1262
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1263
|
+
}
|
|
1264
|
+
}
|
|
1131
1265
|
/**
|
|
1132
1266
|
* Removes a sheet. References to it from anywhere in the workbook become
|
|
1133
1267
|
* `#REF!`, the way Excel writes them, and the sheets after it shift down
|
|
@@ -1289,6 +1423,21 @@ class Book {
|
|
|
1289
1423
|
throw takeFromExternrefTable0(ret[0]);
|
|
1290
1424
|
}
|
|
1291
1425
|
}
|
|
1426
|
+
/**
|
|
1427
|
+
* Changes the fill and outline of a chart's chart area (`format`) and
|
|
1428
|
+
* plot area (`plotFormat`), by its position in `charts`; each takes
|
|
1429
|
+
* `{ fill, line }` as `setShapeFormat` does, or `null` to leave the area
|
|
1430
|
+
* to the chart style.
|
|
1431
|
+
* @param {number} sheet
|
|
1432
|
+
* @param {number} index
|
|
1433
|
+
* @param {ChartFormatPatch} patch
|
|
1434
|
+
*/
|
|
1435
|
+
setChartFormat(sheet, index, patch) {
|
|
1436
|
+
const ret = wasm.book_setChartFormat(this.__wbg_ptr, sheet, index, patch);
|
|
1437
|
+
if (ret[1]) {
|
|
1438
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1439
|
+
}
|
|
1440
|
+
}
|
|
1292
1441
|
/**
|
|
1293
1442
|
* Hides a column, or shows it again. `column` is 1-based.
|
|
1294
1443
|
* @param {number} sheet
|
|
@@ -1354,6 +1503,19 @@ class Book {
|
|
|
1354
1503
|
throw takeFromExternrefTable0(ret[0]);
|
|
1355
1504
|
}
|
|
1356
1505
|
}
|
|
1506
|
+
/**
|
|
1507
|
+
* Changes the fields the patch names and leaves the rest: a string sets
|
|
1508
|
+
* one, `null` clears it. `custom`, when given, replaces the list; a
|
|
1509
|
+
* field's type is taken from `type` or else from the value (a whole
|
|
1510
|
+
* number is an integer).
|
|
1511
|
+
* @param {DocumentPropertiesPatch} patch
|
|
1512
|
+
*/
|
|
1513
|
+
setDocumentProperties(patch) {
|
|
1514
|
+
const ret = wasm.book_setDocumentProperties(this.__wbg_ptr, patch);
|
|
1515
|
+
if (ret[1]) {
|
|
1516
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1517
|
+
}
|
|
1518
|
+
}
|
|
1357
1519
|
/**
|
|
1358
1520
|
* Puts a link over a cell or a block of them.
|
|
1359
1521
|
*
|
|
@@ -1455,6 +1617,35 @@ class Book {
|
|
|
1455
1617
|
throw takeFromExternrefTable0(ret[0]);
|
|
1456
1618
|
}
|
|
1457
1619
|
}
|
|
1620
|
+
/**
|
|
1621
|
+
* Writes formatted text: runs as `getRichText` returns them, each with
|
|
1622
|
+
* its own text and the part of the font it changes (`font` may be left
|
|
1623
|
+
* out or `null` for the cell's own).
|
|
1624
|
+
* @param {number} sheet
|
|
1625
|
+
* @param {string} address
|
|
1626
|
+
* @param {TextRun[]} runs
|
|
1627
|
+
*/
|
|
1628
|
+
setRichText(sheet, address, runs) {
|
|
1629
|
+
const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1630
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1631
|
+
const ret = wasm.book_setRichText(this.__wbg_ptr, sheet, ptr0, len0, runs);
|
|
1632
|
+
if (ret[1]) {
|
|
1633
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1634
|
+
}
|
|
1635
|
+
}
|
|
1636
|
+
/**
|
|
1637
|
+
* The same by 1-based row and column.
|
|
1638
|
+
* @param {number} sheet
|
|
1639
|
+
* @param {number} row
|
|
1640
|
+
* @param {number} column
|
|
1641
|
+
* @param {TextRun[]} runs
|
|
1642
|
+
*/
|
|
1643
|
+
setRichTextAt(sheet, row, column, runs) {
|
|
1644
|
+
const ret = wasm.book_setRichTextAt(this.__wbg_ptr, sheet, row, column, runs);
|
|
1645
|
+
if (ret[1]) {
|
|
1646
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1647
|
+
}
|
|
1648
|
+
}
|
|
1458
1649
|
/**
|
|
1459
1650
|
* Sets the height of a row in points, or gives it back to the sheet
|
|
1460
1651
|
* default with `undefined`. `row` is the number a user sees.
|
|
@@ -1480,6 +1671,34 @@ class Book {
|
|
|
1480
1671
|
throw takeFromExternrefTable0(ret[0]);
|
|
1481
1672
|
}
|
|
1482
1673
|
}
|
|
1674
|
+
/**
|
|
1675
|
+
* Changes how a shape looks, by its position in `shapes`:
|
|
1676
|
+
*
|
|
1677
|
+
* ```js
|
|
1678
|
+
* book.setShapeFormat(0, 2, {
|
|
1679
|
+
* fill: { type: "solid", color: "accent2" },
|
|
1680
|
+
* line: { width: 2 },
|
|
1681
|
+
* font: { bold: true, color: "#FFFFFFFF" },
|
|
1682
|
+
* rotation: 15,
|
|
1683
|
+
* });
|
|
1684
|
+
* ```
|
|
1685
|
+
*
|
|
1686
|
+
* `fill`, `line`, `font`, `rotation` (degrees clockwise), `flipH` and
|
|
1687
|
+
* `flipV`; a field left out stays as it was, `null` for `fill` or `line`
|
|
1688
|
+
* gives it back to the shape's style. A colour is `#RRGGBB`,
|
|
1689
|
+
* `#AARRGGBB` or a theme colour by name (`accent1`, `tx1`, `bg2`), which
|
|
1690
|
+
* follows the theme. The rest of the shape - effects, other runs, the
|
|
1691
|
+
* outline's dashes - stays in the file as it was.
|
|
1692
|
+
* @param {number} sheet
|
|
1693
|
+
* @param {number} index
|
|
1694
|
+
* @param {ShapeFormatPatch} patch
|
|
1695
|
+
*/
|
|
1696
|
+
setShapeFormat(sheet, index, patch) {
|
|
1697
|
+
const ret = wasm.book_setShapeFormat(this.__wbg_ptr, sheet, index, patch);
|
|
1698
|
+
if (ret[1]) {
|
|
1699
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1700
|
+
}
|
|
1701
|
+
}
|
|
1483
1702
|
/**
|
|
1484
1703
|
* Gives a sheet a tab or takes it away: `"visible"`, `"hidden"` or
|
|
1485
1704
|
* `"veryHidden"`.
|
|
@@ -1511,6 +1730,33 @@ class Book {
|
|
|
1511
1730
|
throw takeFromExternrefTable0(ret[0]);
|
|
1512
1731
|
}
|
|
1513
1732
|
}
|
|
1733
|
+
/**
|
|
1734
|
+
* Filters a table by one of its columns, named by its header or
|
|
1735
|
+
* numbered from 1, and hides the data rows the table's criteria reject,
|
|
1736
|
+
* as Excel does. `null` takes the column's criterion off.
|
|
1737
|
+
*
|
|
1738
|
+
* ```js
|
|
1739
|
+
* book.setTableFilter("Sales", "Region", { values: ["South", "West"] });
|
|
1740
|
+
* book.setTableFilter("Sales", "Amount", { custom: [{ op: ">", value: 100 }] });
|
|
1741
|
+
* book.setTableFilter("Sales", 3, { top: 5 }); // or { bottom: 10, percent: true }
|
|
1742
|
+
* ```
|
|
1743
|
+
*
|
|
1744
|
+
* `values` keeps a row whose cell shows one of them, `blank: true` the
|
|
1745
|
+
* empty ones too; `custom` takes one or two comparisons (`=`, `<>`, `>`,
|
|
1746
|
+
* `>=`, `<`, `<=`; `*` and `?` in `=` and `<>`), joined by `or` unless
|
|
1747
|
+
* `and` is set. Criteria on several columns all have to hold.
|
|
1748
|
+
* @param {string} name
|
|
1749
|
+
* @param {string | number} column
|
|
1750
|
+
* @param {TableFilter | null} criteria
|
|
1751
|
+
*/
|
|
1752
|
+
setTableFilter(name, column, criteria) {
|
|
1753
|
+
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1754
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1755
|
+
const ret = wasm.book_setTableFilter(this.__wbg_ptr, ptr0, len0, column, criteria);
|
|
1756
|
+
if (ret[1]) {
|
|
1757
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1758
|
+
}
|
|
1759
|
+
}
|
|
1514
1760
|
/**
|
|
1515
1761
|
* The zoom a reader opens the sheet at, in percent; `undefined` gives it
|
|
1516
1762
|
* back to 100.
|
|
@@ -1524,7 +1770,9 @@ class Book {
|
|
|
1524
1770
|
}
|
|
1525
1771
|
}
|
|
1526
1772
|
/**
|
|
1527
|
-
* The drawn shapes of a sheet, text and all
|
|
1773
|
+
* The drawn shapes of a sheet, text and all, with the look Excel shows:
|
|
1774
|
+
* fill, outline and font are the shape's own with its style filling in
|
|
1775
|
+
* the rest, colours resolved through the workbook theme.
|
|
1528
1776
|
* @param {number} sheet
|
|
1529
1777
|
* @returns {SheetShape[]}
|
|
1530
1778
|
*/
|
|
@@ -1910,10 +2158,18 @@ function __wbg_get_imports() {
|
|
|
1910
2158
|
const ret = Reflect.apply(arg0, arg1, arg2);
|
|
1911
2159
|
return ret;
|
|
1912
2160
|
}, arguments); },
|
|
2161
|
+
__wbg_call_0f2a9af232c18fd2: function() { return handleError(function (arg0, arg1, arg2, arg3) {
|
|
2162
|
+
const ret = arg0.call(arg1, arg2, arg3);
|
|
2163
|
+
return ret;
|
|
2164
|
+
}, arguments); },
|
|
1913
2165
|
__wbg_call_35dba3c747ad7521: function() { return handleError(function (arg0, arg1, arg2) {
|
|
1914
2166
|
const ret = arg0.call(arg1, arg2);
|
|
1915
2167
|
return ret;
|
|
1916
2168
|
}, arguments); },
|
|
2169
|
+
__wbg_from_74f3d90e0ff11240: function(arg0) {
|
|
2170
|
+
const ret = Array.from(arg0);
|
|
2171
|
+
return ret;
|
|
2172
|
+
},
|
|
1917
2173
|
__wbg_getRandomValues_436a51d0629d84e1: function() { return handleError(function (arg0, arg1) {
|
|
1918
2174
|
globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
|
|
1919
2175
|
}, arguments); },
|
|
@@ -1925,6 +2181,10 @@ function __wbg_get_imports() {
|
|
|
1925
2181
|
const ret = Reflect.get(arg0, arg1);
|
|
1926
2182
|
return ret;
|
|
1927
2183
|
}, arguments); },
|
|
2184
|
+
__wbg_get_c0c8f8d7da0c03dd: function(arg0, arg1) {
|
|
2185
|
+
const ret = arg0[arg1 >>> 0];
|
|
2186
|
+
return ret;
|
|
2187
|
+
},
|
|
1928
2188
|
__wbg_get_unchecked_e20b893aeafc3fca: function(arg0, arg1) {
|
|
1929
2189
|
const ret = arg0[arg1 >>> 0];
|
|
1930
2190
|
return ret;
|
|
@@ -1937,6 +2197,10 @@ function __wbg_get_imports() {
|
|
|
1937
2197
|
const ret = arg0.length;
|
|
1938
2198
|
return ret;
|
|
1939
2199
|
},
|
|
2200
|
+
__wbg_message_c141d5e68716b595: function(arg0) {
|
|
2201
|
+
const ret = arg0.message;
|
|
2202
|
+
return ret;
|
|
2203
|
+
},
|
|
1940
2204
|
__wbg_new_0_f117d868b403dc07: function() {
|
|
1941
2205
|
const ret = new Date();
|
|
1942
2206
|
return ret;
|
package/excelerate_bg.wasm
CHANGED
|
Binary file
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
export * from "./excelerate";
|
|
2
|
+
import type { Book, CellValue, CellGrid, CellStylePatch, SheetTable, SortKeys, TableFilter, CsvOptions } from "./excelerate";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Objects over `Book`, whose changing methods return themselves so calls chain:
|
|
6
|
+
*
|
|
7
|
+
* ```js
|
|
8
|
+
* const wb = new Workbook();
|
|
9
|
+
* const sales = wb.addSheet("Sales")
|
|
10
|
+
* .addTableFromData("Sales", "A1", [["Region", "Amount"], ["North", 120], ["South", 340]])
|
|
11
|
+
* .set(1, "Amount", 125)
|
|
12
|
+
* .addFilter("Region", { values: ["South"] });
|
|
13
|
+
* sales.records({ visible: true }); // [{ Region: "South", Amount: 340 }]
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* Each object is a handle - a sheet index, a table name, an address - and
|
|
17
|
+
* works through `workbook.book`, which is there for everything not wrapped.
|
|
18
|
+
*/
|
|
19
|
+
export declare class Workbook {
|
|
20
|
+
/** A new workbook, or one over a `Book` already in hand. */
|
|
21
|
+
constructor(book?: Book);
|
|
22
|
+
readonly book: Book;
|
|
23
|
+
/** Reads any format `Book.read` reads. */
|
|
24
|
+
static read(bytes: Uint8Array, name?: string, maxExpanded?: number, onProgress?: Function, password?: string): Workbook;
|
|
25
|
+
static readCsv(bytes: Uint8Array, options: CsvOptions): Workbook;
|
|
26
|
+
/** Hands one sheet over row by row without keeping its grid; the rest of the workbook comes back. */
|
|
27
|
+
static forEachRow(bytes: Uint8Array, name: string | null | undefined, sheet: number, callback: Function, formatted?: boolean | null): Workbook;
|
|
28
|
+
/** A sheet by position (from 0) or by name. */
|
|
29
|
+
sheet(which: number | string): Sheet;
|
|
30
|
+
sheets(): Sheet[];
|
|
31
|
+
/** Adds a sheet at the end. On a new workbook the first call takes over its empty "Sheet1". */
|
|
32
|
+
addSheet(name?: string): Sheet;
|
|
33
|
+
recalculate(onProgress?: Function): this;
|
|
34
|
+
toXlsx(onProgress?: Function): Uint8Array;
|
|
35
|
+
free(): void;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export declare class Sheet {
|
|
39
|
+
readonly workbook: Workbook;
|
|
40
|
+
/** The tab position the sheet had when it was handed out. */
|
|
41
|
+
readonly index: number;
|
|
42
|
+
readonly book: Book;
|
|
43
|
+
readonly name: string;
|
|
44
|
+
rename(name: string): this;
|
|
45
|
+
/** What the cell shows, through its number format. */
|
|
46
|
+
text(address: string): string;
|
|
47
|
+
/** A block of values whose top left corner lands on `at`. */
|
|
48
|
+
write(at: string, rows: CellGrid): this;
|
|
49
|
+
range(address: string): SheetRange;
|
|
50
|
+
style(address: string, patch: CellStylePatch): this;
|
|
51
|
+
/** Column width in characters; the column is a letter or a number from 1. */
|
|
52
|
+
width(column: string | number, characters?: number): this;
|
|
53
|
+
/** Freezes the rows above and the columns to the left; zeros unfreeze. */
|
|
54
|
+
freeze(rows: number, columns?: number): this;
|
|
55
|
+
/** A table over a range already filled. */
|
|
56
|
+
addTable(name: string, address: string, options?: { header?: boolean }): Table;
|
|
57
|
+
/** Writes `rows` from `at` - the first is the header - and draws a table over them. */
|
|
58
|
+
addTableFromData(name: string, at: string, rows: CellGrid): Table;
|
|
59
|
+
table(name: string): Table;
|
|
60
|
+
tables(): Table[];
|
|
61
|
+
/** Makes this the sheet a workbook opens on. */
|
|
62
|
+
activate(): this;
|
|
63
|
+
/** Recalculates the formulas of this sheet. */
|
|
64
|
+
recalculate(onProgress?: Function): this;
|
|
65
|
+
/** Removes the sheet; handles to the sheets after it go stale. */
|
|
66
|
+
remove(): Workbook;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export declare class Table {
|
|
70
|
+
readonly sheet: Sheet;
|
|
71
|
+
readonly name: string;
|
|
72
|
+
readonly book: Book;
|
|
73
|
+
readonly columns: string[];
|
|
74
|
+
info(): SheetTable;
|
|
75
|
+
/** The whole table, header and totals included; with an address, a range of the sheet. */
|
|
76
|
+
range(address?: string): SheetRange;
|
|
77
|
+
/** The data rows, without the header and totals. */
|
|
78
|
+
data(): SheetRange;
|
|
79
|
+
/** The sheet address of a data cell: `row` from 1, `column` a header or a number from 1. */
|
|
80
|
+
address(row: number, column: string | number): string;
|
|
81
|
+
columnIndex(header: string): number;
|
|
82
|
+
set(row: number, column: string | number, value: CellValue): this;
|
|
83
|
+
get(row: number, column: string | number): CellValue;
|
|
84
|
+
/** Filters by a column and hides the rows that fail, as Excel does. */
|
|
85
|
+
addFilter(column: string | number, criteria: TableFilter): this;
|
|
86
|
+
/** Takes the criterion off one column, or off all of them. */
|
|
87
|
+
clearFilter(column?: string | number): this;
|
|
88
|
+
/** `["Region", "-Amount"]`: a minus sorts largest first. */
|
|
89
|
+
sort(keys: SortKeys): this;
|
|
90
|
+
/** The data rows keyed by header; `visible` leaves out hidden rows. */
|
|
91
|
+
records(options?: { visible?: boolean }): Record<string, CellValue>[];
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export declare class SheetRange {
|
|
95
|
+
readonly sheet: Sheet;
|
|
96
|
+
readonly address: string;
|
|
97
|
+
readonly book: Book;
|
|
98
|
+
values(): CellGrid;
|
|
99
|
+
/** The values of the rows a filter or a user has not hidden. */
|
|
100
|
+
visibleValues(): CellGrid;
|
|
101
|
+
/** Writes a block from the top left corner of the range. */
|
|
102
|
+
set(rows: CellGrid): this;
|
|
103
|
+
style(patch: CellStylePatch): this;
|
|
104
|
+
merge(): this;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Every `Book` method that takes the sheet first is a `Sheet` method without
|
|
109
|
+
* it; one that answers with nothing returns the sheet, so it chains.
|
|
110
|
+
* `sheet.setColumnWidth(2, 14).setRowHidden(5, true).getRange("A1:C3")`.
|
|
111
|
+
*/
|
|
112
|
+
type SheetActionName =
|
|
113
|
+
| "clear" | "clearAt" | "copyRange" | "fillDown" | "fillRight" | "fillSeries"
|
|
114
|
+
| "freezePanes" | "insertCells" | "insertColumns" | "insertColumnsMany"
|
|
115
|
+
| "insertRows" | "insertRowsMany" | "merge" | "moveRange" | "protectSheet"
|
|
116
|
+
| "removeCells" | "removeColumns" | "removeColumnsMany" | "removeRows"
|
|
117
|
+
| "removeRowsMany" | "set" | "setAt" | "setCellStyle" | "setCellStyleAt"
|
|
118
|
+
| "setChartFormat" | "setColumnHidden" | "setColumnWidth" | "setComment"
|
|
119
|
+
| "setHyperlink" | "setRange" | "setRangeAt" | "setRangeStyle"
|
|
120
|
+
| "setRangeStyles" | "setRangeStylesAt" | "setRichText" | "setRichTextAt"
|
|
121
|
+
| "setRowHeight" | "setRowHidden" | "setShapeFormat" | "setSheetVisibility"
|
|
122
|
+
| "setShowGridLines" | "setZoom" | "sortRange" | "unprotectSheet";
|
|
123
|
+
type SheetQueryName =
|
|
124
|
+
| "arrayFormulas" | "autoFilter" | "cellBold" | "cellBoldAt" | "cellCount"
|
|
125
|
+
| "cellIndent" | "cellIndentAt" | "cellStyle" | "cellStyleAt" | "charts"
|
|
126
|
+
| "columnLevel" | "columnWidth" | "comments" | "conditionalFormats"
|
|
127
|
+
| "dataValidations" | "evaluate" | "get" | "getAt" | "getFormatted"
|
|
128
|
+
| "getFormattedAt" | "getFormula" | "getFormulaAt" | "getRange" | "getRangeAt"
|
|
129
|
+
| "getRangeStyles" | "getRangeStylesAt" | "getRichText" | "getRichTextAt"
|
|
130
|
+
| "getRowAt" | "hyperlinks" | "imageData" | "images" | "mergedRanges"
|
|
131
|
+
| "mergedRangesAt" | "pivotTables" | "recalculateCell" | "recalculateCellAt"
|
|
132
|
+
| "recalculateFrom" | "recalculateFromAt" | "recalculateFromMany"
|
|
133
|
+
| "removeComment" | "removeHyperlink" | "removeTable" | "rowHeight"
|
|
134
|
+
| "rowHidden" | "rowLevel" | "shapes" | "sheetProtection" | "sheetView"
|
|
135
|
+
| "sheetVisibility" | "toCsv" | "toHtml" | "unmerge" | "usedRange"
|
|
136
|
+
| "usedRangeHint" | "verifySheetPassword";
|
|
137
|
+
/** Every `Book` method without a sheet is a `Workbook` method, chaining the same way. */
|
|
138
|
+
type BookActionName =
|
|
139
|
+
| "moveSheet" | "protectWorkbook" | "registerFunction" | "setDefinedName"
|
|
140
|
+
| "setDocumentProperties" | "setTableFilter" | "sortTable" | "unprotectWorkbook";
|
|
141
|
+
type BookQueryName =
|
|
142
|
+
| "activeSheet" | "definedNames" | "documentProperties" | "externalBooks"
|
|
143
|
+
| "registeredFunctions" | "removeDefinedName" | "sheetIndex" | "sheetNames"
|
|
144
|
+
| "toOds" | "toXls" | "unregisterFunction" | "workbookProtection";
|
|
145
|
+
|
|
146
|
+
type SheetActions = {
|
|
147
|
+
[P in SheetActionName]: Book[P] extends (sheet: any, ...rest: infer A) => any ? (...rest: A) => Sheet : never;
|
|
148
|
+
};
|
|
149
|
+
type SheetQueries = {
|
|
150
|
+
[P in SheetQueryName]: Book[P] extends (sheet: any, ...rest: infer A) => infer R ? (...rest: A) => R : never;
|
|
151
|
+
};
|
|
152
|
+
type BookActions = {
|
|
153
|
+
[P in BookActionName]: Book[P] extends (...args: infer A) => any ? (...args: A) => Workbook : never;
|
|
154
|
+
};
|
|
155
|
+
type BookQueries = {
|
|
156
|
+
[P in BookQueryName]: Book[P] extends (...args: infer A) => infer R ? (...args: A) => R : never;
|
|
157
|
+
};
|
|
158
|
+
export interface Sheet extends SheetActions, SheetQueries {}
|
|
159
|
+
export interface Workbook extends BookActions, BookQueries {}
|