@rosperitus/excelerate 0.14.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 +135 -9
- package/excelerate.d.ts +183 -8
- package/excelerate.js +181 -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
|
@@ -423,6 +423,35 @@ class Book {
|
|
|
423
423
|
throw takeFromExternrefTable0(ret[0]);
|
|
424
424
|
}
|
|
425
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
|
+
}
|
|
426
455
|
/**
|
|
427
456
|
* Freezes the first `rows` rows and `columns` columns, so they stay put
|
|
428
457
|
* while the rest scrolls. `freezePanes(0, 1, 0)` pins the header row;
|
|
@@ -752,6 +781,20 @@ class Book {
|
|
|
752
781
|
throw takeFromExternrefTable0(ret[0]);
|
|
753
782
|
}
|
|
754
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
|
+
}
|
|
755
798
|
/**
|
|
756
799
|
* Inserts `count` rows above row `at`, moving everything below down.
|
|
757
800
|
* `copyOrigin` - `"before"` (the row above), `"after"` (the row below)
|
|
@@ -774,6 +817,28 @@ class Book {
|
|
|
774
817
|
throw takeFromExternrefTable0(ret[0]);
|
|
775
818
|
}
|
|
776
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
|
+
}
|
|
777
842
|
/**
|
|
778
843
|
* Merges a block of cells: `merge(0, "A1:C1")`.
|
|
779
844
|
* @param {number} sheet
|
|
@@ -913,19 +978,24 @@ class Book {
|
|
|
913
978
|
*
|
|
914
979
|
* `name` is the file name they came from, if the caller has one: it
|
|
915
980
|
* settles what the bytes cannot say (a `.csv` against a `.html`) and names
|
|
916
|
-
* 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.
|
|
917
984
|
* @param {Uint8Array} bytes
|
|
918
985
|
* @param {string | null} [name]
|
|
919
986
|
* @param {number | null} [max_expanded]
|
|
920
987
|
* @param {Function | null} [on_progress]
|
|
988
|
+
* @param {string | null} [password]
|
|
921
989
|
* @returns {Book}
|
|
922
990
|
*/
|
|
923
|
-
static read(bytes, name, max_expanded, on_progress) {
|
|
991
|
+
static read(bytes, name, max_expanded, on_progress, password) {
|
|
924
992
|
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
|
|
925
993
|
const len0 = WASM_VECTOR_LEN;
|
|
926
994
|
var ptr1 = isLikeNone(name) ? 0 : passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
927
995
|
var len1 = WASM_VECTOR_LEN;
|
|
928
|
-
|
|
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);
|
|
929
999
|
if (ret[2]) {
|
|
930
1000
|
throw takeFromExternrefTable0(ret[1]);
|
|
931
1001
|
}
|
|
@@ -1114,6 +1184,17 @@ class Book {
|
|
|
1114
1184
|
throw takeFromExternrefTable0(ret[0]);
|
|
1115
1185
|
}
|
|
1116
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
|
+
}
|
|
1117
1198
|
/**
|
|
1118
1199
|
* Takes a note off a cell. Answers whether there was one.
|
|
1119
1200
|
* @param {number} sheet
|
|
@@ -1169,6 +1250,18 @@ class Book {
|
|
|
1169
1250
|
throw takeFromExternrefTable0(ret[0]);
|
|
1170
1251
|
}
|
|
1171
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
|
+
}
|
|
1172
1265
|
/**
|
|
1173
1266
|
* Removes a sheet. References to it from anywhere in the workbook become
|
|
1174
1267
|
* `#REF!`, the way Excel writes them, and the sheets after it shift down
|
|
@@ -1330,6 +1423,21 @@ class Book {
|
|
|
1330
1423
|
throw takeFromExternrefTable0(ret[0]);
|
|
1331
1424
|
}
|
|
1332
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
|
+
}
|
|
1333
1441
|
/**
|
|
1334
1442
|
* Hides a column, or shows it again. `column` is 1-based.
|
|
1335
1443
|
* @param {number} sheet
|
|
@@ -1563,6 +1671,34 @@ class Book {
|
|
|
1563
1671
|
throw takeFromExternrefTable0(ret[0]);
|
|
1564
1672
|
}
|
|
1565
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
|
+
}
|
|
1566
1702
|
/**
|
|
1567
1703
|
* Gives a sheet a tab or takes it away: `"visible"`, `"hidden"` or
|
|
1568
1704
|
* `"veryHidden"`.
|
|
@@ -1594,6 +1730,33 @@ class Book {
|
|
|
1594
1730
|
throw takeFromExternrefTable0(ret[0]);
|
|
1595
1731
|
}
|
|
1596
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
|
+
}
|
|
1597
1760
|
/**
|
|
1598
1761
|
* The zoom a reader opens the sheet at, in percent; `undefined` gives it
|
|
1599
1762
|
* back to 100.
|
|
@@ -1607,7 +1770,9 @@ class Book {
|
|
|
1607
1770
|
}
|
|
1608
1771
|
}
|
|
1609
1772
|
/**
|
|
1610
|
-
* 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.
|
|
1611
1776
|
* @param {number} sheet
|
|
1612
1777
|
* @returns {SheetShape[]}
|
|
1613
1778
|
*/
|
|
@@ -1993,6 +2158,10 @@ function __wbg_get_imports() {
|
|
|
1993
2158
|
const ret = Reflect.apply(arg0, arg1, arg2);
|
|
1994
2159
|
return ret;
|
|
1995
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); },
|
|
1996
2165
|
__wbg_call_35dba3c747ad7521: function() { return handleError(function (arg0, arg1, arg2) {
|
|
1997
2166
|
const ret = arg0.call(arg1, arg2);
|
|
1998
2167
|
return ret;
|
|
@@ -2012,6 +2181,10 @@ function __wbg_get_imports() {
|
|
|
2012
2181
|
const ret = Reflect.get(arg0, arg1);
|
|
2013
2182
|
return ret;
|
|
2014
2183
|
}, arguments); },
|
|
2184
|
+
__wbg_get_c0c8f8d7da0c03dd: function(arg0, arg1) {
|
|
2185
|
+
const ret = arg0[arg1 >>> 0];
|
|
2186
|
+
return ret;
|
|
2187
|
+
},
|
|
2015
2188
|
__wbg_get_unchecked_e20b893aeafc3fca: function(arg0, arg1) {
|
|
2016
2189
|
const ret = arg0[arg1 >>> 0];
|
|
2017
2190
|
return ret;
|
|
@@ -2024,6 +2197,10 @@ function __wbg_get_imports() {
|
|
|
2024
2197
|
const ret = arg0.length;
|
|
2025
2198
|
return ret;
|
|
2026
2199
|
},
|
|
2200
|
+
__wbg_message_c141d5e68716b595: function(arg0) {
|
|
2201
|
+
const ret = arg0.message;
|
|
2202
|
+
return ret;
|
|
2203
|
+
},
|
|
2027
2204
|
__wbg_new_0_f117d868b403dc07: function() {
|
|
2028
2205
|
const ret = new Date();
|
|
2029
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 {}
|