@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
|
@@ -0,0 +1,2519 @@
|
|
|
1
|
+
/* @ts-self-types="./excelerate.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A workbook.
|
|
5
|
+
*/
|
|
6
|
+
export class Book {
|
|
7
|
+
static __wrap(ptr) {
|
|
8
|
+
const obj = Object.create(Book.prototype);
|
|
9
|
+
obj.__wbg_ptr = ptr;
|
|
10
|
+
BookFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
11
|
+
return obj;
|
|
12
|
+
}
|
|
13
|
+
__destroy_into_raw() {
|
|
14
|
+
const ptr = this.__wbg_ptr;
|
|
15
|
+
this.__wbg_ptr = 0;
|
|
16
|
+
BookFinalization.unregister(this);
|
|
17
|
+
return ptr;
|
|
18
|
+
}
|
|
19
|
+
free() {
|
|
20
|
+
const ptr = this.__destroy_into_raw();
|
|
21
|
+
wasm.__wbg_book_free(ptr, 0);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The tab a reader opens the workbook on.
|
|
25
|
+
* @returns {number}
|
|
26
|
+
*/
|
|
27
|
+
activeSheet() {
|
|
28
|
+
const ret = wasm.book_activeSheet(this.__wbg_ptr);
|
|
29
|
+
return ret >>> 0;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Appends a sheet and returns its index.
|
|
33
|
+
* @param {string} title
|
|
34
|
+
* @returns {number}
|
|
35
|
+
*/
|
|
36
|
+
addSheet(title) {
|
|
37
|
+
const ptr0 = passStringToWasm0(title, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
38
|
+
const len0 = WASM_VECTOR_LEN;
|
|
39
|
+
const ret = wasm.book_addSheet(this.__wbg_ptr, ptr0, len0);
|
|
40
|
+
if (ret[2]) {
|
|
41
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
42
|
+
}
|
|
43
|
+
return ret[0] >>> 0;
|
|
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
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Whether a cell is bold.
|
|
96
|
+
*
|
|
97
|
+
* The one flag, without building the rest of the style: a parser that
|
|
98
|
+
* looks for a header row asks this of every cell, and `cellStyle` would
|
|
99
|
+
* make it pay for the font, fill and four borders it never reads.
|
|
100
|
+
* @param {number} sheet
|
|
101
|
+
* @param {string} address
|
|
102
|
+
* @returns {boolean}
|
|
103
|
+
*/
|
|
104
|
+
cellBold(sheet, address) {
|
|
105
|
+
const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
106
|
+
const len0 = WASM_VECTOR_LEN;
|
|
107
|
+
const ret = wasm.book_cellBold(this.__wbg_ptr, sheet, ptr0, len0);
|
|
108
|
+
if (ret[2]) {
|
|
109
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
110
|
+
}
|
|
111
|
+
return ret[0] !== 0;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* The same by 1-based row and column.
|
|
115
|
+
* @param {number} sheet
|
|
116
|
+
* @param {number} row
|
|
117
|
+
* @param {number} column
|
|
118
|
+
* @returns {boolean}
|
|
119
|
+
*/
|
|
120
|
+
cellBoldAt(sheet, row, column) {
|
|
121
|
+
const ret = wasm.book_cellBoldAt(this.__wbg_ptr, sheet, row, column);
|
|
122
|
+
if (ret[2]) {
|
|
123
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
124
|
+
}
|
|
125
|
+
return ret[0] !== 0;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* How many non-empty cells the workbook holds, or one sheet of it.
|
|
129
|
+
* @param {number | null} [sheet]
|
|
130
|
+
* @returns {number}
|
|
131
|
+
*/
|
|
132
|
+
cellCount(sheet) {
|
|
133
|
+
const ret = wasm.book_cellCount(this.__wbg_ptr, isLikeNone(sheet) ? Number.MAX_SAFE_INTEGER : (sheet) >>> 0);
|
|
134
|
+
return ret >>> 0;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* The indent of a cell, in Excel's indent steps (0 when it has none).
|
|
138
|
+
*
|
|
139
|
+
* Indent lives on the cell's style, and a spreadsheet only honours it for
|
|
140
|
+
* left, right and distributed alignment - but the number is returned as
|
|
141
|
+
* the file states it, whatever the alignment.
|
|
142
|
+
* @param {number} sheet
|
|
143
|
+
* @param {string} address
|
|
144
|
+
* @returns {number}
|
|
145
|
+
*/
|
|
146
|
+
cellIndent(sheet, address) {
|
|
147
|
+
const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
148
|
+
const len0 = WASM_VECTOR_LEN;
|
|
149
|
+
const ret = wasm.book_cellIndent(this.__wbg_ptr, sheet, ptr0, len0);
|
|
150
|
+
if (ret[2]) {
|
|
151
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
152
|
+
}
|
|
153
|
+
return ret[0] >>> 0;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* The same by 1-based row and column.
|
|
157
|
+
* @param {number} sheet
|
|
158
|
+
* @param {number} row
|
|
159
|
+
* @param {number} column
|
|
160
|
+
* @returns {number}
|
|
161
|
+
*/
|
|
162
|
+
cellIndentAt(sheet, row, column) {
|
|
163
|
+
const ret = wasm.book_cellIndentAt(this.__wbg_ptr, sheet, row, column);
|
|
164
|
+
if (ret[2]) {
|
|
165
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
166
|
+
}
|
|
167
|
+
return ret[0] >>> 0;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* How a cell is painted: number format, font, fill, borders and text
|
|
171
|
+
* placement, as the file states them.
|
|
172
|
+
*
|
|
173
|
+
* A cell the file says nothing about answers with Excel's defaults, which
|
|
174
|
+
* is what Excel itself shows for it.
|
|
175
|
+
* @param {number} sheet
|
|
176
|
+
* @param {string} address
|
|
177
|
+
* @returns {CellStyle}
|
|
178
|
+
*/
|
|
179
|
+
cellStyle(sheet, address) {
|
|
180
|
+
const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
181
|
+
const len0 = WASM_VECTOR_LEN;
|
|
182
|
+
const ret = wasm.book_cellStyle(this.__wbg_ptr, sheet, ptr0, len0);
|
|
183
|
+
if (ret[2]) {
|
|
184
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
185
|
+
}
|
|
186
|
+
return takeFromExternrefTable0(ret[0]);
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* The same by 1-based row and column.
|
|
190
|
+
* @param {number} sheet
|
|
191
|
+
* @param {number} row
|
|
192
|
+
* @param {number} column
|
|
193
|
+
* @returns {CellStyle}
|
|
194
|
+
*/
|
|
195
|
+
cellStyleAt(sheet, row, column) {
|
|
196
|
+
const ret = wasm.book_cellStyleAt(this.__wbg_ptr, sheet, row, column);
|
|
197
|
+
if (ret[2]) {
|
|
198
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
199
|
+
}
|
|
200
|
+
return takeFromExternrefTable0(ret[0]);
|
|
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
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Empties a cell, style and all.
|
|
217
|
+
* @param {number} sheet
|
|
218
|
+
* @param {string} address
|
|
219
|
+
*/
|
|
220
|
+
clear(sheet, address) {
|
|
221
|
+
const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
222
|
+
const len0 = WASM_VECTOR_LEN;
|
|
223
|
+
const ret = wasm.book_clear(this.__wbg_ptr, sheet, ptr0, len0);
|
|
224
|
+
if (ret[1]) {
|
|
225
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* The same by 1-based row and column.
|
|
230
|
+
* @param {number} sheet
|
|
231
|
+
* @param {number} row
|
|
232
|
+
* @param {number} column
|
|
233
|
+
*/
|
|
234
|
+
clearAt(sheet, row, column) {
|
|
235
|
+
const ret = wasm.book_clearAt(this.__wbg_ptr, sheet, row, column);
|
|
236
|
+
if (ret[1]) {
|
|
237
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* The same for a column, named by its letters: `columnLevel(0, "C")`.
|
|
242
|
+
* @param {number} sheet
|
|
243
|
+
* @param {string} column
|
|
244
|
+
* @returns {number}
|
|
245
|
+
*/
|
|
246
|
+
columnLevel(sheet, column) {
|
|
247
|
+
const ptr0 = passStringToWasm0(column, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
248
|
+
const len0 = WASM_VECTOR_LEN;
|
|
249
|
+
const ret = wasm.book_columnLevel(this.__wbg_ptr, sheet, ptr0, len0);
|
|
250
|
+
if (ret[2]) {
|
|
251
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
252
|
+
}
|
|
253
|
+
return ret[0];
|
|
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
|
+
}
|
|
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
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Evaluates a formula (with or without the leading `=`) as if it sat in
|
|
351
|
+
* `address` of `sheet`, and returns its result.
|
|
352
|
+
* @param {number} sheet
|
|
353
|
+
* @param {string} address
|
|
354
|
+
* @param {string} formula
|
|
355
|
+
* @returns {CellValue}
|
|
356
|
+
*/
|
|
357
|
+
evaluate(sheet, address, formula) {
|
|
358
|
+
const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
359
|
+
const len0 = WASM_VECTOR_LEN;
|
|
360
|
+
const ptr1 = passStringToWasm0(formula, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
361
|
+
const len1 = WASM_VECTOR_LEN;
|
|
362
|
+
const ret = wasm.book_evaluate(this.__wbg_ptr, sheet, ptr0, len0, ptr1, len1);
|
|
363
|
+
if (ret[2]) {
|
|
364
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
365
|
+
}
|
|
366
|
+
return takeFromExternrefTable0(ret[0]);
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* The other workbooks this one reads, in the order `[1]Sheet1!A1` counts
|
|
370
|
+
* them. A path is `undefined` where the file does not name one.
|
|
371
|
+
* @returns {any[]}
|
|
372
|
+
*/
|
|
373
|
+
externalBooks() {
|
|
374
|
+
const ret = wasm.book_externalBooks(this.__wbg_ptr);
|
|
375
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]);
|
|
376
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
377
|
+
return v1;
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* Copies the first row of a range into the rows below it, as Ctrl+D.
|
|
381
|
+
* @param {number} sheet
|
|
382
|
+
* @param {string} range
|
|
383
|
+
*/
|
|
384
|
+
fillDown(sheet, range) {
|
|
385
|
+
const ptr0 = passStringToWasm0(range, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
386
|
+
const len0 = WASM_VECTOR_LEN;
|
|
387
|
+
const ret = wasm.book_fillDown(this.__wbg_ptr, sheet, ptr0, len0);
|
|
388
|
+
if (ret[1]) {
|
|
389
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* Copies the first column of a range into the columns to its right, as
|
|
394
|
+
* Ctrl+R.
|
|
395
|
+
* @param {number} sheet
|
|
396
|
+
* @param {string} range
|
|
397
|
+
*/
|
|
398
|
+
fillRight(sheet, range) {
|
|
399
|
+
const ptr0 = passStringToWasm0(range, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
400
|
+
const len0 = WASM_VECTOR_LEN;
|
|
401
|
+
const ret = wasm.book_fillRight(this.__wbg_ptr, sheet, ptr0, len0);
|
|
402
|
+
if (ret[1]) {
|
|
403
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* Continues what the first cells of a range start, as dragging the fill
|
|
408
|
+
* handle does: `1, 2` goes on `3, 4`, `Кв1` to `Кв2`, `Jan` to `Feb`, a
|
|
409
|
+
* date by a day; anything else repeats. `"down"` fills each column,
|
|
410
|
+
* `"right"` each row; `"up"` and `"left"` run the series back from the
|
|
411
|
+
* last cells.
|
|
412
|
+
* @param {number} sheet
|
|
413
|
+
* @param {string} range
|
|
414
|
+
* @param {"down" | "right" | "up" | "left"} direction
|
|
415
|
+
*/
|
|
416
|
+
fillSeries(sheet, range, direction) {
|
|
417
|
+
const ptr0 = passStringToWasm0(range, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
418
|
+
const len0 = WASM_VECTOR_LEN;
|
|
419
|
+
const ptr1 = passStringToWasm0(direction, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
420
|
+
const len1 = WASM_VECTOR_LEN;
|
|
421
|
+
const ret = wasm.book_fillSeries(this.__wbg_ptr, sheet, ptr0, len0, ptr1, len1);
|
|
422
|
+
if (ret[1]) {
|
|
423
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
424
|
+
}
|
|
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
|
+
}
|
|
455
|
+
/**
|
|
456
|
+
* Freezes the first `rows` rows and `columns` columns, so they stay put
|
|
457
|
+
* while the rest scrolls. `freezePanes(0, 1, 0)` pins the header row;
|
|
458
|
+
* `freezePanes(0, 0, 0)` unfreezes.
|
|
459
|
+
* @param {number} sheet
|
|
460
|
+
* @param {number} rows
|
|
461
|
+
* @param {number} columns
|
|
462
|
+
*/
|
|
463
|
+
freezePanes(sheet, rows, columns) {
|
|
464
|
+
const ret = wasm.book_freezePanes(this.__wbg_ptr, sheet, rows, columns);
|
|
465
|
+
if (ret[1]) {
|
|
466
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
/**
|
|
470
|
+
* The value at `address` on sheet `sheet`, as a JS number, string, boolean
|
|
471
|
+
* or `null`. A formula cell gives its cached result, not its text.
|
|
472
|
+
* @param {number} sheet
|
|
473
|
+
* @param {string} address
|
|
474
|
+
* @returns {CellValue}
|
|
475
|
+
*/
|
|
476
|
+
get(sheet, address) {
|
|
477
|
+
const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
478
|
+
const len0 = WASM_VECTOR_LEN;
|
|
479
|
+
const ret = wasm.book_get(this.__wbg_ptr, sheet, ptr0, len0);
|
|
480
|
+
if (ret[2]) {
|
|
481
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
482
|
+
}
|
|
483
|
+
return takeFromExternrefTable0(ret[0]);
|
|
484
|
+
}
|
|
485
|
+
/**
|
|
486
|
+
* The same by 1-based row and column.
|
|
487
|
+
* @param {number} sheet
|
|
488
|
+
* @param {number} row
|
|
489
|
+
* @param {number} column
|
|
490
|
+
* @returns {CellValue}
|
|
491
|
+
*/
|
|
492
|
+
getAt(sheet, row, column) {
|
|
493
|
+
const ret = wasm.book_getAt(this.__wbg_ptr, sheet, row, column);
|
|
494
|
+
if (ret[2]) {
|
|
495
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
496
|
+
}
|
|
497
|
+
return takeFromExternrefTable0(ret[0]);
|
|
498
|
+
}
|
|
499
|
+
/**
|
|
500
|
+
* The cell as a spreadsheet would display it: the value run through its
|
|
501
|
+
* number format, so `0.256` under `0.0%` reads `25.6%`.
|
|
502
|
+
* @param {number} sheet
|
|
503
|
+
* @param {string} address
|
|
504
|
+
* @returns {string}
|
|
505
|
+
*/
|
|
506
|
+
getFormatted(sheet, address) {
|
|
507
|
+
let deferred3_0;
|
|
508
|
+
let deferred3_1;
|
|
509
|
+
try {
|
|
510
|
+
const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
511
|
+
const len0 = WASM_VECTOR_LEN;
|
|
512
|
+
const ret = wasm.book_getFormatted(this.__wbg_ptr, sheet, ptr0, len0);
|
|
513
|
+
var ptr2 = ret[0];
|
|
514
|
+
var len2 = ret[1];
|
|
515
|
+
if (ret[3]) {
|
|
516
|
+
ptr2 = 0; len2 = 0;
|
|
517
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
518
|
+
}
|
|
519
|
+
deferred3_0 = ptr2;
|
|
520
|
+
deferred3_1 = len2;
|
|
521
|
+
return getStringFromWasm0(ptr2, len2);
|
|
522
|
+
} finally {
|
|
523
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
/**
|
|
527
|
+
* The same by 1-based row and column.
|
|
528
|
+
* @param {number} sheet
|
|
529
|
+
* @param {number} row
|
|
530
|
+
* @param {number} column
|
|
531
|
+
* @returns {string}
|
|
532
|
+
*/
|
|
533
|
+
getFormattedAt(sheet, row, column) {
|
|
534
|
+
let deferred2_0;
|
|
535
|
+
let deferred2_1;
|
|
536
|
+
try {
|
|
537
|
+
const ret = wasm.book_getFormattedAt(this.__wbg_ptr, sheet, row, column);
|
|
538
|
+
var ptr1 = ret[0];
|
|
539
|
+
var len1 = ret[1];
|
|
540
|
+
if (ret[3]) {
|
|
541
|
+
ptr1 = 0; len1 = 0;
|
|
542
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
543
|
+
}
|
|
544
|
+
deferred2_0 = ptr1;
|
|
545
|
+
deferred2_1 = len1;
|
|
546
|
+
return getStringFromWasm0(ptr1, len1);
|
|
547
|
+
} finally {
|
|
548
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
/**
|
|
552
|
+
* The formula text of a cell without its leading `=`, or `undefined` when
|
|
553
|
+
* the cell holds a plain value.
|
|
554
|
+
* @param {number} sheet
|
|
555
|
+
* @param {string} address
|
|
556
|
+
* @returns {string | undefined}
|
|
557
|
+
*/
|
|
558
|
+
getFormula(sheet, address) {
|
|
559
|
+
const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
560
|
+
const len0 = WASM_VECTOR_LEN;
|
|
561
|
+
const ret = wasm.book_getFormula(this.__wbg_ptr, sheet, ptr0, len0);
|
|
562
|
+
let v2;
|
|
563
|
+
if (ret[0] !== 0) {
|
|
564
|
+
v2 = getStringFromWasm0(ret[0], ret[1]);
|
|
565
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
566
|
+
}
|
|
567
|
+
return v2;
|
|
568
|
+
}
|
|
569
|
+
/**
|
|
570
|
+
* The same by 1-based row and column.
|
|
571
|
+
* @param {number} sheet
|
|
572
|
+
* @param {number} row
|
|
573
|
+
* @param {number} column
|
|
574
|
+
* @returns {string | undefined}
|
|
575
|
+
*/
|
|
576
|
+
getFormulaAt(sheet, row, column) {
|
|
577
|
+
const ret = wasm.book_getFormulaAt(this.__wbg_ptr, sheet, row, column);
|
|
578
|
+
let v1;
|
|
579
|
+
if (ret[0] !== 0) {
|
|
580
|
+
v1 = getStringFromWasm0(ret[0], ret[1]);
|
|
581
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
582
|
+
}
|
|
583
|
+
return v1;
|
|
584
|
+
}
|
|
585
|
+
/**
|
|
586
|
+
* A rectangle of cells, row by row. One call across the boundary instead
|
|
587
|
+
* of one per cell, which is what makes reading a sheet worth doing.
|
|
588
|
+
* @param {number} sheet
|
|
589
|
+
* @param {string} range
|
|
590
|
+
* @returns {CellGrid}
|
|
591
|
+
*/
|
|
592
|
+
getRange(sheet, range) {
|
|
593
|
+
const ptr0 = passStringToWasm0(range, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
594
|
+
const len0 = WASM_VECTOR_LEN;
|
|
595
|
+
const ret = wasm.book_getRange(this.__wbg_ptr, sheet, ptr0, len0);
|
|
596
|
+
if (ret[2]) {
|
|
597
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
598
|
+
}
|
|
599
|
+
return takeFromExternrefTable0(ret[0]);
|
|
600
|
+
}
|
|
601
|
+
/**
|
|
602
|
+
* The same by numbers: the top-left cell, then how many rows and columns
|
|
603
|
+
* to take. `getRangeAt(0, 1, 1, 3, 2)` is `A1:B3`.
|
|
604
|
+
* @param {number} sheet
|
|
605
|
+
* @param {number} row
|
|
606
|
+
* @param {number} column
|
|
607
|
+
* @param {number} rows
|
|
608
|
+
* @param {number} columns
|
|
609
|
+
* @returns {CellGrid}
|
|
610
|
+
*/
|
|
611
|
+
getRangeAt(sheet, row, column, rows, columns) {
|
|
612
|
+
const ret = wasm.book_getRangeAt(this.__wbg_ptr, sheet, row, column, rows, columns);
|
|
613
|
+
if (ret[2]) {
|
|
614
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
615
|
+
}
|
|
616
|
+
return takeFromExternrefTable0(ret[0]);
|
|
617
|
+
}
|
|
618
|
+
/**
|
|
619
|
+
* The styles of a rectangle in one call: each distinct style once, and a
|
|
620
|
+
* grid of indexes into them. `cellStyle` per cell costs a crossing and a
|
|
621
|
+
* whole style object per cell; a formatted table of ten thousand cells
|
|
622
|
+
* usually has a dozen styles.
|
|
623
|
+
* @param {number} sheet
|
|
624
|
+
* @param {string} range
|
|
625
|
+
* @returns {RangeStyles}
|
|
626
|
+
*/
|
|
627
|
+
getRangeStyles(sheet, range) {
|
|
628
|
+
const ptr0 = passStringToWasm0(range, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
629
|
+
const len0 = WASM_VECTOR_LEN;
|
|
630
|
+
const ret = wasm.book_getRangeStyles(this.__wbg_ptr, sheet, ptr0, len0);
|
|
631
|
+
if (ret[2]) {
|
|
632
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
633
|
+
}
|
|
634
|
+
return takeFromExternrefTable0(ret[0]);
|
|
635
|
+
}
|
|
636
|
+
/**
|
|
637
|
+
* The same by numbers, as `getRangeAt` takes them.
|
|
638
|
+
* @param {number} sheet
|
|
639
|
+
* @param {number} row
|
|
640
|
+
* @param {number} column
|
|
641
|
+
* @param {number} rows
|
|
642
|
+
* @param {number} columns
|
|
643
|
+
* @returns {RangeStyles}
|
|
644
|
+
*/
|
|
645
|
+
getRangeStylesAt(sheet, row, column, rows, columns) {
|
|
646
|
+
const ret = wasm.book_getRangeStylesAt(this.__wbg_ptr, sheet, row, column, rows, columns);
|
|
647
|
+
if (ret[2]) {
|
|
648
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
649
|
+
}
|
|
650
|
+
return takeFromExternrefTable0(ret[0]);
|
|
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
|
+
}
|
|
683
|
+
/**
|
|
684
|
+
* A whole row in one crossing of the boundary: values, displayed text,
|
|
685
|
+
* bold and indent, plus whether the row is hidden.
|
|
686
|
+
*
|
|
687
|
+
* The arrays run from column 1 to the last column this row has a cell in,
|
|
688
|
+
* so a row of ten cells costs one call rather than forty.
|
|
689
|
+
*
|
|
690
|
+
* `formatted` is what the number format makes of each value, and building
|
|
691
|
+
* it allocates a string per cell - which a caller reading values does not
|
|
692
|
+
* want to pay half a sheet over. Pass `false` and the field comes back
|
|
693
|
+
* `null`; `getFormattedAt` still answers for the cells that need it.
|
|
694
|
+
* @param {number} sheet
|
|
695
|
+
* @param {number} row
|
|
696
|
+
* @param {boolean | null} [formatted]
|
|
697
|
+
* @returns {SheetRow}
|
|
698
|
+
*/
|
|
699
|
+
getRowAt(sheet, row, formatted) {
|
|
700
|
+
const ret = wasm.book_getRowAt(this.__wbg_ptr, sheet, row, isLikeNone(formatted) ? 0xFFFFFF : formatted ? 1 : 0);
|
|
701
|
+
if (ret[2]) {
|
|
702
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
703
|
+
}
|
|
704
|
+
return takeFromExternrefTable0(ret[0]);
|
|
705
|
+
}
|
|
706
|
+
/**
|
|
707
|
+
* The hyperlinks of a sheet. `external` tells a URL from a jump inside
|
|
708
|
+
* the workbook.
|
|
709
|
+
* @param {number} sheet
|
|
710
|
+
* @returns {SheetHyperlink[]}
|
|
711
|
+
*/
|
|
712
|
+
hyperlinks(sheet) {
|
|
713
|
+
const ret = wasm.book_hyperlinks(this.__wbg_ptr, sheet);
|
|
714
|
+
if (ret[2]) {
|
|
715
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
716
|
+
}
|
|
717
|
+
return takeFromExternrefTable0(ret[0]);
|
|
718
|
+
}
|
|
719
|
+
/**
|
|
720
|
+
* The bytes of one picture, by its position in `images`.
|
|
721
|
+
* @param {number} sheet
|
|
722
|
+
* @param {number} index
|
|
723
|
+
* @returns {Uint8Array}
|
|
724
|
+
*/
|
|
725
|
+
imageData(sheet, index) {
|
|
726
|
+
const ret = wasm.book_imageData(this.__wbg_ptr, sheet, index);
|
|
727
|
+
if (ret[3]) {
|
|
728
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
729
|
+
}
|
|
730
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
731
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
732
|
+
return v1;
|
|
733
|
+
}
|
|
734
|
+
/**
|
|
735
|
+
* The pictures on a sheet, without their bytes: `imageData` fetches those
|
|
736
|
+
* for the one that is wanted.
|
|
737
|
+
* @param {number} sheet
|
|
738
|
+
* @returns {SheetImage[]}
|
|
739
|
+
*/
|
|
740
|
+
images(sheet) {
|
|
741
|
+
const ret = wasm.book_images(this.__wbg_ptr, sheet);
|
|
742
|
+
if (ret[2]) {
|
|
743
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
744
|
+
}
|
|
745
|
+
return takeFromExternrefTable0(ret[0]);
|
|
746
|
+
}
|
|
747
|
+
/**
|
|
748
|
+
* Inserts blank cells over a range, pushing what was there `"down"` or
|
|
749
|
+
* `"right"` - Excel's "Insert Cells", which moves part of a row rather
|
|
750
|
+
* than the whole of it. `copyOrigin` works as in `insertRows`.
|
|
751
|
+
* @param {number} sheet
|
|
752
|
+
* @param {string} range
|
|
753
|
+
* @param {"down" | "right"} shift
|
|
754
|
+
* @param {"before" | "after" | "none"} [copyOrigin]
|
|
755
|
+
*/
|
|
756
|
+
insertCells(sheet, range, shift, copyOrigin) {
|
|
757
|
+
const ptr0 = passStringToWasm0(range, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
758
|
+
const len0 = WASM_VECTOR_LEN;
|
|
759
|
+
const ptr1 = passStringToWasm0(shift, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
760
|
+
const len1 = WASM_VECTOR_LEN;
|
|
761
|
+
var ptr2 = isLikeNone(copyOrigin) ? 0 : passStringToWasm0(copyOrigin, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
762
|
+
var len2 = WASM_VECTOR_LEN;
|
|
763
|
+
const ret = wasm.book_insertCells(this.__wbg_ptr, sheet, ptr0, len0, ptr1, len1, ptr2, len2);
|
|
764
|
+
if (ret[1]) {
|
|
765
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
/**
|
|
769
|
+
* Inserts `count` columns to the left of column `at`, 1-based.
|
|
770
|
+
* `copyOrigin` works as in `insertRows`, with left and right.
|
|
771
|
+
* @param {number} sheet
|
|
772
|
+
* @param {number} at
|
|
773
|
+
* @param {number} count
|
|
774
|
+
* @param {"before" | "after" | "none"} [copyOrigin]
|
|
775
|
+
*/
|
|
776
|
+
insertColumns(sheet, at, count, copyOrigin) {
|
|
777
|
+
var ptr0 = isLikeNone(copyOrigin) ? 0 : passStringToWasm0(copyOrigin, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
778
|
+
var len0 = WASM_VECTOR_LEN;
|
|
779
|
+
const ret = wasm.book_insertColumns(this.__wbg_ptr, sheet, at, count, ptr0, len0);
|
|
780
|
+
if (ret[1]) {
|
|
781
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
782
|
+
}
|
|
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
|
+
}
|
|
798
|
+
/**
|
|
799
|
+
* Inserts `count` rows above row `at`, moving everything below down.
|
|
800
|
+
* `copyOrigin` - `"before"` (the row above), `"after"` (the row below)
|
|
801
|
+
* or `"none"` - says whose formatting the new rows take. Left out, it is
|
|
802
|
+
* `"before"`, as in Excel.
|
|
803
|
+
*
|
|
804
|
+
* Formulas across the whole workbook follow the cells they read, and so
|
|
805
|
+
* do merges, links, validations, tables and drawings. `at` is the number
|
|
806
|
+
* a user sees.
|
|
807
|
+
* @param {number} sheet
|
|
808
|
+
* @param {number} at
|
|
809
|
+
* @param {number} count
|
|
810
|
+
* @param {"before" | "after" | "none"} [copyOrigin]
|
|
811
|
+
*/
|
|
812
|
+
insertRows(sheet, at, count, copyOrigin) {
|
|
813
|
+
var ptr0 = isLikeNone(copyOrigin) ? 0 : passStringToWasm0(copyOrigin, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
814
|
+
var len0 = WASM_VECTOR_LEN;
|
|
815
|
+
const ret = wasm.book_insertRows(this.__wbg_ptr, sheet, at, count, ptr0, len0);
|
|
816
|
+
if (ret[1]) {
|
|
817
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
818
|
+
}
|
|
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
|
+
}
|
|
842
|
+
/**
|
|
843
|
+
* Merges a block of cells: `merge(0, "A1:C1")`.
|
|
844
|
+
* @param {number} sheet
|
|
845
|
+
* @param {string} range
|
|
846
|
+
*/
|
|
847
|
+
merge(sheet, range) {
|
|
848
|
+
const ptr0 = passStringToWasm0(range, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
849
|
+
const len0 = WASM_VECTOR_LEN;
|
|
850
|
+
const ret = wasm.book_merge(this.__wbg_ptr, sheet, ptr0, len0);
|
|
851
|
+
if (ret[1]) {
|
|
852
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
/**
|
|
856
|
+
* The merged areas of a sheet, as `"A1:C1"` strings in the order the file
|
|
857
|
+
* lists them.
|
|
858
|
+
* @param {number} sheet
|
|
859
|
+
* @returns {string[]}
|
|
860
|
+
*/
|
|
861
|
+
mergedRanges(sheet) {
|
|
862
|
+
const ret = wasm.book_mergedRanges(this.__wbg_ptr, sheet);
|
|
863
|
+
if (ret[3]) {
|
|
864
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
865
|
+
}
|
|
866
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]);
|
|
867
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
868
|
+
return v1;
|
|
869
|
+
}
|
|
870
|
+
/**
|
|
871
|
+
* The merged areas of a sheet as numbers: four per area, `[r1, c1, r2,
|
|
872
|
+
* c2]`, rows and columns 1-based.
|
|
873
|
+
*
|
|
874
|
+
* One typed array instead of a JS string per area, which is what a sheet
|
|
875
|
+
* carrying three hundred thousand of them needs.
|
|
876
|
+
* @param {number} sheet
|
|
877
|
+
* @returns {Uint32Array}
|
|
878
|
+
*/
|
|
879
|
+
mergedRangesAt(sheet) {
|
|
880
|
+
const ret = wasm.book_mergedRangesAt(this.__wbg_ptr, sheet);
|
|
881
|
+
if (ret[2]) {
|
|
882
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
883
|
+
}
|
|
884
|
+
return takeFromExternrefTable0(ret[0]);
|
|
885
|
+
}
|
|
886
|
+
/**
|
|
887
|
+
* Moves a rectangle of cells, leaving the source empty.
|
|
888
|
+
*
|
|
889
|
+
* A moved formula keeps reading the cells it read; the formulas elsewhere
|
|
890
|
+
* that read *these* cells follow them instead, as they do when Excel cuts
|
|
891
|
+
* and pastes.
|
|
892
|
+
* @param {number} sheet
|
|
893
|
+
* @param {string} range
|
|
894
|
+
* @param {string} to
|
|
895
|
+
* @param {number | null} [to_sheet]
|
|
896
|
+
*/
|
|
897
|
+
moveRange(sheet, range, to, to_sheet) {
|
|
898
|
+
const ptr0 = passStringToWasm0(range, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
899
|
+
const len0 = WASM_VECTOR_LEN;
|
|
900
|
+
const ptr1 = passStringToWasm0(to, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
901
|
+
const len1 = WASM_VECTOR_LEN;
|
|
902
|
+
const ret = wasm.book_moveRange(this.__wbg_ptr, sheet, ptr0, len0, ptr1, len1, isLikeNone(to_sheet) ? Number.MAX_SAFE_INTEGER : (to_sheet) >>> 0);
|
|
903
|
+
if (ret[1]) {
|
|
904
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
/**
|
|
908
|
+
* Moves a sheet along the tab bar. Formulas are untouched - a sheet is
|
|
909
|
+
* named, not numbered - but every index moves, this one included, so read
|
|
910
|
+
* `sheetIndex` again afterwards.
|
|
911
|
+
* @param {number} from
|
|
912
|
+
* @param {number} to
|
|
913
|
+
*/
|
|
914
|
+
moveSheet(from, to) {
|
|
915
|
+
const ret = wasm.book_moveSheet(this.__wbg_ptr, from, to);
|
|
916
|
+
if (ret[1]) {
|
|
917
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
/**
|
|
921
|
+
* A new workbook with one empty sheet.
|
|
922
|
+
*/
|
|
923
|
+
constructor() {
|
|
924
|
+
const ret = wasm.book_new();
|
|
925
|
+
this.__wbg_ptr = ret;
|
|
926
|
+
BookFinalization.register(this, this.__wbg_ptr, this);
|
|
927
|
+
return this;
|
|
928
|
+
}
|
|
929
|
+
/**
|
|
930
|
+
* The pivot reports laid out on a sheet. The numbers they show are cells
|
|
931
|
+
* like any others; this says where a report sits and how wide its axes
|
|
932
|
+
* are.
|
|
933
|
+
* @param {number} sheet
|
|
934
|
+
* @returns {SheetPivotTable[]}
|
|
935
|
+
*/
|
|
936
|
+
pivotTables(sheet) {
|
|
937
|
+
const ret = wasm.book_pivotTables(this.__wbg_ptr, sheet);
|
|
938
|
+
if (ret[2]) {
|
|
939
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
940
|
+
}
|
|
941
|
+
return takeFromExternrefTable0(ret[0]);
|
|
942
|
+
}
|
|
943
|
+
/**
|
|
944
|
+
* Locks a sheet against editing, optionally behind a password.
|
|
945
|
+
*
|
|
946
|
+
* This is the lock Excel offers under "Protect Sheet": it stops a user
|
|
947
|
+
* editing, it does not encrypt anything. The password is stored as Excel
|
|
948
|
+
* stores it - SHA-512 over a random salt, 100,000 spins - and
|
|
949
|
+
* `verifySheetPassword` checks it back.
|
|
950
|
+
* @param {number} sheet
|
|
951
|
+
* @param {string | null} [password]
|
|
952
|
+
*/
|
|
953
|
+
protectSheet(sheet, password) {
|
|
954
|
+
var ptr0 = isLikeNone(password) ? 0 : passStringToWasm0(password, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
955
|
+
var len0 = WASM_VECTOR_LEN;
|
|
956
|
+
const ret = wasm.book_protectSheet(this.__wbg_ptr, sheet, ptr0, len0);
|
|
957
|
+
if (ret[1]) {
|
|
958
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
959
|
+
}
|
|
960
|
+
}
|
|
961
|
+
/**
|
|
962
|
+
* Locks the structure of the workbook: which sheets there are, and their
|
|
963
|
+
* order. `windows` locks the window layout as well.
|
|
964
|
+
* @param {string | null} [password]
|
|
965
|
+
* @param {boolean | null} [windows]
|
|
966
|
+
*/
|
|
967
|
+
protectWorkbook(password, windows) {
|
|
968
|
+
var ptr0 = isLikeNone(password) ? 0 : passStringToWasm0(password, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
969
|
+
var len0 = WASM_VECTOR_LEN;
|
|
970
|
+
const ret = wasm.book_protectWorkbook(this.__wbg_ptr, ptr0, len0, isLikeNone(windows) ? 0xFFFFFF : windows ? 1 : 0);
|
|
971
|
+
if (ret[1]) {
|
|
972
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
/**
|
|
976
|
+
* Reads a workbook of any format this crate supports, working the format
|
|
977
|
+
* out from the bytes themselves.
|
|
978
|
+
*
|
|
979
|
+
* `name` is the file name they came from, if the caller has one: it
|
|
980
|
+
* settles what the bytes cannot say (a `.csv` against a `.html`) and names
|
|
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.
|
|
984
|
+
* @param {Uint8Array} bytes
|
|
985
|
+
* @param {string | null} [name]
|
|
986
|
+
* @param {number | null} [max_expanded]
|
|
987
|
+
* @param {Function | null} [on_progress]
|
|
988
|
+
* @param {string | null} [password]
|
|
989
|
+
* @returns {Book}
|
|
990
|
+
*/
|
|
991
|
+
static read(bytes, name, max_expanded, on_progress, password) {
|
|
992
|
+
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
|
|
993
|
+
const len0 = WASM_VECTOR_LEN;
|
|
994
|
+
var ptr1 = isLikeNone(name) ? 0 : passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
995
|
+
var len1 = WASM_VECTOR_LEN;
|
|
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);
|
|
999
|
+
if (ret[2]) {
|
|
1000
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1001
|
+
}
|
|
1002
|
+
return Book.__wrap(ret[0]);
|
|
1003
|
+
}
|
|
1004
|
+
/**
|
|
1005
|
+
* Reads CSV with the guesses overridden: the delimiter, whether a row
|
|
1006
|
+
* that produced no cell is skipped, whether an empty field becomes an
|
|
1007
|
+
* empty string rather than no cell at all.
|
|
1008
|
+
*
|
|
1009
|
+
* `Book.read` guesses all of this from the bytes, which is right for a
|
|
1010
|
+
* file of unknown origin; this is for one whose shape you already know.
|
|
1011
|
+
* @param {Uint8Array} bytes
|
|
1012
|
+
* @param {CsvOptions} options
|
|
1013
|
+
* @returns {Book}
|
|
1014
|
+
*/
|
|
1015
|
+
static readCsv(bytes, options) {
|
|
1016
|
+
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
|
|
1017
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1018
|
+
const ret = wasm.book_readCsv(ptr0, len0, options);
|
|
1019
|
+
if (ret[2]) {
|
|
1020
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1021
|
+
}
|
|
1022
|
+
return Book.__wrap(ret[0]);
|
|
1023
|
+
}
|
|
1024
|
+
/**
|
|
1025
|
+
* Recomputes every formula and stores the results beside them, so that
|
|
1026
|
+
* `get` and `toCsv` show this engine's answers rather than the cache the
|
|
1027
|
+
* file was saved with. Returns how many formulas were computed.
|
|
1028
|
+
*
|
|
1029
|
+
* With no argument the whole workbook is recomputed; with a sheet index,
|
|
1030
|
+
* only that sheet's formulas are - though they still read the whole
|
|
1031
|
+
* workbook, as a cross-sheet reference must.
|
|
1032
|
+
* @param {number | null} [sheet]
|
|
1033
|
+
* @param {Function | null} [on_progress]
|
|
1034
|
+
* @returns {number}
|
|
1035
|
+
*/
|
|
1036
|
+
recalculate(sheet, on_progress) {
|
|
1037
|
+
const ret = wasm.book_recalculate(this.__wbg_ptr, isLikeNone(sheet) ? Number.MAX_SAFE_INTEGER : (sheet) >>> 0, isLikeNone(on_progress) ? 0 : addToExternrefTable0(on_progress));
|
|
1038
|
+
return ret >>> 0;
|
|
1039
|
+
}
|
|
1040
|
+
/**
|
|
1041
|
+
* Recomputes the formula in one cell and stores its result. Returns
|
|
1042
|
+
* whether there was a formula there.
|
|
1043
|
+
*
|
|
1044
|
+
* Not the same as `recalculateFrom`, which recomputes the formulas
|
|
1045
|
+
* *reading* this cell and leaves the cell itself alone.
|
|
1046
|
+
* @param {number} sheet
|
|
1047
|
+
* @param {string} address
|
|
1048
|
+
* @returns {boolean}
|
|
1049
|
+
*/
|
|
1050
|
+
recalculateCell(sheet, address) {
|
|
1051
|
+
const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1052
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1053
|
+
const ret = wasm.book_recalculateCell(this.__wbg_ptr, sheet, ptr0, len0);
|
|
1054
|
+
if (ret[2]) {
|
|
1055
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1056
|
+
}
|
|
1057
|
+
return ret[0] !== 0;
|
|
1058
|
+
}
|
|
1059
|
+
/**
|
|
1060
|
+
* The same by 1-based row and column.
|
|
1061
|
+
* @param {number} sheet
|
|
1062
|
+
* @param {number} row
|
|
1063
|
+
* @param {number} column
|
|
1064
|
+
* @returns {boolean}
|
|
1065
|
+
*/
|
|
1066
|
+
recalculateCellAt(sheet, row, column) {
|
|
1067
|
+
const ret = wasm.book_recalculateCellAt(this.__wbg_ptr, sheet, row, column);
|
|
1068
|
+
if (ret[2]) {
|
|
1069
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1070
|
+
}
|
|
1071
|
+
return ret[0] !== 0;
|
|
1072
|
+
}
|
|
1073
|
+
/**
|
|
1074
|
+
* Recomputes only what depends on one cell that changed - the formulas
|
|
1075
|
+
* reading it, the formulas reading those, and so on. Returns how many were
|
|
1076
|
+
* computed. This is the pass to run after `set`.
|
|
1077
|
+
*
|
|
1078
|
+
* For a batch of edits use `recalculateFromMany`, which answers them all
|
|
1079
|
+
* in one pass.
|
|
1080
|
+
* @param {number} sheet
|
|
1081
|
+
* @param {string} address
|
|
1082
|
+
* @returns {number}
|
|
1083
|
+
*/
|
|
1084
|
+
recalculateFrom(sheet, address) {
|
|
1085
|
+
const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1086
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1087
|
+
const ret = wasm.book_recalculateFrom(this.__wbg_ptr, sheet, ptr0, len0);
|
|
1088
|
+
if (ret[2]) {
|
|
1089
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1090
|
+
}
|
|
1091
|
+
return ret[0] >>> 0;
|
|
1092
|
+
}
|
|
1093
|
+
/**
|
|
1094
|
+
* The same by 1-based row and column.
|
|
1095
|
+
* @param {number} sheet
|
|
1096
|
+
* @param {number} row
|
|
1097
|
+
* @param {number} column
|
|
1098
|
+
* @returns {number}
|
|
1099
|
+
*/
|
|
1100
|
+
recalculateFromAt(sheet, row, column) {
|
|
1101
|
+
const ret = wasm.book_recalculateFromAt(this.__wbg_ptr, sheet, row, column);
|
|
1102
|
+
if (ret[2]) {
|
|
1103
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1104
|
+
}
|
|
1105
|
+
return ret[0] >>> 0;
|
|
1106
|
+
}
|
|
1107
|
+
/**
|
|
1108
|
+
* The same for a batch of cells, all on sheet `sheet`, answered in one
|
|
1109
|
+
* pass: editing a hundred cells costs one walk of the workbook, not a
|
|
1110
|
+
* hundred.
|
|
1111
|
+
*
|
|
1112
|
+
* The index of what reads what is built on the first call and kept, so a
|
|
1113
|
+
* run of edits parses the formulas only once. `set` keeps it in step.
|
|
1114
|
+
* @param {number} sheet
|
|
1115
|
+
* @param {string[]} addresses
|
|
1116
|
+
* @returns {number}
|
|
1117
|
+
*/
|
|
1118
|
+
recalculateFromMany(sheet, addresses) {
|
|
1119
|
+
const ptr0 = passArrayJsValueToWasm0(addresses, wasm.__wbindgen_malloc);
|
|
1120
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1121
|
+
const ret = wasm.book_recalculateFromMany(this.__wbg_ptr, sheet, ptr0, len0);
|
|
1122
|
+
if (ret[2]) {
|
|
1123
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1124
|
+
}
|
|
1125
|
+
return ret[0] >>> 0;
|
|
1126
|
+
}
|
|
1127
|
+
/**
|
|
1128
|
+
* Registers a function of your own, callable from any formula in the
|
|
1129
|
+
* workbook by that name.
|
|
1130
|
+
*
|
|
1131
|
+
* The function is handed the arguments already computed - a range arrives
|
|
1132
|
+
* as an array of arrays - and whatever it returns becomes the value. A
|
|
1133
|
+
* name a built-in claims stays the built-in's: a workbook where `SUM`
|
|
1134
|
+
* means something else is a workbook nobody else can read.
|
|
1135
|
+
*
|
|
1136
|
+
* ```js
|
|
1137
|
+
* book.registerFunction("MYRATE", (base) => base * 1.5 + 0.5);
|
|
1138
|
+
* book.evaluate(0, "A1", "=MYRATE(10)"); // 15.5
|
|
1139
|
+
* ```
|
|
1140
|
+
* @param {string} name
|
|
1141
|
+
* @param {Function} _function
|
|
1142
|
+
*/
|
|
1143
|
+
registerFunction(name, _function) {
|
|
1144
|
+
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1145
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1146
|
+
wasm.book_registerFunction(this.__wbg_ptr, ptr0, len0, _function);
|
|
1147
|
+
}
|
|
1148
|
+
/**
|
|
1149
|
+
* The names registered, in no particular order.
|
|
1150
|
+
* @returns {string[]}
|
|
1151
|
+
*/
|
|
1152
|
+
registeredFunctions() {
|
|
1153
|
+
const ret = wasm.book_registeredFunctions(this.__wbg_ptr);
|
|
1154
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]);
|
|
1155
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
1156
|
+
return v1;
|
|
1157
|
+
}
|
|
1158
|
+
/**
|
|
1159
|
+
* Removes the cells of a range, pulling the rest back over the hole from
|
|
1160
|
+
* below (`"up"`) or from the right (`"left"`).
|
|
1161
|
+
* @param {number} sheet
|
|
1162
|
+
* @param {string} range
|
|
1163
|
+
* @param {"up" | "left"} shift
|
|
1164
|
+
*/
|
|
1165
|
+
removeCells(sheet, range, shift) {
|
|
1166
|
+
const ptr0 = passStringToWasm0(range, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1167
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1168
|
+
const ptr1 = passStringToWasm0(shift, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1169
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1170
|
+
const ret = wasm.book_removeCells(this.__wbg_ptr, sheet, ptr0, len0, ptr1, len1);
|
|
1171
|
+
if (ret[1]) {
|
|
1172
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1173
|
+
}
|
|
1174
|
+
}
|
|
1175
|
+
/**
|
|
1176
|
+
* Removes `count` columns from column `at`, 1-based.
|
|
1177
|
+
* @param {number} sheet
|
|
1178
|
+
* @param {number} at
|
|
1179
|
+
* @param {number} count
|
|
1180
|
+
*/
|
|
1181
|
+
removeColumns(sheet, at, count) {
|
|
1182
|
+
const ret = wasm.book_removeColumns(this.__wbg_ptr, sheet, at, count);
|
|
1183
|
+
if (ret[1]) {
|
|
1184
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1185
|
+
}
|
|
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
|
+
}
|
|
1198
|
+
/**
|
|
1199
|
+
* Takes a note off a cell. Answers whether there was one.
|
|
1200
|
+
* @param {number} sheet
|
|
1201
|
+
* @param {string} address
|
|
1202
|
+
* @returns {boolean}
|
|
1203
|
+
*/
|
|
1204
|
+
removeComment(sheet, address) {
|
|
1205
|
+
const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1206
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1207
|
+
const ret = wasm.book_removeComment(this.__wbg_ptr, sheet, ptr0, len0);
|
|
1208
|
+
if (ret[2]) {
|
|
1209
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1210
|
+
}
|
|
1211
|
+
return ret[0] !== 0;
|
|
1212
|
+
}
|
|
1213
|
+
/**
|
|
1214
|
+
* Removes a defined name. Answers whether there was one.
|
|
1215
|
+
* @param {string} name
|
|
1216
|
+
* @param {number | null} [sheet]
|
|
1217
|
+
* @returns {boolean}
|
|
1218
|
+
*/
|
|
1219
|
+
removeDefinedName(name, sheet) {
|
|
1220
|
+
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1221
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1222
|
+
const ret = wasm.book_removeDefinedName(this.__wbg_ptr, ptr0, len0, isLikeNone(sheet) ? Number.MAX_SAFE_INTEGER : (sheet) >>> 0);
|
|
1223
|
+
return ret !== 0;
|
|
1224
|
+
}
|
|
1225
|
+
/**
|
|
1226
|
+
* Takes the link off a range. Answers whether there was one.
|
|
1227
|
+
* @param {number} sheet
|
|
1228
|
+
* @param {string} range
|
|
1229
|
+
* @returns {boolean}
|
|
1230
|
+
*/
|
|
1231
|
+
removeHyperlink(sheet, range) {
|
|
1232
|
+
const ptr0 = passStringToWasm0(range, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1233
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1234
|
+
const ret = wasm.book_removeHyperlink(this.__wbg_ptr, sheet, ptr0, len0);
|
|
1235
|
+
if (ret[2]) {
|
|
1236
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1237
|
+
}
|
|
1238
|
+
return ret[0] !== 0;
|
|
1239
|
+
}
|
|
1240
|
+
/**
|
|
1241
|
+
* Removes `count` rows from row `at` down. A formula that read a removed
|
|
1242
|
+
* cell reads `#REF!` afterwards.
|
|
1243
|
+
* @param {number} sheet
|
|
1244
|
+
* @param {number} at
|
|
1245
|
+
* @param {number} count
|
|
1246
|
+
*/
|
|
1247
|
+
removeRows(sheet, at, count) {
|
|
1248
|
+
const ret = wasm.book_removeRows(this.__wbg_ptr, sheet, at, count);
|
|
1249
|
+
if (ret[1]) {
|
|
1250
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1251
|
+
}
|
|
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
|
+
}
|
|
1265
|
+
/**
|
|
1266
|
+
* Removes a sheet. References to it from anywhere in the workbook become
|
|
1267
|
+
* `#REF!`, the way Excel writes them, and the sheets after it shift down
|
|
1268
|
+
* by one index.
|
|
1269
|
+
* @param {number} sheet
|
|
1270
|
+
*/
|
|
1271
|
+
removeSheet(sheet) {
|
|
1272
|
+
const ret = wasm.book_removeSheet(this.__wbg_ptr, sheet);
|
|
1273
|
+
if (ret[1]) {
|
|
1274
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1275
|
+
}
|
|
1276
|
+
}
|
|
1277
|
+
/**
|
|
1278
|
+
* Removes a table by name. Answers whether there was one.
|
|
1279
|
+
* @param {number} sheet
|
|
1280
|
+
* @param {string} name
|
|
1281
|
+
* @returns {boolean}
|
|
1282
|
+
*/
|
|
1283
|
+
removeTable(sheet, name) {
|
|
1284
|
+
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1285
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1286
|
+
const ret = wasm.book_removeTable(this.__wbg_ptr, sheet, ptr0, len0);
|
|
1287
|
+
if (ret[2]) {
|
|
1288
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1289
|
+
}
|
|
1290
|
+
return ret[0] !== 0;
|
|
1291
|
+
}
|
|
1292
|
+
/**
|
|
1293
|
+
* Renames a sheet.
|
|
1294
|
+
* @param {number} sheet
|
|
1295
|
+
* @param {string} title
|
|
1296
|
+
*/
|
|
1297
|
+
renameSheet(sheet, title) {
|
|
1298
|
+
const ptr0 = passStringToWasm0(title, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1299
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1300
|
+
const ret = wasm.book_renameSheet(this.__wbg_ptr, sheet, ptr0, len0);
|
|
1301
|
+
if (ret[1]) {
|
|
1302
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1303
|
+
}
|
|
1304
|
+
}
|
|
1305
|
+
/**
|
|
1306
|
+
* The height of a row in points, or `undefined` when the sheet leaves it
|
|
1307
|
+
* to the default. `row` is the number a user sees.
|
|
1308
|
+
* @param {number} sheet
|
|
1309
|
+
* @param {number} row
|
|
1310
|
+
* @returns {number | undefined}
|
|
1311
|
+
*/
|
|
1312
|
+
rowHeight(sheet, row) {
|
|
1313
|
+
const ret = wasm.book_rowHeight(this.__wbg_ptr, sheet, row);
|
|
1314
|
+
if (ret[3]) {
|
|
1315
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1316
|
+
}
|
|
1317
|
+
return ret[0] === 0 ? undefined : ret[1];
|
|
1318
|
+
}
|
|
1319
|
+
/**
|
|
1320
|
+
* Whether a row is hidden. `row` is the number a user sees.
|
|
1321
|
+
* @param {number} sheet
|
|
1322
|
+
* @param {number} row
|
|
1323
|
+
* @returns {boolean}
|
|
1324
|
+
*/
|
|
1325
|
+
rowHidden(sheet, row) {
|
|
1326
|
+
const ret = wasm.book_rowHidden(this.__wbg_ptr, sheet, row);
|
|
1327
|
+
if (ret[2]) {
|
|
1328
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1329
|
+
}
|
|
1330
|
+
return ret[0] !== 0;
|
|
1331
|
+
}
|
|
1332
|
+
/**
|
|
1333
|
+
* How deeply a row is grouped: 0 when it is not, 1 for the outermost
|
|
1334
|
+
* group, and so on. `row` is the number a user sees.
|
|
1335
|
+
* @param {number} sheet
|
|
1336
|
+
* @param {number} row
|
|
1337
|
+
* @returns {number}
|
|
1338
|
+
*/
|
|
1339
|
+
rowLevel(sheet, row) {
|
|
1340
|
+
const ret = wasm.book_rowLevel(this.__wbg_ptr, sheet, row);
|
|
1341
|
+
if (ret[2]) {
|
|
1342
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1343
|
+
}
|
|
1344
|
+
return ret[0];
|
|
1345
|
+
}
|
|
1346
|
+
/**
|
|
1347
|
+
* Writes a value: a number, boolean, or string. A string starting with `=`
|
|
1348
|
+
* becomes a formula.
|
|
1349
|
+
* @param {number} sheet
|
|
1350
|
+
* @param {string} address
|
|
1351
|
+
* @param {CellValue} value
|
|
1352
|
+
*/
|
|
1353
|
+
set(sheet, address, value) {
|
|
1354
|
+
const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1355
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1356
|
+
const ret = wasm.book_set(this.__wbg_ptr, sheet, ptr0, len0, value);
|
|
1357
|
+
if (ret[1]) {
|
|
1358
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1359
|
+
}
|
|
1360
|
+
}
|
|
1361
|
+
/**
|
|
1362
|
+
* Sets that tab.
|
|
1363
|
+
* @param {number} sheet
|
|
1364
|
+
*/
|
|
1365
|
+
setActiveSheet(sheet) {
|
|
1366
|
+
const ret = wasm.book_setActiveSheet(this.__wbg_ptr, sheet);
|
|
1367
|
+
if (ret[1]) {
|
|
1368
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1369
|
+
}
|
|
1370
|
+
}
|
|
1371
|
+
/**
|
|
1372
|
+
* The same by 1-based row and column.
|
|
1373
|
+
* @param {number} sheet
|
|
1374
|
+
* @param {number} row
|
|
1375
|
+
* @param {number} column
|
|
1376
|
+
* @param {CellValue} value
|
|
1377
|
+
*/
|
|
1378
|
+
setAt(sheet, row, column, value) {
|
|
1379
|
+
const ret = wasm.book_setAt(this.__wbg_ptr, sheet, row, column, value);
|
|
1380
|
+
if (ret[1]) {
|
|
1381
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1382
|
+
}
|
|
1383
|
+
}
|
|
1384
|
+
/**
|
|
1385
|
+
* Paints a cell: a number format, a font, a fill, borders, alignment, or
|
|
1386
|
+
* any part of those.
|
|
1387
|
+
*
|
|
1388
|
+
* The patch is laid over the style the cell has, so a field left out
|
|
1389
|
+
* keeps what was there - `{ font: { bold: true } }` does not reset the
|
|
1390
|
+
* number format. Equal styles share one entry in the workbook's table,
|
|
1391
|
+
* so painting a column costs one style, not one per cell.
|
|
1392
|
+
*
|
|
1393
|
+
* ```js
|
|
1394
|
+
* book.setCellStyle(0, "B2", {
|
|
1395
|
+
* numberFormat: "#,##0.00",
|
|
1396
|
+
* font: { bold: true, color: "#FF1F4E79" },
|
|
1397
|
+
* fill: { pattern: "solid", foreground: "#FFFFE699" },
|
|
1398
|
+
* alignment: { horizontal: "right" },
|
|
1399
|
+
* });
|
|
1400
|
+
* ```
|
|
1401
|
+
* @param {number} sheet
|
|
1402
|
+
* @param {string} address
|
|
1403
|
+
* @param {CellStylePatch} patch
|
|
1404
|
+
*/
|
|
1405
|
+
setCellStyle(sheet, address, patch) {
|
|
1406
|
+
const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1407
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1408
|
+
const ret = wasm.book_setCellStyle(this.__wbg_ptr, sheet, ptr0, len0, patch);
|
|
1409
|
+
if (ret[1]) {
|
|
1410
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1411
|
+
}
|
|
1412
|
+
}
|
|
1413
|
+
/**
|
|
1414
|
+
* The same by 1-based row and column.
|
|
1415
|
+
* @param {number} sheet
|
|
1416
|
+
* @param {number} row
|
|
1417
|
+
* @param {number} column
|
|
1418
|
+
* @param {CellStylePatch} patch
|
|
1419
|
+
*/
|
|
1420
|
+
setCellStyleAt(sheet, row, column, patch) {
|
|
1421
|
+
const ret = wasm.book_setCellStyleAt(this.__wbg_ptr, sheet, row, column, patch);
|
|
1422
|
+
if (ret[1]) {
|
|
1423
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1424
|
+
}
|
|
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
|
+
}
|
|
1441
|
+
/**
|
|
1442
|
+
* Hides a column, or shows it again. `column` is 1-based.
|
|
1443
|
+
* @param {number} sheet
|
|
1444
|
+
* @param {number} column
|
|
1445
|
+
* @param {boolean} hidden
|
|
1446
|
+
*/
|
|
1447
|
+
setColumnHidden(sheet, column, hidden) {
|
|
1448
|
+
const ret = wasm.book_setColumnHidden(this.__wbg_ptr, sheet, column, hidden);
|
|
1449
|
+
if (ret[1]) {
|
|
1450
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1451
|
+
}
|
|
1452
|
+
}
|
|
1453
|
+
/**
|
|
1454
|
+
* Sets the width of a column in characters of the default font, or gives
|
|
1455
|
+
* it back to the sheet default with `undefined`. `column` is 1-based.
|
|
1456
|
+
*
|
|
1457
|
+
* A run of columns that covered this one is split around it, so the
|
|
1458
|
+
* neighbours keep the width they had.
|
|
1459
|
+
* @param {number} sheet
|
|
1460
|
+
* @param {number} column
|
|
1461
|
+
* @param {number | null} [width]
|
|
1462
|
+
*/
|
|
1463
|
+
setColumnWidth(sheet, column, width) {
|
|
1464
|
+
const ret = wasm.book_setColumnWidth(this.__wbg_ptr, sheet, column, !isLikeNone(width), isLikeNone(width) ? 0 : width);
|
|
1465
|
+
if (ret[1]) {
|
|
1466
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1467
|
+
}
|
|
1468
|
+
}
|
|
1469
|
+
/**
|
|
1470
|
+
* Puts a note on a cell, replacing any note already there.
|
|
1471
|
+
* @param {number} sheet
|
|
1472
|
+
* @param {string} address
|
|
1473
|
+
* @param {string} author
|
|
1474
|
+
* @param {string} text
|
|
1475
|
+
*/
|
|
1476
|
+
setComment(sheet, address, author, text) {
|
|
1477
|
+
const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1478
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1479
|
+
const ptr1 = passStringToWasm0(author, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1480
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1481
|
+
const ptr2 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1482
|
+
const len2 = WASM_VECTOR_LEN;
|
|
1483
|
+
const ret = wasm.book_setComment(this.__wbg_ptr, sheet, ptr0, len0, ptr1, len1, ptr2, len2);
|
|
1484
|
+
if (ret[1]) {
|
|
1485
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1486
|
+
}
|
|
1487
|
+
}
|
|
1488
|
+
/**
|
|
1489
|
+
* Defines a name, replacing one of the same name. `formula` is what it
|
|
1490
|
+
* stands for - `Sheet1!$A$1:$A$9` or a constant - and `sheet` makes the
|
|
1491
|
+
* name local to that sheet instead of the workbook.
|
|
1492
|
+
* @param {string} name
|
|
1493
|
+
* @param {string} formula
|
|
1494
|
+
* @param {number | null} [sheet]
|
|
1495
|
+
*/
|
|
1496
|
+
setDefinedName(name, formula, sheet) {
|
|
1497
|
+
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1498
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1499
|
+
const ptr1 = passStringToWasm0(formula, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1500
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1501
|
+
const ret = wasm.book_setDefinedName(this.__wbg_ptr, ptr0, len0, ptr1, len1, isLikeNone(sheet) ? Number.MAX_SAFE_INTEGER : (sheet) >>> 0);
|
|
1502
|
+
if (ret[1]) {
|
|
1503
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1504
|
+
}
|
|
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
|
+
}
|
|
1519
|
+
/**
|
|
1520
|
+
* Puts a link over a cell or a block of them.
|
|
1521
|
+
*
|
|
1522
|
+
* `target` is a URL or a file path unless `inside` is true, and then it
|
|
1523
|
+
* is a place in this workbook: `'Sheet 2'!A1`.
|
|
1524
|
+
* @param {number} sheet
|
|
1525
|
+
* @param {string} range
|
|
1526
|
+
* @param {string} target
|
|
1527
|
+
* @param {boolean | null} [inside]
|
|
1528
|
+
* @param {string | null} [display]
|
|
1529
|
+
* @param {string | null} [tooltip]
|
|
1530
|
+
*/
|
|
1531
|
+
setHyperlink(sheet, range, target, inside, display, tooltip) {
|
|
1532
|
+
const ptr0 = passStringToWasm0(range, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1533
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1534
|
+
const ptr1 = passStringToWasm0(target, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1535
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1536
|
+
var ptr2 = isLikeNone(display) ? 0 : passStringToWasm0(display, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1537
|
+
var len2 = WASM_VECTOR_LEN;
|
|
1538
|
+
var ptr3 = isLikeNone(tooltip) ? 0 : passStringToWasm0(tooltip, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1539
|
+
var len3 = WASM_VECTOR_LEN;
|
|
1540
|
+
const ret = wasm.book_setHyperlink(this.__wbg_ptr, sheet, ptr0, len0, ptr1, len1, isLikeNone(inside) ? 0xFFFFFF : inside ? 1 : 0, ptr2, len2, ptr3, len3);
|
|
1541
|
+
if (ret[1]) {
|
|
1542
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1543
|
+
}
|
|
1544
|
+
}
|
|
1545
|
+
/**
|
|
1546
|
+
* Writes a rectangle of values with `at` as its top-left corner. Rows may
|
|
1547
|
+
* differ in length; a `null` leaves its cell empty.
|
|
1548
|
+
* @param {number} sheet
|
|
1549
|
+
* @param {string} at
|
|
1550
|
+
* @param {CellGrid} values
|
|
1551
|
+
*/
|
|
1552
|
+
setRange(sheet, at, values) {
|
|
1553
|
+
const ptr0 = passStringToWasm0(at, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1554
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1555
|
+
const ret = wasm.book_setRange(this.__wbg_ptr, sheet, ptr0, len0, values);
|
|
1556
|
+
if (ret[1]) {
|
|
1557
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1558
|
+
}
|
|
1559
|
+
}
|
|
1560
|
+
/**
|
|
1561
|
+
* The same with the corner given as 1-based row and column.
|
|
1562
|
+
* @param {number} sheet
|
|
1563
|
+
* @param {number} row
|
|
1564
|
+
* @param {number} column
|
|
1565
|
+
* @param {CellGrid} values
|
|
1566
|
+
*/
|
|
1567
|
+
setRangeAt(sheet, row, column, values) {
|
|
1568
|
+
const ret = wasm.book_setRangeAt(this.__wbg_ptr, sheet, row, column, values);
|
|
1569
|
+
if (ret[1]) {
|
|
1570
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1571
|
+
}
|
|
1572
|
+
}
|
|
1573
|
+
/**
|
|
1574
|
+
* The same over a rectangle: `setRangeStyle(0, "A1:D1", { font: { bold:
|
|
1575
|
+
* true } })`. Cells the range covers but the sheet has no value for are
|
|
1576
|
+
* created empty, which is what carries the style.
|
|
1577
|
+
* @param {number} sheet
|
|
1578
|
+
* @param {string} range
|
|
1579
|
+
* @param {CellStylePatch} patch
|
|
1580
|
+
*/
|
|
1581
|
+
setRangeStyle(sheet, range, patch) {
|
|
1582
|
+
const ptr0 = passStringToWasm0(range, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1583
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1584
|
+
const ret = wasm.book_setRangeStyle(this.__wbg_ptr, sheet, ptr0, len0, patch);
|
|
1585
|
+
if (ret[1]) {
|
|
1586
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1587
|
+
}
|
|
1588
|
+
}
|
|
1589
|
+
/**
|
|
1590
|
+
* Paints a rectangle cell by cell in one call, `at` its top-left corner:
|
|
1591
|
+
* `grid` points into `styles`, each a patch as `setCellStyle` takes it,
|
|
1592
|
+
* and `null` or `-1` leaves its cell alone. The output of
|
|
1593
|
+
* `getRangeStyles` goes back in unchanged, so a block's formatting can be
|
|
1594
|
+
* read, edited in JS and written back - or copied somewhere else.
|
|
1595
|
+
* @param {number} sheet
|
|
1596
|
+
* @param {string} at
|
|
1597
|
+
* @param {RangeStylesPatch} styles
|
|
1598
|
+
*/
|
|
1599
|
+
setRangeStyles(sheet, at, styles) {
|
|
1600
|
+
const ptr0 = passStringToWasm0(at, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1601
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1602
|
+
const ret = wasm.book_setRangeStyles(this.__wbg_ptr, sheet, ptr0, len0, styles);
|
|
1603
|
+
if (ret[1]) {
|
|
1604
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1605
|
+
}
|
|
1606
|
+
}
|
|
1607
|
+
/**
|
|
1608
|
+
* The same with the corner given as 1-based row and column.
|
|
1609
|
+
* @param {number} sheet
|
|
1610
|
+
* @param {number} row
|
|
1611
|
+
* @param {number} column
|
|
1612
|
+
* @param {RangeStylesPatch} styles
|
|
1613
|
+
*/
|
|
1614
|
+
setRangeStylesAt(sheet, row, column, styles) {
|
|
1615
|
+
const ret = wasm.book_setRangeStylesAt(this.__wbg_ptr, sheet, row, column, styles);
|
|
1616
|
+
if (ret[1]) {
|
|
1617
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1618
|
+
}
|
|
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
|
+
}
|
|
1649
|
+
/**
|
|
1650
|
+
* Sets the height of a row in points, or gives it back to the sheet
|
|
1651
|
+
* default with `undefined`. `row` is the number a user sees.
|
|
1652
|
+
* @param {number} sheet
|
|
1653
|
+
* @param {number} row
|
|
1654
|
+
* @param {number | null} [height]
|
|
1655
|
+
*/
|
|
1656
|
+
setRowHeight(sheet, row, height) {
|
|
1657
|
+
const ret = wasm.book_setRowHeight(this.__wbg_ptr, sheet, row, !isLikeNone(height), isLikeNone(height) ? 0 : height);
|
|
1658
|
+
if (ret[1]) {
|
|
1659
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1660
|
+
}
|
|
1661
|
+
}
|
|
1662
|
+
/**
|
|
1663
|
+
* Hides a row, or shows it again.
|
|
1664
|
+
* @param {number} sheet
|
|
1665
|
+
* @param {number} row
|
|
1666
|
+
* @param {boolean} hidden
|
|
1667
|
+
*/
|
|
1668
|
+
setRowHidden(sheet, row, hidden) {
|
|
1669
|
+
const ret = wasm.book_setRowHidden(this.__wbg_ptr, sheet, row, hidden);
|
|
1670
|
+
if (ret[1]) {
|
|
1671
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1672
|
+
}
|
|
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
|
+
}
|
|
1702
|
+
/**
|
|
1703
|
+
* Gives a sheet a tab or takes it away: `"visible"`, `"hidden"` or
|
|
1704
|
+
* `"veryHidden"`.
|
|
1705
|
+
*
|
|
1706
|
+
* A very hidden sheet is not in the dialog Excel offers for unhiding one.
|
|
1707
|
+
* Either way the sheet keeps its index, which is what every other call
|
|
1708
|
+
* counts.
|
|
1709
|
+
* @param {number} sheet
|
|
1710
|
+
* @param {string} state
|
|
1711
|
+
*/
|
|
1712
|
+
setSheetVisibility(sheet, state) {
|
|
1713
|
+
const ptr0 = passStringToWasm0(state, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1714
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1715
|
+
const ret = wasm.book_setSheetVisibility(this.__wbg_ptr, sheet, ptr0, len0);
|
|
1716
|
+
if (ret[1]) {
|
|
1717
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1718
|
+
}
|
|
1719
|
+
}
|
|
1720
|
+
/**
|
|
1721
|
+
* Shows or hides the grid lines, and the row and column headings with
|
|
1722
|
+
* `headers`.
|
|
1723
|
+
* @param {number} sheet
|
|
1724
|
+
* @param {boolean} show
|
|
1725
|
+
* @param {boolean | null} [headers]
|
|
1726
|
+
*/
|
|
1727
|
+
setShowGridLines(sheet, show, headers) {
|
|
1728
|
+
const ret = wasm.book_setShowGridLines(this.__wbg_ptr, sheet, show, isLikeNone(headers) ? 0xFFFFFF : headers ? 1 : 0);
|
|
1729
|
+
if (ret[1]) {
|
|
1730
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1731
|
+
}
|
|
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
|
+
}
|
|
1760
|
+
/**
|
|
1761
|
+
* The zoom a reader opens the sheet at, in percent; `undefined` gives it
|
|
1762
|
+
* back to 100.
|
|
1763
|
+
* @param {number} sheet
|
|
1764
|
+
* @param {number | null} [percent]
|
|
1765
|
+
*/
|
|
1766
|
+
setZoom(sheet, percent) {
|
|
1767
|
+
const ret = wasm.book_setZoom(this.__wbg_ptr, sheet, isLikeNone(percent) ? Number.MAX_SAFE_INTEGER : (percent) >>> 0);
|
|
1768
|
+
if (ret[1]) {
|
|
1769
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1770
|
+
}
|
|
1771
|
+
}
|
|
1772
|
+
/**
|
|
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.
|
|
1776
|
+
* @param {number} sheet
|
|
1777
|
+
* @returns {SheetShape[]}
|
|
1778
|
+
*/
|
|
1779
|
+
shapes(sheet) {
|
|
1780
|
+
const ret = wasm.book_shapes(this.__wbg_ptr, sheet);
|
|
1781
|
+
if (ret[2]) {
|
|
1782
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1783
|
+
}
|
|
1784
|
+
return takeFromExternrefTable0(ret[0]);
|
|
1785
|
+
}
|
|
1786
|
+
/**
|
|
1787
|
+
* The tab index of a sheet by name, or `undefined` when there is none.
|
|
1788
|
+
* Names are compared the way Excel does, ignoring case.
|
|
1789
|
+
* @param {string} name
|
|
1790
|
+
* @returns {number | undefined}
|
|
1791
|
+
*/
|
|
1792
|
+
sheetIndex(name) {
|
|
1793
|
+
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1794
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1795
|
+
const ret = wasm.book_sheetIndex(this.__wbg_ptr, ptr0, len0);
|
|
1796
|
+
return ret === Number.MAX_SAFE_INTEGER ? undefined : ret;
|
|
1797
|
+
}
|
|
1798
|
+
/**
|
|
1799
|
+
* Sheet titles, in tab order.
|
|
1800
|
+
* @returns {string[]}
|
|
1801
|
+
*/
|
|
1802
|
+
sheetNames() {
|
|
1803
|
+
const ret = wasm.book_sheetNames(this.__wbg_ptr);
|
|
1804
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]);
|
|
1805
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
1806
|
+
return v1;
|
|
1807
|
+
}
|
|
1808
|
+
/**
|
|
1809
|
+
* Whether a sheet is locked, and whether the lock has a password.
|
|
1810
|
+
* @param {number} sheet
|
|
1811
|
+
* @returns {ProtectionInfo}
|
|
1812
|
+
*/
|
|
1813
|
+
sheetProtection(sheet) {
|
|
1814
|
+
const ret = wasm.book_sheetProtection(this.__wbg_ptr, sheet);
|
|
1815
|
+
if (ret[2]) {
|
|
1816
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1817
|
+
}
|
|
1818
|
+
return takeFromExternrefTable0(ret[0]);
|
|
1819
|
+
}
|
|
1820
|
+
/**
|
|
1821
|
+
* How the sheet is frozen and shown.
|
|
1822
|
+
* @param {number} sheet
|
|
1823
|
+
* @returns {SheetViewInfo}
|
|
1824
|
+
*/
|
|
1825
|
+
sheetView(sheet) {
|
|
1826
|
+
const ret = wasm.book_sheetView(this.__wbg_ptr, sheet);
|
|
1827
|
+
if (ret[2]) {
|
|
1828
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1829
|
+
}
|
|
1830
|
+
return takeFromExternrefTable0(ret[0]);
|
|
1831
|
+
}
|
|
1832
|
+
/**
|
|
1833
|
+
* Whether a sheet has a tab: `"visible"`, `"hidden"` or `"veryHidden"`.
|
|
1834
|
+
*
|
|
1835
|
+
* `sheetNames` lists every sheet, hidden ones included, because that is
|
|
1836
|
+
* what the index of every other call counts.
|
|
1837
|
+
* @param {number} sheet
|
|
1838
|
+
* @returns {string}
|
|
1839
|
+
*/
|
|
1840
|
+
sheetVisibility(sheet) {
|
|
1841
|
+
let deferred2_0;
|
|
1842
|
+
let deferred2_1;
|
|
1843
|
+
try {
|
|
1844
|
+
const ret = wasm.book_sheetVisibility(this.__wbg_ptr, sheet);
|
|
1845
|
+
var ptr1 = ret[0];
|
|
1846
|
+
var len1 = ret[1];
|
|
1847
|
+
if (ret[3]) {
|
|
1848
|
+
ptr1 = 0; len1 = 0;
|
|
1849
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1850
|
+
}
|
|
1851
|
+
deferred2_0 = ptr1;
|
|
1852
|
+
deferred2_1 = len1;
|
|
1853
|
+
return getStringFromWasm0(ptr1, len1);
|
|
1854
|
+
} finally {
|
|
1855
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
1856
|
+
}
|
|
1857
|
+
}
|
|
1858
|
+
/**
|
|
1859
|
+
* Sorts the rows of a range, or its columns. A key is a column number of
|
|
1860
|
+
* the sheet, 1-based (a row number when sorting columns), or the text of
|
|
1861
|
+
* a header when `options.header` says the first line is one; a minus
|
|
1862
|
+
* sorts it largest first: `[2, -4]`, `["Region", "-Amount"]`. The first
|
|
1863
|
+
* key decides first.
|
|
1864
|
+
*
|
|
1865
|
+
* ```js
|
|
1866
|
+
* book.sortRange(0, "A1:D100", ["Region", "-Amount"], { header: true });
|
|
1867
|
+
* ```
|
|
1868
|
+
* @param {number} sheet
|
|
1869
|
+
* @param {string} range
|
|
1870
|
+
* @param {SortKeys} keys
|
|
1871
|
+
* @param {SortRangeOptions} [options]
|
|
1872
|
+
*/
|
|
1873
|
+
sortRange(sheet, range, keys, options) {
|
|
1874
|
+
const ptr0 = passStringToWasm0(range, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1875
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1876
|
+
const ret = wasm.book_sortRange(this.__wbg_ptr, sheet, ptr0, len0, keys, options);
|
|
1877
|
+
if (ret[1]) {
|
|
1878
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1879
|
+
}
|
|
1880
|
+
}
|
|
1881
|
+
/**
|
|
1882
|
+
* Sorts the data rows of a table, found by name anywhere in the book;
|
|
1883
|
+
* its header and totals rows stay put. Keys name its columns, as in
|
|
1884
|
+
* `sortRange`: `book.sortTable("Sales", ["-Amount"])`.
|
|
1885
|
+
* @param {string} name
|
|
1886
|
+
* @param {SortKeys} keys
|
|
1887
|
+
*/
|
|
1888
|
+
sortTable(name, keys) {
|
|
1889
|
+
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1890
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1891
|
+
const ret = wasm.book_sortTable(this.__wbg_ptr, ptr0, len0, keys);
|
|
1892
|
+
if (ret[1]) {
|
|
1893
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1894
|
+
}
|
|
1895
|
+
}
|
|
1896
|
+
/**
|
|
1897
|
+
* The tables of a sheet: what a structured reference like `Sales[Amount]`
|
|
1898
|
+
* names.
|
|
1899
|
+
* @param {number} sheet
|
|
1900
|
+
* @returns {SheetTable[]}
|
|
1901
|
+
*/
|
|
1902
|
+
tables(sheet) {
|
|
1903
|
+
const ret = wasm.book_tables(this.__wbg_ptr, sheet);
|
|
1904
|
+
if (ret[2]) {
|
|
1905
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1906
|
+
}
|
|
1907
|
+
return takeFromExternrefTable0(ret[0]);
|
|
1908
|
+
}
|
|
1909
|
+
/**
|
|
1910
|
+
* One sheet as CSV, comma-separated unless `options.delimiter` says
|
|
1911
|
+
* otherwise - a semicolon for a locale where the comma is the decimal
|
|
1912
|
+
* mark.
|
|
1913
|
+
* @param {number} sheet
|
|
1914
|
+
* @param {CsvOptions} [options]
|
|
1915
|
+
* @returns {string}
|
|
1916
|
+
*/
|
|
1917
|
+
toCsv(sheet, options) {
|
|
1918
|
+
let deferred2_0;
|
|
1919
|
+
let deferred2_1;
|
|
1920
|
+
try {
|
|
1921
|
+
const ret = wasm.book_toCsv(this.__wbg_ptr, sheet, options);
|
|
1922
|
+
var ptr1 = ret[0];
|
|
1923
|
+
var len1 = ret[1];
|
|
1924
|
+
if (ret[3]) {
|
|
1925
|
+
ptr1 = 0; len1 = 0;
|
|
1926
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1927
|
+
}
|
|
1928
|
+
deferred2_0 = ptr1;
|
|
1929
|
+
deferred2_1 = len1;
|
|
1930
|
+
return getStringFromWasm0(ptr1, len1);
|
|
1931
|
+
} finally {
|
|
1932
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
1933
|
+
}
|
|
1934
|
+
}
|
|
1935
|
+
/**
|
|
1936
|
+
* The workbook as an HTML page, or one sheet of it. `fragment` leaves out
|
|
1937
|
+
* the `<html>` wrapper, for embedding in a page that already has one.
|
|
1938
|
+
* @param {number | null} [sheet]
|
|
1939
|
+
* @param {boolean | null} [fragment]
|
|
1940
|
+
* @returns {string}
|
|
1941
|
+
*/
|
|
1942
|
+
toHtml(sheet, fragment) {
|
|
1943
|
+
let deferred2_0;
|
|
1944
|
+
let deferred2_1;
|
|
1945
|
+
try {
|
|
1946
|
+
const ret = wasm.book_toHtml(this.__wbg_ptr, isLikeNone(sheet) ? Number.MAX_SAFE_INTEGER : (sheet) >>> 0, isLikeNone(fragment) ? 0xFFFFFF : fragment ? 1 : 0);
|
|
1947
|
+
var ptr1 = ret[0];
|
|
1948
|
+
var len1 = ret[1];
|
|
1949
|
+
if (ret[3]) {
|
|
1950
|
+
ptr1 = 0; len1 = 0;
|
|
1951
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1952
|
+
}
|
|
1953
|
+
deferred2_0 = ptr1;
|
|
1954
|
+
deferred2_1 = len1;
|
|
1955
|
+
return getStringFromWasm0(ptr1, len1);
|
|
1956
|
+
} finally {
|
|
1957
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
1958
|
+
}
|
|
1959
|
+
}
|
|
1960
|
+
/**
|
|
1961
|
+
* The workbook as an `OpenDocument` spreadsheet.
|
|
1962
|
+
* @returns {Uint8Array}
|
|
1963
|
+
*/
|
|
1964
|
+
toOds() {
|
|
1965
|
+
const ret = wasm.book_toOds(this.__wbg_ptr);
|
|
1966
|
+
if (ret[3]) {
|
|
1967
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1968
|
+
}
|
|
1969
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
1970
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
1971
|
+
return v1;
|
|
1972
|
+
}
|
|
1973
|
+
/**
|
|
1974
|
+
* The workbook as a BIFF8 `.xls` file.
|
|
1975
|
+
*
|
|
1976
|
+
* Formulas are written as tokens with their cached result; what BIFF8
|
|
1977
|
+
* cannot hold - a structured reference, a row past 65536 - is written as
|
|
1978
|
+
* the value, so call `recalculate` first if the cache is stale.
|
|
1979
|
+
* @returns {Uint8Array}
|
|
1980
|
+
*/
|
|
1981
|
+
toXls() {
|
|
1982
|
+
const ret = wasm.book_toXls(this.__wbg_ptr);
|
|
1983
|
+
if (ret[3]) {
|
|
1984
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1985
|
+
}
|
|
1986
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
1987
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
1988
|
+
return v1;
|
|
1989
|
+
}
|
|
1990
|
+
/**
|
|
1991
|
+
* The workbook as an xlsx package.
|
|
1992
|
+
* @param {Function | null} [on_progress]
|
|
1993
|
+
* @returns {Uint8Array}
|
|
1994
|
+
*/
|
|
1995
|
+
toXlsx(on_progress) {
|
|
1996
|
+
const ret = wasm.book_toXlsx(this.__wbg_ptr, isLikeNone(on_progress) ? 0 : addToExternrefTable0(on_progress));
|
|
1997
|
+
if (ret[3]) {
|
|
1998
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1999
|
+
}
|
|
2000
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
2001
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
2002
|
+
return v1;
|
|
2003
|
+
}
|
|
2004
|
+
/**
|
|
2005
|
+
* Takes a merge back out. Answers whether there was one.
|
|
2006
|
+
* @param {number} sheet
|
|
2007
|
+
* @param {string} range
|
|
2008
|
+
* @returns {boolean}
|
|
2009
|
+
*/
|
|
2010
|
+
unmerge(sheet, range) {
|
|
2011
|
+
const ptr0 = passStringToWasm0(range, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2012
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2013
|
+
const ret = wasm.book_unmerge(this.__wbg_ptr, sheet, ptr0, len0);
|
|
2014
|
+
if (ret[2]) {
|
|
2015
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2016
|
+
}
|
|
2017
|
+
return ret[0] !== 0;
|
|
2018
|
+
}
|
|
2019
|
+
/**
|
|
2020
|
+
* Unlocks a sheet, password and all.
|
|
2021
|
+
* @param {number} sheet
|
|
2022
|
+
*/
|
|
2023
|
+
unprotectSheet(sheet) {
|
|
2024
|
+
const ret = wasm.book_unprotectSheet(this.__wbg_ptr, sheet);
|
|
2025
|
+
if (ret[1]) {
|
|
2026
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
2027
|
+
}
|
|
2028
|
+
}
|
|
2029
|
+
/**
|
|
2030
|
+
* Unlocks the workbook.
|
|
2031
|
+
*/
|
|
2032
|
+
unprotectWorkbook() {
|
|
2033
|
+
wasm.book_unprotectWorkbook(this.__wbg_ptr);
|
|
2034
|
+
}
|
|
2035
|
+
/**
|
|
2036
|
+
* Forgets a function registered earlier; answers whether there was one.
|
|
2037
|
+
* @param {string} name
|
|
2038
|
+
* @returns {boolean}
|
|
2039
|
+
*/
|
|
2040
|
+
unregisterFunction(name) {
|
|
2041
|
+
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2042
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2043
|
+
const ret = wasm.book_unregisterFunction(this.__wbg_ptr, ptr0, len0);
|
|
2044
|
+
return ret !== 0;
|
|
2045
|
+
}
|
|
2046
|
+
/**
|
|
2047
|
+
* The used range of a sheet as `A1:D9`, or `undefined` if it holds
|
|
2048
|
+
* nothing. This is the rectangle to walk; the sheet itself is sparse.
|
|
2049
|
+
* @param {number} sheet
|
|
2050
|
+
* @returns {string | undefined}
|
|
2051
|
+
*/
|
|
2052
|
+
usedRange(sheet) {
|
|
2053
|
+
const ret = wasm.book_usedRange(this.__wbg_ptr, sheet);
|
|
2054
|
+
let v1;
|
|
2055
|
+
if (ret[0] !== 0) {
|
|
2056
|
+
v1 = getStringFromWasm0(ret[0], ret[1]);
|
|
2057
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
2058
|
+
}
|
|
2059
|
+
return v1;
|
|
2060
|
+
}
|
|
2061
|
+
/**
|
|
2062
|
+
* The used range of a sheet as `"A1:D20"` without walking the rows;
|
|
2063
|
+
* `undefined` for an empty sheet.
|
|
2064
|
+
*
|
|
2065
|
+
* Rows are exact, columns an upper bound: removing a cell never narrows
|
|
2066
|
+
* them. `usedRange` answers the same until a cell in an edge column is
|
|
2067
|
+
* removed, and walks the rows after that to give the exact rectangle.
|
|
2068
|
+
* @param {number} sheet
|
|
2069
|
+
* @returns {string | undefined}
|
|
2070
|
+
*/
|
|
2071
|
+
usedRangeHint(sheet) {
|
|
2072
|
+
const ret = wasm.book_usedRangeHint(this.__wbg_ptr, sheet);
|
|
2073
|
+
if (ret[3]) {
|
|
2074
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
2075
|
+
}
|
|
2076
|
+
let v1;
|
|
2077
|
+
if (ret[0] !== 0) {
|
|
2078
|
+
v1 = getStringFromWasm0(ret[0], ret[1]);
|
|
2079
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
2080
|
+
}
|
|
2081
|
+
return v1;
|
|
2082
|
+
}
|
|
2083
|
+
/**
|
|
2084
|
+
* Whether that password unlocks the sheet. `false` for a sheet with no
|
|
2085
|
+
* password on it, and for a hash this crate cannot check.
|
|
2086
|
+
* @param {number} sheet
|
|
2087
|
+
* @param {string} password
|
|
2088
|
+
* @returns {boolean}
|
|
2089
|
+
*/
|
|
2090
|
+
verifySheetPassword(sheet, password) {
|
|
2091
|
+
const ptr0 = passStringToWasm0(password, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2092
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2093
|
+
const ret = wasm.book_verifySheetPassword(this.__wbg_ptr, sheet, ptr0, len0);
|
|
2094
|
+
if (ret[2]) {
|
|
2095
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2096
|
+
}
|
|
2097
|
+
return ret[0] !== 0;
|
|
2098
|
+
}
|
|
2099
|
+
/**
|
|
2100
|
+
* Whether the workbook's structure is locked, and whether behind a
|
|
2101
|
+
* password.
|
|
2102
|
+
* @returns {ProtectionInfo}
|
|
2103
|
+
*/
|
|
2104
|
+
workbookProtection() {
|
|
2105
|
+
const ret = wasm.book_workbookProtection(this.__wbg_ptr);
|
|
2106
|
+
return ret;
|
|
2107
|
+
}
|
|
2108
|
+
}
|
|
2109
|
+
if (Symbol.dispose) Book.prototype[Symbol.dispose] = Book.prototype.free;
|
|
2110
|
+
function __wbg_get_imports() {
|
|
2111
|
+
const import0 = {
|
|
2112
|
+
__proto__: null,
|
|
2113
|
+
__wbg_Error_408e67f47ca7b58b: function(arg0, arg1) {
|
|
2114
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
2115
|
+
return ret;
|
|
2116
|
+
},
|
|
2117
|
+
__wbg___wbindgen_boolean_get_c9c83ebd41b34df3: function(arg0) {
|
|
2118
|
+
const v = arg0;
|
|
2119
|
+
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
2120
|
+
return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
|
|
2121
|
+
},
|
|
2122
|
+
__wbg___wbindgen_is_falsy_b7464e97ddc1b7a4: function(arg0) {
|
|
2123
|
+
const ret = !arg0;
|
|
2124
|
+
return ret;
|
|
2125
|
+
},
|
|
2126
|
+
__wbg___wbindgen_is_null_7d13f41e1a2d5140: function(arg0) {
|
|
2127
|
+
const ret = arg0 === null;
|
|
2128
|
+
return ret;
|
|
2129
|
+
},
|
|
2130
|
+
__wbg___wbindgen_is_object_a2790eb24c211ea0: function(arg0) {
|
|
2131
|
+
const val = arg0;
|
|
2132
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
2133
|
+
return ret;
|
|
2134
|
+
},
|
|
2135
|
+
__wbg___wbindgen_is_undefined_6cff064c44e0d823: function(arg0) {
|
|
2136
|
+
const ret = arg0 === undefined;
|
|
2137
|
+
return ret;
|
|
2138
|
+
},
|
|
2139
|
+
__wbg___wbindgen_number_get_136b9679cab35cfb: function(arg0, arg1) {
|
|
2140
|
+
const obj = arg1;
|
|
2141
|
+
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
2142
|
+
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
2143
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
2144
|
+
},
|
|
2145
|
+
__wbg___wbindgen_string_get_d154f1e671052120: function(arg0, arg1) {
|
|
2146
|
+
const obj = arg1;
|
|
2147
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
2148
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2149
|
+
var len1 = WASM_VECTOR_LEN;
|
|
2150
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
2151
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
2152
|
+
},
|
|
2153
|
+
__wbg___wbindgen_throw_bb96b2010945f0bc: function(arg0, arg1) {
|
|
2154
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
2155
|
+
},
|
|
2156
|
+
__wbg_apply_6cd9daeacef161ce: function() { return handleError(function (arg0, arg1, arg2) {
|
|
2157
|
+
const ret = Reflect.apply(arg0, arg1, arg2);
|
|
2158
|
+
return ret;
|
|
2159
|
+
}, arguments); },
|
|
2160
|
+
__wbg_call_0f2a9af232c18fd2: function() { return handleError(function (arg0, arg1, arg2, arg3) {
|
|
2161
|
+
const ret = arg0.call(arg1, arg2, arg3);
|
|
2162
|
+
return ret;
|
|
2163
|
+
}, arguments); },
|
|
2164
|
+
__wbg_call_35dba3c747ad7521: function() { return handleError(function (arg0, arg1, arg2) {
|
|
2165
|
+
const ret = arg0.call(arg1, arg2);
|
|
2166
|
+
return ret;
|
|
2167
|
+
}, arguments); },
|
|
2168
|
+
__wbg_from_74f3d90e0ff11240: function(arg0) {
|
|
2169
|
+
const ret = Array.from(arg0);
|
|
2170
|
+
return ret;
|
|
2171
|
+
},
|
|
2172
|
+
__wbg_getRandomValues_436a51d0629d84e1: function() { return handleError(function (arg0, arg1) {
|
|
2173
|
+
globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
|
|
2174
|
+
}, arguments); },
|
|
2175
|
+
__wbg_getTime_63fb0332e6c4ec17: function(arg0) {
|
|
2176
|
+
const ret = arg0.getTime();
|
|
2177
|
+
return ret;
|
|
2178
|
+
},
|
|
2179
|
+
__wbg_get_971a0c45d172643f: function() { return handleError(function (arg0, arg1) {
|
|
2180
|
+
const ret = Reflect.get(arg0, arg1);
|
|
2181
|
+
return ret;
|
|
2182
|
+
}, arguments); },
|
|
2183
|
+
__wbg_get_c0c8f8d7da0c03dd: function(arg0, arg1) {
|
|
2184
|
+
const ret = arg0[arg1 >>> 0];
|
|
2185
|
+
return ret;
|
|
2186
|
+
},
|
|
2187
|
+
__wbg_get_unchecked_e20b893aeafc3fca: function(arg0, arg1) {
|
|
2188
|
+
const ret = arg0[arg1 >>> 0];
|
|
2189
|
+
return ret;
|
|
2190
|
+
},
|
|
2191
|
+
__wbg_isArray_6339f732981044bf: function(arg0) {
|
|
2192
|
+
const ret = Array.isArray(arg0);
|
|
2193
|
+
return ret;
|
|
2194
|
+
},
|
|
2195
|
+
__wbg_length_ecfa2c63d3d0d82c: function(arg0) {
|
|
2196
|
+
const ret = arg0.length;
|
|
2197
|
+
return ret;
|
|
2198
|
+
},
|
|
2199
|
+
__wbg_message_c141d5e68716b595: function(arg0) {
|
|
2200
|
+
const ret = arg0.message;
|
|
2201
|
+
return ret;
|
|
2202
|
+
},
|
|
2203
|
+
__wbg_new_0_f117d868b403dc07: function() {
|
|
2204
|
+
const ret = new Date();
|
|
2205
|
+
return ret;
|
|
2206
|
+
},
|
|
2207
|
+
__wbg_new_116be93542d39019: function() {
|
|
2208
|
+
const ret = new Array();
|
|
2209
|
+
return ret;
|
|
2210
|
+
},
|
|
2211
|
+
__wbg_new_ebe3e0f6837f0879: function() {
|
|
2212
|
+
const ret = new Object();
|
|
2213
|
+
return ret;
|
|
2214
|
+
},
|
|
2215
|
+
__wbg_new_from_slice_3eea173078478cfe: function(arg0, arg1) {
|
|
2216
|
+
const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
|
|
2217
|
+
return ret;
|
|
2218
|
+
},
|
|
2219
|
+
__wbg_new_from_slice_8aed4f0384605526: function(arg0, arg1) {
|
|
2220
|
+
const ret = new Uint32Array(getArrayU32FromWasm0(arg0, arg1));
|
|
2221
|
+
return ret;
|
|
2222
|
+
},
|
|
2223
|
+
__wbg_now_8b265300afd5f2b9: function() {
|
|
2224
|
+
const ret = Date.now();
|
|
2225
|
+
return ret;
|
|
2226
|
+
},
|
|
2227
|
+
__wbg_push_adb0107829f02d75: function(arg0, arg1) {
|
|
2228
|
+
const ret = arg0.push(arg1);
|
|
2229
|
+
return ret;
|
|
2230
|
+
},
|
|
2231
|
+
__wbg_set_8155bb79a948541b: function() { return handleError(function (arg0, arg1, arg2) {
|
|
2232
|
+
const ret = Reflect.set(arg0, arg1, arg2);
|
|
2233
|
+
return ret;
|
|
2234
|
+
}, arguments); },
|
|
2235
|
+
__wbindgen_cast_0000000000000001: function(arg0) {
|
|
2236
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
2237
|
+
const ret = arg0;
|
|
2238
|
+
return ret;
|
|
2239
|
+
},
|
|
2240
|
+
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
2241
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
2242
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
2243
|
+
return ret;
|
|
2244
|
+
},
|
|
2245
|
+
__wbindgen_init_externref_table: function() {
|
|
2246
|
+
const table = wasm.__wbindgen_externrefs;
|
|
2247
|
+
const offset = table.grow(4);
|
|
2248
|
+
table.set(0, undefined);
|
|
2249
|
+
table.set(offset + 0, undefined);
|
|
2250
|
+
table.set(offset + 1, null);
|
|
2251
|
+
table.set(offset + 2, true);
|
|
2252
|
+
table.set(offset + 3, false);
|
|
2253
|
+
},
|
|
2254
|
+
};
|
|
2255
|
+
return {
|
|
2256
|
+
__proto__: null,
|
|
2257
|
+
"./excelerate_bg.js": import0,
|
|
2258
|
+
};
|
|
2259
|
+
}
|
|
2260
|
+
|
|
2261
|
+
const BookFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
2262
|
+
? { register: () => {}, unregister: () => {} }
|
|
2263
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_book_free(ptr, 1));
|
|
2264
|
+
|
|
2265
|
+
function addToExternrefTable0(obj) {
|
|
2266
|
+
const idx = wasm.__externref_table_alloc();
|
|
2267
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
2268
|
+
return idx;
|
|
2269
|
+
}
|
|
2270
|
+
|
|
2271
|
+
function getArrayJsValueFromWasm0(ptr, len) {
|
|
2272
|
+
ptr = ptr >>> 0;
|
|
2273
|
+
const mem = getDataViewMemory0();
|
|
2274
|
+
const result = [];
|
|
2275
|
+
for (let i = ptr; i < ptr + 4 * len; i += 4) {
|
|
2276
|
+
result.push(wasm.__wbindgen_externrefs.get(mem.getUint32(i, true)));
|
|
2277
|
+
}
|
|
2278
|
+
wasm.__externref_drop_slice(ptr, len);
|
|
2279
|
+
return result;
|
|
2280
|
+
}
|
|
2281
|
+
|
|
2282
|
+
function getArrayU32FromWasm0(ptr, len) {
|
|
2283
|
+
ptr = ptr >>> 0;
|
|
2284
|
+
return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
|
2285
|
+
}
|
|
2286
|
+
|
|
2287
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
2288
|
+
ptr = ptr >>> 0;
|
|
2289
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
2290
|
+
}
|
|
2291
|
+
|
|
2292
|
+
let cachedDataViewMemory0 = null;
|
|
2293
|
+
function getDataViewMemory0() {
|
|
2294
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
2295
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
2296
|
+
}
|
|
2297
|
+
return cachedDataViewMemory0;
|
|
2298
|
+
}
|
|
2299
|
+
|
|
2300
|
+
function getStringFromWasm0(ptr, len) {
|
|
2301
|
+
return decodeText(ptr >>> 0, len);
|
|
2302
|
+
}
|
|
2303
|
+
|
|
2304
|
+
let cachedUint32ArrayMemory0 = null;
|
|
2305
|
+
function getUint32ArrayMemory0() {
|
|
2306
|
+
if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
|
|
2307
|
+
cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
|
|
2308
|
+
}
|
|
2309
|
+
return cachedUint32ArrayMemory0;
|
|
2310
|
+
}
|
|
2311
|
+
|
|
2312
|
+
let cachedUint8ArrayMemory0 = null;
|
|
2313
|
+
function getUint8ArrayMemory0() {
|
|
2314
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
2315
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
2316
|
+
}
|
|
2317
|
+
return cachedUint8ArrayMemory0;
|
|
2318
|
+
}
|
|
2319
|
+
|
|
2320
|
+
function handleError(f, args) {
|
|
2321
|
+
try {
|
|
2322
|
+
return f.apply(this, args);
|
|
2323
|
+
} catch (e) {
|
|
2324
|
+
const idx = addToExternrefTable0(e);
|
|
2325
|
+
wasm.__wbindgen_exn_store(idx);
|
|
2326
|
+
}
|
|
2327
|
+
}
|
|
2328
|
+
|
|
2329
|
+
function isLikeNone(x) {
|
|
2330
|
+
return x === undefined || x === null;
|
|
2331
|
+
}
|
|
2332
|
+
|
|
2333
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
2334
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
2335
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
2336
|
+
WASM_VECTOR_LEN = arg.length;
|
|
2337
|
+
return ptr;
|
|
2338
|
+
}
|
|
2339
|
+
|
|
2340
|
+
function passArrayJsValueToWasm0(array, malloc) {
|
|
2341
|
+
const ptr = malloc(array.length * 4, 4) >>> 0;
|
|
2342
|
+
for (let i = 0; i < array.length; i++) {
|
|
2343
|
+
const add = addToExternrefTable0(array[i]);
|
|
2344
|
+
getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
|
|
2345
|
+
}
|
|
2346
|
+
WASM_VECTOR_LEN = array.length;
|
|
2347
|
+
return ptr;
|
|
2348
|
+
}
|
|
2349
|
+
|
|
2350
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
2351
|
+
if (realloc === undefined) {
|
|
2352
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
2353
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
2354
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
2355
|
+
WASM_VECTOR_LEN = buf.length;
|
|
2356
|
+
return ptr;
|
|
2357
|
+
}
|
|
2358
|
+
|
|
2359
|
+
let len = arg.length;
|
|
2360
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
2361
|
+
|
|
2362
|
+
const mem = getUint8ArrayMemory0();
|
|
2363
|
+
|
|
2364
|
+
let offset = 0;
|
|
2365
|
+
|
|
2366
|
+
for (; offset < len; offset++) {
|
|
2367
|
+
const code = arg.charCodeAt(offset);
|
|
2368
|
+
if (code > 0x7F) break;
|
|
2369
|
+
mem[ptr + offset] = code;
|
|
2370
|
+
}
|
|
2371
|
+
if (offset !== len) {
|
|
2372
|
+
if (offset !== 0) {
|
|
2373
|
+
arg = arg.slice(offset);
|
|
2374
|
+
}
|
|
2375
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
2376
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
2377
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
2378
|
+
|
|
2379
|
+
offset += ret.written;
|
|
2380
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
2381
|
+
}
|
|
2382
|
+
|
|
2383
|
+
WASM_VECTOR_LEN = offset;
|
|
2384
|
+
return ptr;
|
|
2385
|
+
}
|
|
2386
|
+
|
|
2387
|
+
function takeFromExternrefTable0(idx) {
|
|
2388
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
2389
|
+
wasm.__externref_table_dealloc(idx);
|
|
2390
|
+
return value;
|
|
2391
|
+
}
|
|
2392
|
+
|
|
2393
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
2394
|
+
cachedTextDecoder.decode();
|
|
2395
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
2396
|
+
let numBytesDecoded = 0;
|
|
2397
|
+
function decodeText(ptr, len) {
|
|
2398
|
+
numBytesDecoded += len;
|
|
2399
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
2400
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
2401
|
+
cachedTextDecoder.decode();
|
|
2402
|
+
numBytesDecoded = len;
|
|
2403
|
+
}
|
|
2404
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
2405
|
+
}
|
|
2406
|
+
|
|
2407
|
+
const cachedTextEncoder = new TextEncoder();
|
|
2408
|
+
|
|
2409
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
2410
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
2411
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
2412
|
+
view.set(buf);
|
|
2413
|
+
return {
|
|
2414
|
+
read: arg.length,
|
|
2415
|
+
written: buf.length
|
|
2416
|
+
};
|
|
2417
|
+
};
|
|
2418
|
+
}
|
|
2419
|
+
|
|
2420
|
+
let WASM_VECTOR_LEN = 0;
|
|
2421
|
+
|
|
2422
|
+
let wasmModule, wasmInstance, wasm;
|
|
2423
|
+
function __wbg_finalize_init(instance, module) {
|
|
2424
|
+
wasmInstance = instance;
|
|
2425
|
+
wasm = instance.exports;
|
|
2426
|
+
wasmModule = module;
|
|
2427
|
+
cachedDataViewMemory0 = null;
|
|
2428
|
+
cachedUint32ArrayMemory0 = null;
|
|
2429
|
+
cachedUint8ArrayMemory0 = null;
|
|
2430
|
+
wasm.__wbindgen_start();
|
|
2431
|
+
return wasm;
|
|
2432
|
+
}
|
|
2433
|
+
|
|
2434
|
+
async function __wbg_load(module, imports) {
|
|
2435
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
2436
|
+
if (!module.ok) {
|
|
2437
|
+
throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);
|
|
2438
|
+
}
|
|
2439
|
+
|
|
2440
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
2441
|
+
try {
|
|
2442
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
2443
|
+
} catch (e) {
|
|
2444
|
+
const validResponse = expectedResponseType(module.type);
|
|
2445
|
+
|
|
2446
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
2447
|
+
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
2448
|
+
|
|
2449
|
+
} else { throw e; }
|
|
2450
|
+
}
|
|
2451
|
+
}
|
|
2452
|
+
|
|
2453
|
+
const bytes = await module.arrayBuffer();
|
|
2454
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
2455
|
+
} else {
|
|
2456
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
2457
|
+
|
|
2458
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
2459
|
+
return { instance, module };
|
|
2460
|
+
} else {
|
|
2461
|
+
return instance;
|
|
2462
|
+
}
|
|
2463
|
+
}
|
|
2464
|
+
|
|
2465
|
+
function expectedResponseType(type) {
|
|
2466
|
+
switch (type) {
|
|
2467
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
2468
|
+
}
|
|
2469
|
+
return false;
|
|
2470
|
+
}
|
|
2471
|
+
}
|
|
2472
|
+
|
|
2473
|
+
function initSync(module) {
|
|
2474
|
+
if (wasm !== undefined) return wasm;
|
|
2475
|
+
|
|
2476
|
+
|
|
2477
|
+
if (module !== undefined) {
|
|
2478
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
2479
|
+
({module} = module)
|
|
2480
|
+
} else {
|
|
2481
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
2482
|
+
}
|
|
2483
|
+
}
|
|
2484
|
+
|
|
2485
|
+
const imports = __wbg_get_imports();
|
|
2486
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
2487
|
+
module = new WebAssembly.Module(module);
|
|
2488
|
+
}
|
|
2489
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
2490
|
+
return __wbg_finalize_init(instance, module);
|
|
2491
|
+
}
|
|
2492
|
+
|
|
2493
|
+
async function __wbg_init(module_or_path) {
|
|
2494
|
+
if (wasm !== undefined) return wasm;
|
|
2495
|
+
|
|
2496
|
+
|
|
2497
|
+
if (module_or_path !== undefined) {
|
|
2498
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
2499
|
+
({module_or_path} = module_or_path)
|
|
2500
|
+
} else {
|
|
2501
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
2502
|
+
}
|
|
2503
|
+
}
|
|
2504
|
+
|
|
2505
|
+
if (module_or_path === undefined) {
|
|
2506
|
+
module_or_path = new URL('excelerate_bg.wasm', import.meta.url);
|
|
2507
|
+
}
|
|
2508
|
+
const imports = __wbg_get_imports();
|
|
2509
|
+
|
|
2510
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
2511
|
+
module_or_path = fetch(module_or_path);
|
|
2512
|
+
}
|
|
2513
|
+
|
|
2514
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
2515
|
+
|
|
2516
|
+
return __wbg_finalize_init(instance, module);
|
|
2517
|
+
}
|
|
2518
|
+
|
|
2519
|
+
export { initSync, __wbg_init as default };
|