@trebco/treb 21.2.4
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/LICENSE.txt +165 -0
- package/README-esm.md +37 -0
- package/README.md +149 -0
- package/package.json +14 -0
- package/treb-bundle.css +2 -0
- package/treb-bundle.mjs +15 -0
- package/treb.d.ts +1080 -0
package/treb.d.ts
ADDED
|
@@ -0,0 +1,1080 @@
|
|
|
1
|
+
/*! API v21.2. Copyright 2018-2022 trebco, llc. All rights reserved. LGPL: https://treb.app/license */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Global instance. In the base script, this object will be created as an
|
|
5
|
+
* ambient global object (bound to the window object). If you instead use the
|
|
6
|
+
* ES module, import the TREB object from the module.
|
|
7
|
+
*/
|
|
8
|
+
declare const TREB: TREBGlobal;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* global object used to create spreadsheets
|
|
12
|
+
*/
|
|
13
|
+
export declare class TREBGlobal {
|
|
14
|
+
|
|
15
|
+
/** TREB version */
|
|
16
|
+
version: string;
|
|
17
|
+
|
|
18
|
+
/** create a spreadsheet */
|
|
19
|
+
CreateSpreadsheet(options: EmbeddedSpreadsheetOptions): EmbeddedSpreadsheet;
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* options for saving files. we add the option for JSON formatting.
|
|
24
|
+
*/
|
|
25
|
+
export interface SaveOptions extends SerializeOptions {
|
|
26
|
+
|
|
27
|
+
/** pretty json formatting */
|
|
28
|
+
pretty?: boolean;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* options for the LoadDocument method
|
|
33
|
+
*/
|
|
34
|
+
export interface LoadDocumentOptions {
|
|
35
|
+
scroll?: string | ICellAddress;
|
|
36
|
+
flush?: boolean;
|
|
37
|
+
recalculate?: boolean;
|
|
38
|
+
override_sheet?: string;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* options for the GetRange method
|
|
43
|
+
*/
|
|
44
|
+
export interface GetRangeOptions {
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* return formatted values (apply number formats and return strings)
|
|
48
|
+
* @deprecated
|
|
49
|
+
*/
|
|
50
|
+
formatted?: boolean;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* return formulas instead of values. formula takes precedence over
|
|
54
|
+
* "formatted"; if you pass both, returned values will *not* be formatted.
|
|
55
|
+
* @deprecated
|
|
56
|
+
*
|
|
57
|
+
**/
|
|
58
|
+
formula?: boolean;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* optional style for returned values (replaces old flags).
|
|
62
|
+
*
|
|
63
|
+
* @remarks
|
|
64
|
+
*
|
|
65
|
+
* `formatted` returns formatted values, applying number formatting and
|
|
66
|
+
* returning strings. `formula` returns cell formulas instead of values.
|
|
67
|
+
*/
|
|
68
|
+
type?: 'formatted' | 'formula';
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* options for the SetRange method
|
|
73
|
+
*/
|
|
74
|
+
export interface SetRangeOptions {
|
|
75
|
+
|
|
76
|
+
/** transpose rectangular array before inserting */
|
|
77
|
+
transpose?: boolean;
|
|
78
|
+
|
|
79
|
+
/** recycle values (R-style) */
|
|
80
|
+
recycle?: boolean;
|
|
81
|
+
|
|
82
|
+
/** apply as an array (as if you pressed ctrl+shift+enter) */
|
|
83
|
+
array?: boolean;
|
|
84
|
+
|
|
85
|
+
/** spill over */
|
|
86
|
+
spill?: boolean;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* options for the ScrollTo method.
|
|
91
|
+
*
|
|
92
|
+
* @remarks
|
|
93
|
+
*
|
|
94
|
+
* this method was renamed because of a conflict with a DOM type,
|
|
95
|
+
* which was causing problems with the documentation generator.
|
|
96
|
+
*/
|
|
97
|
+
export interface SheetScrollOptions {
|
|
98
|
+
|
|
99
|
+
/** scroll in x-direction. defaults to true. */
|
|
100
|
+
x?: boolean;
|
|
101
|
+
|
|
102
|
+
/** scroll in y-direction. defaults to true. */
|
|
103
|
+
y?: boolean;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* smooth scrolling, if supported. we use scrollTo so support is as here:
|
|
107
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollTo
|
|
108
|
+
*/
|
|
109
|
+
smooth?: boolean;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* embedded spreadsheet
|
|
114
|
+
*/
|
|
115
|
+
export declare class EmbeddedSpreadsheet {
|
|
116
|
+
|
|
117
|
+
/** document name (metadata) */
|
|
118
|
+
get document_name(): string | undefined;
|
|
119
|
+
|
|
120
|
+
/** document name (metadata) */
|
|
121
|
+
set document_name(name: string | undefined);
|
|
122
|
+
|
|
123
|
+
/** opaque user data (metadata) */
|
|
124
|
+
get user_data(): unknown;
|
|
125
|
+
|
|
126
|
+
/** opaque user data (metadata) */
|
|
127
|
+
set user_data(data: unknown);
|
|
128
|
+
|
|
129
|
+
/** current grid scale */
|
|
130
|
+
get scale(): number;
|
|
131
|
+
|
|
132
|
+
/** current grid scale */
|
|
133
|
+
set scale(value: number);
|
|
134
|
+
|
|
135
|
+
/** headless state */
|
|
136
|
+
get headless(): boolean;
|
|
137
|
+
|
|
138
|
+
/** headless state */
|
|
139
|
+
set headless(value: boolean);
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* state is the current revision of the document. it is preserved any
|
|
143
|
+
* time the document is saved. it should be a consistent indication of
|
|
144
|
+
* the document version and can be used to compare versions.
|
|
145
|
+
*
|
|
146
|
+
* state is an atomically-incrementing integer but rolls over at 2^16.
|
|
147
|
+
*/
|
|
148
|
+
get state(): number;
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* indicates the current revision of the document is not equal to the
|
|
152
|
+
* last-saved revision of the document.
|
|
153
|
+
*/
|
|
154
|
+
get dirty(): boolean;
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Use this function to batch multiple document changes. Essentially the
|
|
158
|
+
* grid stops broadcasting events for the duration of the function call,
|
|
159
|
+
* and collects them instead. After the function call we update as necessary.
|
|
160
|
+
*
|
|
161
|
+
* @public
|
|
162
|
+
*/
|
|
163
|
+
Batch(func: () => void, paint?: boolean): Promise<void>;
|
|
164
|
+
|
|
165
|
+
/** set freeze area */
|
|
166
|
+
Freeze(rows?: number, columns?: number): void;
|
|
167
|
+
|
|
168
|
+
/** freeze at current selection */
|
|
169
|
+
FreezeSelection(): void;
|
|
170
|
+
|
|
171
|
+
/** return current freeze area */
|
|
172
|
+
GetFreeze(): FreezePane;
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Update theme from CSS. Because the spreadsheet is painted, not
|
|
176
|
+
* rendered, you need to notifiy us if external style (CSS) properties
|
|
177
|
+
* have changed. We will update and repaint.
|
|
178
|
+
*/
|
|
179
|
+
UpdateTheme(): void;
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Get sheet ID, by name (sheet name) or index. This may be useful for
|
|
183
|
+
* constructing references programatically.
|
|
184
|
+
*
|
|
185
|
+
* @remarks
|
|
186
|
+
*
|
|
187
|
+
* Sheet IDs are positive integers. IDs are ephemeral, they should not be
|
|
188
|
+
* retained after a document is closed or reloaded. They will likely (almost)
|
|
189
|
+
* always be the same, but that's not guaranteed, so don't rely on them.
|
|
190
|
+
*
|
|
191
|
+
* @param sheet - sheet name or index. sheet names are matched case-insensitively.
|
|
192
|
+
*
|
|
193
|
+
* @returns ID, or undefined if the index is not found (0 is not a valid
|
|
194
|
+
* sheet ID, so you can test for falsy).
|
|
195
|
+
*
|
|
196
|
+
* @public
|
|
197
|
+
*/
|
|
198
|
+
GetSheetID(sheet: string | number): number | undefined;
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Add a sheet, optionally named.
|
|
202
|
+
*/
|
|
203
|
+
AddSheet(name?: string): void;
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Insert an annotation node. Usually this means inserting a chart.
|
|
207
|
+
*
|
|
208
|
+
* @param formula - annotation formula. For charts, the chart formula.
|
|
209
|
+
* @param type - annotation type. Defaults to `treb-chart`.
|
|
210
|
+
* @param rect - coordinates, or a range reference for layout.
|
|
211
|
+
*/
|
|
212
|
+
InsertAnnotation(formula: string, type?: string, rect?: IRectangle | RangeReference): void;
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Insert an image. This method will open a file chooser and (if an image
|
|
216
|
+
* is selected) insert the image into the document.
|
|
217
|
+
*/
|
|
218
|
+
InsertImage(): void;
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Rename a sheet.
|
|
222
|
+
*
|
|
223
|
+
* @param index - old name or index of sheet. leave undefined to use
|
|
224
|
+
* current active sheet.
|
|
225
|
+
*
|
|
226
|
+
* @public
|
|
227
|
+
*/
|
|
228
|
+
RenameSheet(index: string | number | undefined, new_name: string): void;
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Delete a sheet.
|
|
232
|
+
*
|
|
233
|
+
* @param index - sheet name or index. Leave undefined to delete the active sheet.
|
|
234
|
+
*
|
|
235
|
+
* @public
|
|
236
|
+
*/
|
|
237
|
+
DeleteSheet(index?: string | number): void;
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Show or hide sheet. This is a replacement for the `ShowSheet` method,
|
|
241
|
+
* because that name is somewhat ambiguous.
|
|
242
|
+
*
|
|
243
|
+
* @param index - sheet name or index.
|
|
244
|
+
*
|
|
245
|
+
* @public
|
|
246
|
+
*/
|
|
247
|
+
HideSheet(index?: number | string, hide?: boolean): void;
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Show or hide sheet. This method is deprecated because it's ambiguous.
|
|
251
|
+
* To set a sheet's visibility, use `HideSheet`. To activate a sheet, use
|
|
252
|
+
* `ActivateSheet`.
|
|
253
|
+
*
|
|
254
|
+
* @param index - sheet name or index.
|
|
255
|
+
*
|
|
256
|
+
* @see HideSheet
|
|
257
|
+
* @deprecated Use `HideSheet` instead.
|
|
258
|
+
*/
|
|
259
|
+
ShowSheet(index?: number | string, show?: boolean): void;
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Activate sheet.
|
|
263
|
+
*
|
|
264
|
+
* @param index - sheet name or index.
|
|
265
|
+
*
|
|
266
|
+
* @public
|
|
267
|
+
*/
|
|
268
|
+
ActivateSheet(index: number | string): void;
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Set width of column(s).
|
|
272
|
+
*
|
|
273
|
+
* @param column - column, or columns (array), or undefined means all columns
|
|
274
|
+
* @param width - desired width (can be 0) or undefined means 'auto-size'
|
|
275
|
+
*
|
|
276
|
+
* @public
|
|
277
|
+
*/
|
|
278
|
+
SetColumnWidth(column?: number | number[], width?: number): void;
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Set height of row(s).
|
|
282
|
+
*
|
|
283
|
+
* @param row - row, or rows (array), or undefined means all rows
|
|
284
|
+
* @param height - desired height (can be 0) or undefined means 'auto-size'
|
|
285
|
+
*
|
|
286
|
+
* @public
|
|
287
|
+
*/
|
|
288
|
+
SetRowHeight(row?: number | number[], height?: number): void;
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Insert row(s).
|
|
292
|
+
*
|
|
293
|
+
* @param before_row - leave undefined to use current selection.
|
|
294
|
+
*
|
|
295
|
+
* @public
|
|
296
|
+
*/
|
|
297
|
+
InsertRows(before_row?: number, count?: number): void;
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Insert column(s).
|
|
301
|
+
*
|
|
302
|
+
* @param before_column - leave undefined to use current selection.
|
|
303
|
+
*
|
|
304
|
+
* @public
|
|
305
|
+
*/
|
|
306
|
+
InsertColumns(before_column?: number, count?: number): void;
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* Delete row(s).
|
|
310
|
+
*
|
|
311
|
+
* @param start_row - leave undefined to use current selection. in this
|
|
312
|
+
* case the `count` parameter will be ignored and all rows in the selection
|
|
313
|
+
* will be deleted.
|
|
314
|
+
*/
|
|
315
|
+
DeleteRows(start_row?: number, count?: number): void;
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* Delete columns(s).
|
|
319
|
+
*
|
|
320
|
+
* @param start_column - leave undefined to use current selection. in this
|
|
321
|
+
* case the `count` parameter will be ignored and all columns in the
|
|
322
|
+
* selection will be deleted.
|
|
323
|
+
*/
|
|
324
|
+
DeleteColumns(start_column?: number, count?: number): void;
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* Merge cells in range.
|
|
328
|
+
*
|
|
329
|
+
* @param range - target range. leave undefined to use current selection.
|
|
330
|
+
*
|
|
331
|
+
* @public
|
|
332
|
+
*/
|
|
333
|
+
MergeCells(range?: RangeReference): void;
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* Unmerge cells in range.
|
|
337
|
+
*
|
|
338
|
+
* @param range - target range. leave undefined to use current selection.
|
|
339
|
+
*
|
|
340
|
+
* @public
|
|
341
|
+
*/
|
|
342
|
+
UnmergeCells(range?: RangeReference): void;
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* Export to XLSX file.
|
|
346
|
+
*
|
|
347
|
+
* @remarks
|
|
348
|
+
*
|
|
349
|
+
* this requires a bunch of processing -- one, we do this in a worker, and
|
|
350
|
+
* two, it's demand loaded so we don't bloat up this embed script.
|
|
351
|
+
*/
|
|
352
|
+
Export(): void;
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* Focus the grid.
|
|
356
|
+
*
|
|
357
|
+
* @public
|
|
358
|
+
*/
|
|
359
|
+
Focus(): void;
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* Update layout and repaint if necessary.
|
|
363
|
+
*
|
|
364
|
+
* @remarks
|
|
365
|
+
*
|
|
366
|
+
* Call this method when the container is resized. It's not necessary
|
|
367
|
+
* if the resize is triggered by our resize handle, only if the container
|
|
368
|
+
* is resized externally.
|
|
369
|
+
*
|
|
370
|
+
* @public
|
|
371
|
+
*/
|
|
372
|
+
Resize(): void;
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* Clear/reset sheet. This will reset the undo stack as well,
|
|
376
|
+
* so it cannot be undone.
|
|
377
|
+
*
|
|
378
|
+
* @public
|
|
379
|
+
*/
|
|
380
|
+
Reset(): void;
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* load a document from from local storage, using the given key.
|
|
384
|
+
* this method will also set the local option for the storage key, so the
|
|
385
|
+
* document will potentially be saved on modification.
|
|
386
|
+
*/
|
|
387
|
+
LoadFromLocalStorage(key: string): boolean;
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* load a network document by URI. CORS headers must be set appropriately
|
|
391
|
+
* on documents originating from different hosts.
|
|
392
|
+
*/
|
|
393
|
+
LoadNetworkDocument(uri: string, options?: EmbeddedSpreadsheetOptions): Promise<void>;
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* Load a desktop file. This method will show a file chooser and open
|
|
397
|
+
* the selected file (if any).
|
|
398
|
+
*
|
|
399
|
+
* @public
|
|
400
|
+
*/
|
|
401
|
+
LoadLocalFile(): Promise<void>;
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* Export sheet as CSV/TSV. This is an internal method called by the save
|
|
405
|
+
* document methods, but you can call it directly if you want the text as
|
|
406
|
+
* a string.
|
|
407
|
+
*
|
|
408
|
+
* @returns string
|
|
409
|
+
*
|
|
410
|
+
* @public
|
|
411
|
+
*/
|
|
412
|
+
ExportDelimited(options?: ExportOptions): string;
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* Save the current document to a desktop file.
|
|
416
|
+
*
|
|
417
|
+
* @param filename Filename or extension to use the document name.
|
|
418
|
+
*
|
|
419
|
+
* @public
|
|
420
|
+
*/
|
|
421
|
+
SaveLocalFile(filename?: string, additional_options?: SaveOptions): void;
|
|
422
|
+
|
|
423
|
+
/**
|
|
424
|
+
* Load CSV from string. This is used internally when loading network
|
|
425
|
+
* documents and local files, but you can call it directly if you have
|
|
426
|
+
* a CSV file as text.
|
|
427
|
+
*
|
|
428
|
+
* @public
|
|
429
|
+
*/
|
|
430
|
+
LoadCSV(csv: string, source?: LoadSource): void;
|
|
431
|
+
|
|
432
|
+
/**
|
|
433
|
+
* get or set the current scroll offset. scroll offset is automatically
|
|
434
|
+
* saved if you save the document or switch tabs; this is for saving/
|
|
435
|
+
* restoring scroll if you cache the containing element.
|
|
436
|
+
*/
|
|
437
|
+
ScrollOffset(offset?: Point): Point | undefined;
|
|
438
|
+
|
|
439
|
+
/**
|
|
440
|
+
* unserialize document from data.
|
|
441
|
+
*
|
|
442
|
+
**/
|
|
443
|
+
LoadDocument(data: any, options?: LoadDocumentOptions): void;
|
|
444
|
+
|
|
445
|
+
/**
|
|
446
|
+
* Set note (comment) in cell.
|
|
447
|
+
*
|
|
448
|
+
* @param address target address, or leave undefined to use current selection.
|
|
449
|
+
* @param note note text, or leave undefined to clear existing note.
|
|
450
|
+
*/
|
|
451
|
+
SetNote(address: AddressReference | undefined, note?: string): void;
|
|
452
|
+
|
|
453
|
+
/**
|
|
454
|
+
* set or clear cell valiation.
|
|
455
|
+
*
|
|
456
|
+
* @param address - target cell
|
|
457
|
+
* @param validation - a spreadsheet range, list of data, or undefined. pass
|
|
458
|
+
* undefined to remove existing cell validation.
|
|
459
|
+
* @param error - setting an invalid value in the target cell is an error (and
|
|
460
|
+
* is blocked). defaults to false.
|
|
461
|
+
*/
|
|
462
|
+
SetValidation(address: AddressReference, validation?: RangeReference | CellValue[], error?: boolean): void;
|
|
463
|
+
|
|
464
|
+
/**
|
|
465
|
+
* Delete a macro function.
|
|
466
|
+
*
|
|
467
|
+
* @public
|
|
468
|
+
*/
|
|
469
|
+
RemoveFunction(name: string): void;
|
|
470
|
+
|
|
471
|
+
/**
|
|
472
|
+
* Create a macro function.
|
|
473
|
+
*
|
|
474
|
+
* @public
|
|
475
|
+
*/
|
|
476
|
+
DefineFunction(name: string, argument_names?: string | string[], function_def?: string): void;
|
|
477
|
+
|
|
478
|
+
/**
|
|
479
|
+
* Serialize document to a plain javascript object. The result is suitable
|
|
480
|
+
* for converting to JSON. This method is used by the SaveLocalFile and
|
|
481
|
+
* SaveLocalStorage methods, but you can call it directly if you want to
|
|
482
|
+
* save the document some other way.
|
|
483
|
+
*
|
|
484
|
+
* @public
|
|
485
|
+
*/
|
|
486
|
+
SerializeDocument(options?: SerializeOptions): any;
|
|
487
|
+
|
|
488
|
+
/**
|
|
489
|
+
* Recalculate sheet.
|
|
490
|
+
*
|
|
491
|
+
* @public
|
|
492
|
+
*/
|
|
493
|
+
Recalculate(): Promise<void>;
|
|
494
|
+
|
|
495
|
+
/**
|
|
496
|
+
* Save document to local storage.
|
|
497
|
+
*
|
|
498
|
+
* @param key optional storage key. if omitted, the method will use
|
|
499
|
+
* the key from local options (set at create time).
|
|
500
|
+
*/
|
|
501
|
+
SaveLocalStorage(key?: string | undefined): void;
|
|
502
|
+
|
|
503
|
+
/**
|
|
504
|
+
* Revert state one level from the undo stack.
|
|
505
|
+
*
|
|
506
|
+
* @public
|
|
507
|
+
*/
|
|
508
|
+
Undo(): void;
|
|
509
|
+
|
|
510
|
+
/**
|
|
511
|
+
* Show the about dialog.
|
|
512
|
+
*
|
|
513
|
+
* @public
|
|
514
|
+
*/
|
|
515
|
+
About(): void;
|
|
516
|
+
|
|
517
|
+
/**
|
|
518
|
+
* Scroll to the given address. In the current implementation this method
|
|
519
|
+
* will not change sheets, although it probably should if the reference
|
|
520
|
+
* is to a different sheet.
|
|
521
|
+
*
|
|
522
|
+
* @public
|
|
523
|
+
*/
|
|
524
|
+
ScrollTo(address: AddressReference, options?: SheetScrollOptions): void;
|
|
525
|
+
|
|
526
|
+
/**
|
|
527
|
+
* Resolve a string address/range to an address or area (range) object.
|
|
528
|
+
*
|
|
529
|
+
* @param reference A string like "A1" or "Sheet1!B2:C3". If a sheet name
|
|
530
|
+
* is not included, the current active sheet is used. You can also pass a
|
|
531
|
+
* named range as reference.
|
|
532
|
+
*
|
|
533
|
+
* @public
|
|
534
|
+
*/
|
|
535
|
+
Resolve(reference: string): ICellAddress | IArea | undefined;
|
|
536
|
+
|
|
537
|
+
/**
|
|
538
|
+
* Evaluate an arbitrary expression in the spreadsheet. You should generally
|
|
539
|
+
* use sheet names when referring to cells, to avoid ambiguity. Otherwise
|
|
540
|
+
* cell references will resolve to the active sheet.
|
|
541
|
+
*
|
|
542
|
+
* @public
|
|
543
|
+
*/
|
|
544
|
+
Evaluate(expression: string): CellValue | CellValue[][];
|
|
545
|
+
|
|
546
|
+
/**
|
|
547
|
+
* Returns the current selection, as a string address or range.
|
|
548
|
+
*
|
|
549
|
+
* @param qualified include sheet name in result. default true.
|
|
550
|
+
*
|
|
551
|
+
* @returns selection as a string, or empty string if there's no selection.
|
|
552
|
+
*
|
|
553
|
+
* @public
|
|
554
|
+
*/
|
|
555
|
+
GetSelection(qualified?: boolean): string;
|
|
556
|
+
|
|
557
|
+
/**
|
|
558
|
+
* Parse a string and return a number (if possible).
|
|
559
|
+
*
|
|
560
|
+
* @public
|
|
561
|
+
*/
|
|
562
|
+
ParseNumber(text: string): number | Complex | boolean | string | undefined;
|
|
563
|
+
|
|
564
|
+
/**
|
|
565
|
+
* Format a number with an arbitrary formatter.
|
|
566
|
+
*
|
|
567
|
+
* @public
|
|
568
|
+
*/
|
|
569
|
+
FormatNumber(value: number, format?: string): string;
|
|
570
|
+
|
|
571
|
+
/**
|
|
572
|
+
* Apply borders to range.
|
|
573
|
+
*
|
|
574
|
+
* @param range pass `undefined` as range to apply to current selection.
|
|
575
|
+
*
|
|
576
|
+
* @remarks
|
|
577
|
+
*
|
|
578
|
+
* Borders are part of style, but setting/removing borders is more
|
|
579
|
+
* complicated than setting other style properties. usually you want
|
|
580
|
+
* things to apply to ranges, rather than individual cells. removing
|
|
581
|
+
* borders needs to consider neighbor borders. and so on.
|
|
582
|
+
*
|
|
583
|
+
* @public
|
|
584
|
+
*/
|
|
585
|
+
ApplyBorders(range: RangeReference | undefined, borders: BorderConstants, width?: number): void;
|
|
586
|
+
|
|
587
|
+
/**
|
|
588
|
+
* Apply style to range.
|
|
589
|
+
*
|
|
590
|
+
* @param range pass `undefined` as range to apply to current selection.
|
|
591
|
+
* @param delta apply over existing properties. default true.
|
|
592
|
+
*
|
|
593
|
+
* @remarks
|
|
594
|
+
*
|
|
595
|
+
* Don't use this method to set borders, use `ApplyBorders`.
|
|
596
|
+
*
|
|
597
|
+
* @public
|
|
598
|
+
*/
|
|
599
|
+
ApplyStyle(range?: RangeReference, style?: Style.Properties, delta?: boolean): void;
|
|
600
|
+
|
|
601
|
+
/**
|
|
602
|
+
* Remove a named range (removes the name, not the range).
|
|
603
|
+
*
|
|
604
|
+
* @public
|
|
605
|
+
*/
|
|
606
|
+
ClearName(name: string): void;
|
|
607
|
+
|
|
608
|
+
/**
|
|
609
|
+
* Create a named range.
|
|
610
|
+
*
|
|
611
|
+
* @param range leave undefined to use current selection
|
|
612
|
+
*
|
|
613
|
+
* @public
|
|
614
|
+
*/
|
|
615
|
+
DefineName(name: string, range?: RangeReference): void;
|
|
616
|
+
|
|
617
|
+
/**
|
|
618
|
+
* Set or remove a link in a cell.
|
|
619
|
+
*
|
|
620
|
+
* @param target http/https URL or a spreadsheet reference (as text). set blank to remove link.
|
|
621
|
+
*
|
|
622
|
+
* @public
|
|
623
|
+
*/
|
|
624
|
+
SetLink(address?: AddressReference, target?: string): void;
|
|
625
|
+
|
|
626
|
+
/**
|
|
627
|
+
* Select a range.
|
|
628
|
+
*
|
|
629
|
+
* @public
|
|
630
|
+
*/
|
|
631
|
+
Select(range: RangeReference): void;
|
|
632
|
+
|
|
633
|
+
/**
|
|
634
|
+
*
|
|
635
|
+
* @param range target range. leave undefined to use current selection.
|
|
636
|
+
*
|
|
637
|
+
* @public
|
|
638
|
+
*/
|
|
639
|
+
GetRange(range?: RangeReference, options?: GetRangeOptions): CellValue | CellValue[][] | undefined;
|
|
640
|
+
|
|
641
|
+
/**
|
|
642
|
+
* returns the style from the target address or range.
|
|
643
|
+
*
|
|
644
|
+
* @param range - target range. leave undefined to use current selection
|
|
645
|
+
* @param apply_theme - include theme defaults when returning style
|
|
646
|
+
*
|
|
647
|
+
*/
|
|
648
|
+
GetStyle(range?: RangeReference, apply_theme?: boolean): Style.Properties | Style.Properties[][] | undefined;
|
|
649
|
+
|
|
650
|
+
/**
|
|
651
|
+
* Set data in range.
|
|
652
|
+
*
|
|
653
|
+
* @param range target range. leave undefined to use current selection.
|
|
654
|
+
*
|
|
655
|
+
* @public
|
|
656
|
+
*/
|
|
657
|
+
SetRange(range?: RangeReference, data?: CellValue | CellValue[][], options?: SetRangeOptions): void;
|
|
658
|
+
|
|
659
|
+
/**
|
|
660
|
+
* Subscribe to spreadsheet events
|
|
661
|
+
* @param subscriber - callback function
|
|
662
|
+
* @returns a token used to cancel the subscription
|
|
663
|
+
*/
|
|
664
|
+
Subscribe(subscriber: (event: EmbeddedSheetEvent) => void): number;
|
|
665
|
+
|
|
666
|
+
/**
|
|
667
|
+
* Cancel subscription
|
|
668
|
+
* @param token - the token returned from `Subscribe`
|
|
669
|
+
*/
|
|
670
|
+
Cancel(token: number): void;
|
|
671
|
+
}
|
|
672
|
+
export interface FreezePane {
|
|
673
|
+
rows: number;
|
|
674
|
+
columns: number;
|
|
675
|
+
}
|
|
676
|
+
export declare type BorderConstants = "none" | "all" | "outside" | "top" | "bottom" | "left" | "right" | "double-top" | "double-bottom";
|
|
677
|
+
|
|
678
|
+
/**
|
|
679
|
+
* options for serializing data
|
|
680
|
+
*
|
|
681
|
+
**/
|
|
682
|
+
export interface SerializeOptions {
|
|
683
|
+
|
|
684
|
+
/** optimize for size */
|
|
685
|
+
optimize?: 'size' | 'speed';
|
|
686
|
+
|
|
687
|
+
/** include the rendered/calculated value in export */
|
|
688
|
+
rendered_values?: boolean;
|
|
689
|
+
|
|
690
|
+
/** translate colors to xlsx-friendly values */
|
|
691
|
+
export_colors?: boolean;
|
|
692
|
+
|
|
693
|
+
/** export cells that have no value, but have a border or background color */
|
|
694
|
+
decorated_cells?: boolean;
|
|
695
|
+
|
|
696
|
+
/** prune unused rows/columns */
|
|
697
|
+
shrink?: boolean;
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
/**
|
|
701
|
+
* Structure represents a cell address. Note that row and column are 0-based.
|
|
702
|
+
*/
|
|
703
|
+
export interface ICellAddress {
|
|
704
|
+
|
|
705
|
+
/** 0-based row */
|
|
706
|
+
row: number;
|
|
707
|
+
|
|
708
|
+
/** 0-based column */
|
|
709
|
+
column: number;
|
|
710
|
+
absolute_row?: boolean;
|
|
711
|
+
absolute_column?: boolean;
|
|
712
|
+
sheet_id?: number;
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
/**
|
|
716
|
+
* Structure represents a 2d range of cells.
|
|
717
|
+
*
|
|
718
|
+
**/
|
|
719
|
+
export interface IArea {
|
|
720
|
+
start: ICellAddress;
|
|
721
|
+
end: ICellAddress;
|
|
722
|
+
}
|
|
723
|
+
export interface Point {
|
|
724
|
+
x: number;
|
|
725
|
+
y: number;
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
/** structure represents rectangle coordinates */
|
|
729
|
+
export interface IRectangle {
|
|
730
|
+
top: number;
|
|
731
|
+
left: number;
|
|
732
|
+
width: number;
|
|
733
|
+
height: number;
|
|
734
|
+
}
|
|
735
|
+
export declare namespace Style {
|
|
736
|
+
|
|
737
|
+
/**
|
|
738
|
+
* horizontal align constants
|
|
739
|
+
*/ type HorizontalAlign = "" | "left" | "center" | "right";
|
|
740
|
+
|
|
741
|
+
/**
|
|
742
|
+
* vertical align constants
|
|
743
|
+
*
|
|
744
|
+
**/ type VerticalAlign = "" | "top" | "bottom" | "middle";
|
|
745
|
+
|
|
746
|
+
/** composite font size */
|
|
747
|
+
interface FontSize {
|
|
748
|
+
unit: 'pt' | 'px' | 'em' | '%';
|
|
749
|
+
value: number;
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
/**
|
|
753
|
+
* color is either a theme color (theme index plus tint), or CSS text
|
|
754
|
+
*
|
|
755
|
+
**/
|
|
756
|
+
interface Color {
|
|
757
|
+
theme?: number;
|
|
758
|
+
tint?: number;
|
|
759
|
+
text?: string;
|
|
760
|
+
|
|
761
|
+
/** @deprecated */
|
|
762
|
+
none?: boolean;
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
/**
|
|
766
|
+
* style properties applied to a cell.
|
|
767
|
+
*/
|
|
768
|
+
interface Properties {
|
|
769
|
+
|
|
770
|
+
/** horizontal align defaults to left */
|
|
771
|
+
horizontal_align?: HorizontalAlign;
|
|
772
|
+
|
|
773
|
+
/** vertical align defaults to bottom */
|
|
774
|
+
vertical_align?: VerticalAlign;
|
|
775
|
+
|
|
776
|
+
/** representation for NaN */
|
|
777
|
+
nan?: string;
|
|
778
|
+
|
|
779
|
+
/** number format, either a symbolic name like "General" or a format string */
|
|
780
|
+
number_format?: string;
|
|
781
|
+
|
|
782
|
+
/** wrap text */
|
|
783
|
+
wrap?: boolean;
|
|
784
|
+
|
|
785
|
+
/**
|
|
786
|
+
* font size. we recommend using relative font sizes (either % or em)
|
|
787
|
+
* which will be relative to the theme font size.
|
|
788
|
+
*/
|
|
789
|
+
font_size?: FontSize;
|
|
790
|
+
|
|
791
|
+
/** font face. this can be a comma-delimited list, like CSS */
|
|
792
|
+
font_face?: string;
|
|
793
|
+
|
|
794
|
+
/** flag */
|
|
795
|
+
bold?: boolean;
|
|
796
|
+
|
|
797
|
+
/** flag */
|
|
798
|
+
italic?: boolean;
|
|
799
|
+
|
|
800
|
+
/** flag */
|
|
801
|
+
underline?: boolean;
|
|
802
|
+
|
|
803
|
+
/** flag */
|
|
804
|
+
strike?: boolean;
|
|
805
|
+
|
|
806
|
+
/** border weight */
|
|
807
|
+
border_top?: number;
|
|
808
|
+
|
|
809
|
+
/** border weight */
|
|
810
|
+
border_right?: number;
|
|
811
|
+
|
|
812
|
+
/** border weight */
|
|
813
|
+
border_left?: number;
|
|
814
|
+
|
|
815
|
+
/** border weight */
|
|
816
|
+
border_bottom?: number;
|
|
817
|
+
|
|
818
|
+
/** text color */
|
|
819
|
+
text?: Color;
|
|
820
|
+
|
|
821
|
+
/** background color */
|
|
822
|
+
fill?: Color;
|
|
823
|
+
|
|
824
|
+
/** border color */
|
|
825
|
+
border_top_fill?: Color;
|
|
826
|
+
|
|
827
|
+
/** border color */
|
|
828
|
+
border_left_fill?: Color;
|
|
829
|
+
|
|
830
|
+
/** border color */
|
|
831
|
+
border_right_fill?: Color;
|
|
832
|
+
|
|
833
|
+
/** border color */
|
|
834
|
+
border_bottom_fill?: Color;
|
|
835
|
+
|
|
836
|
+
/**
|
|
837
|
+
* cell is locked for editing
|
|
838
|
+
*/
|
|
839
|
+
locked?: boolean;
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
export declare type CellValue = undefined | string | number | boolean | Complex | DimensionedQuantity;
|
|
843
|
+
|
|
844
|
+
/**
|
|
845
|
+
* Complex number type
|
|
846
|
+
*/
|
|
847
|
+
export interface Complex {
|
|
848
|
+
real: number;
|
|
849
|
+
imaginary: number;
|
|
850
|
+
}
|
|
851
|
+
export interface DimensionedQuantity {
|
|
852
|
+
value: number;
|
|
853
|
+
unit: string;
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
/**
|
|
857
|
+
* type represents a reference passed in to API functions. it can be an
|
|
858
|
+
* address object, or a string.
|
|
859
|
+
*/
|
|
860
|
+
export declare type AddressReference = string | ICellAddress;
|
|
861
|
+
|
|
862
|
+
/**
|
|
863
|
+
* type represents a reference passed in to API functions. it can be an
|
|
864
|
+
* address object, an area (range) object, or a string.
|
|
865
|
+
*/
|
|
866
|
+
export declare type RangeReference = string | ICellAddress | IArea;
|
|
867
|
+
|
|
868
|
+
/**
|
|
869
|
+
* options for exporting CSV/TSV
|
|
870
|
+
*/
|
|
871
|
+
export interface ExportOptions {
|
|
872
|
+
|
|
873
|
+
/** comma or tab */
|
|
874
|
+
delimiter?: ',' | '\t';
|
|
875
|
+
|
|
876
|
+
/** optionally choose a sheet to export (defaults to active sheet) */
|
|
877
|
+
sheet?: string | number;
|
|
878
|
+
|
|
879
|
+
/** export formulas not values */
|
|
880
|
+
formulas?: boolean;
|
|
881
|
+
|
|
882
|
+
/** use number formats when exporting numbers */
|
|
883
|
+
formatted?: boolean;
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
/**
|
|
887
|
+
* options for creating spreadsheet
|
|
888
|
+
*/
|
|
889
|
+
export interface EmbeddedSpreadsheetOptions {
|
|
890
|
+
|
|
891
|
+
/** containing HTML element */
|
|
892
|
+
container?: string | HTMLElement;
|
|
893
|
+
|
|
894
|
+
/** allow drag-and-drop files */
|
|
895
|
+
dnd?: boolean;
|
|
896
|
+
|
|
897
|
+
/** expandable grid */
|
|
898
|
+
expand?: boolean;
|
|
899
|
+
|
|
900
|
+
/** key in localStorage for persisting document */
|
|
901
|
+
storage_key?: string;
|
|
902
|
+
|
|
903
|
+
/** don't load immediately (?) */
|
|
904
|
+
toll_initial_load?: boolean;
|
|
905
|
+
|
|
906
|
+
/** show formula bar */
|
|
907
|
+
formula_bar?: boolean;
|
|
908
|
+
|
|
909
|
+
/** expand formula bar */
|
|
910
|
+
expand_formula_button?: boolean;
|
|
911
|
+
|
|
912
|
+
/** scroll to cell on load */
|
|
913
|
+
scroll?: string | ICellAddress;
|
|
914
|
+
|
|
915
|
+
/** sheet to show on load, overrides anything in the model */
|
|
916
|
+
sheet?: string;
|
|
917
|
+
|
|
918
|
+
/** add resizable wrapper */
|
|
919
|
+
resizable?: boolean;
|
|
920
|
+
|
|
921
|
+
/** export to xlsx, now optional */
|
|
922
|
+
export?: boolean;
|
|
923
|
+
|
|
924
|
+
/** fill container */
|
|
925
|
+
auto_size?: boolean;
|
|
926
|
+
|
|
927
|
+
/** popout icon */
|
|
928
|
+
popout?: boolean;
|
|
929
|
+
|
|
930
|
+
/** fetch network document (URI) */
|
|
931
|
+
network_document?: string;
|
|
932
|
+
|
|
933
|
+
/** load this document if the storage document isn't found (fallback) */
|
|
934
|
+
alternate_document?: string;
|
|
935
|
+
|
|
936
|
+
/** freeze rows */
|
|
937
|
+
freeze_rows?: number;
|
|
938
|
+
|
|
939
|
+
/** freeze columns */
|
|
940
|
+
freeze_columns?: number;
|
|
941
|
+
|
|
942
|
+
/** row/column headers */
|
|
943
|
+
headers?: boolean;
|
|
944
|
+
|
|
945
|
+
/** recalculate on load */
|
|
946
|
+
recalculate?: boolean;
|
|
947
|
+
|
|
948
|
+
/** show scrollbars */
|
|
949
|
+
scrollbars?: boolean;
|
|
950
|
+
|
|
951
|
+
/** show tab bar (multi sheet) */
|
|
952
|
+
tab_bar?: boolean | 'auto';
|
|
953
|
+
|
|
954
|
+
/** allow add tab */
|
|
955
|
+
add_tab?: boolean;
|
|
956
|
+
|
|
957
|
+
/** show delete tab */
|
|
958
|
+
delete_tab?: boolean;
|
|
959
|
+
|
|
960
|
+
/** set a reference in global (self) */
|
|
961
|
+
global_name?: string;
|
|
962
|
+
|
|
963
|
+
/** support undo */
|
|
964
|
+
undo?: boolean;
|
|
965
|
+
|
|
966
|
+
/** support in-cell editor */
|
|
967
|
+
in_cell_editor?: boolean;
|
|
968
|
+
|
|
969
|
+
/** prompt "you have unsaved changes" */
|
|
970
|
+
prompt_save?: boolean;
|
|
971
|
+
|
|
972
|
+
/**
|
|
973
|
+
* toolbar display option
|
|
974
|
+
*/
|
|
975
|
+
toolbar?: boolean | 'show' | 'narrow' | 'show-narrow';
|
|
976
|
+
|
|
977
|
+
/** file options in the toolbar */
|
|
978
|
+
file_menu?: boolean;
|
|
979
|
+
|
|
980
|
+
/** font size in the toolbar */
|
|
981
|
+
font_scale?: boolean;
|
|
982
|
+
|
|
983
|
+
/** chart menu in the toolbar */
|
|
984
|
+
chart_menu?: boolean;
|
|
985
|
+
|
|
986
|
+
/** recalculate button in the toolbar */
|
|
987
|
+
toolbar_recalculate_button?: boolean;
|
|
988
|
+
|
|
989
|
+
/** new option, better support for headless operations (default false) */
|
|
990
|
+
headless?: boolean;
|
|
991
|
+
|
|
992
|
+
/** max size for image, in bytes */
|
|
993
|
+
max_file_size?: number;
|
|
994
|
+
|
|
995
|
+
/** initial scale */
|
|
996
|
+
scale?: number;
|
|
997
|
+
|
|
998
|
+
/** show scale buttons */
|
|
999
|
+
scale_control?: boolean;
|
|
1000
|
+
|
|
1001
|
+
/** show stats panel */
|
|
1002
|
+
stats?: boolean;
|
|
1003
|
+
|
|
1004
|
+
/** save/load scale. this can optionally have a string key to disambiguate */
|
|
1005
|
+
persist_scale?: boolean | string;
|
|
1006
|
+
|
|
1007
|
+
/** target window for hyperlinks (default _blank); set false to disable hyperlinks altogether */
|
|
1008
|
+
hyperlinks?: string | false;
|
|
1009
|
+
|
|
1010
|
+
/**
|
|
1011
|
+
* for rendering the imaginary number. this is intended to support
|
|
1012
|
+
* switching to a different character for rendering, or adding a leading
|
|
1013
|
+
* space/half-space/hair-space.
|
|
1014
|
+
*/
|
|
1015
|
+
imaginary_value?: string;
|
|
1016
|
+
|
|
1017
|
+
/** support MD formatting for text */
|
|
1018
|
+
markdown?: boolean;
|
|
1019
|
+
|
|
1020
|
+
/** show tinted colors in toolbar color dropdowns */
|
|
1021
|
+
tint_theme_colors?: boolean;
|
|
1022
|
+
|
|
1023
|
+
/** show a spinner for long-running operations */
|
|
1024
|
+
spinner?: boolean;
|
|
1025
|
+
}
|
|
1026
|
+
export declare type LoadSource = "drag-and-drop" | "local-file" | "network-file" | "local-storage" | "undo";
|
|
1027
|
+
|
|
1028
|
+
/**
|
|
1029
|
+
* EmbeddedSheetEvent is a discriminated union. Switch on the `type` field
|
|
1030
|
+
* of the event.
|
|
1031
|
+
*/
|
|
1032
|
+
export declare type EmbeddedSheetEvent = DocumentChangeEvent | DocumentResetEvent | DocumentLoadEvent | DataChangeEvent | SelectionEvent | ResizeEvent;
|
|
1033
|
+
export interface ResizeEvent {
|
|
1034
|
+
type: 'resize';
|
|
1035
|
+
}
|
|
1036
|
+
export declare type LoadType = "treb" | "csv" | "xlsx";
|
|
1037
|
+
|
|
1038
|
+
/**
|
|
1039
|
+
* This event is sent when a document is loaded, and also on undo. The
|
|
1040
|
+
* source field can help determine if it was triggered by an undo operation.
|
|
1041
|
+
*/
|
|
1042
|
+
export interface DocumentLoadEvent {
|
|
1043
|
+
type: 'load';
|
|
1044
|
+
source?: LoadSource;
|
|
1045
|
+
file_type?: LoadType;
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
/**
|
|
1049
|
+
* This event is sent when the document is reset.
|
|
1050
|
+
*
|
|
1051
|
+
**/
|
|
1052
|
+
export interface DocumentResetEvent {
|
|
1053
|
+
type: 'reset';
|
|
1054
|
+
}
|
|
1055
|
+
|
|
1056
|
+
/**
|
|
1057
|
+
* This event is sent when data in the spreadsheet changes, but there are
|
|
1058
|
+
* no structural or cell changes. For example, the `RAND` function returns
|
|
1059
|
+
* a new value on every calculation, but the function itself does not change.
|
|
1060
|
+
*/
|
|
1061
|
+
export interface DataChangeEvent {
|
|
1062
|
+
type: 'data';
|
|
1063
|
+
}
|
|
1064
|
+
|
|
1065
|
+
/**
|
|
1066
|
+
* This event is sent when the value of a cell changes, or when the document
|
|
1067
|
+
* structure chages. Structure changes might be inserting/deleting rows or
|
|
1068
|
+
* columns, or adding/removing a sheet.
|
|
1069
|
+
*/
|
|
1070
|
+
export interface DocumentChangeEvent {
|
|
1071
|
+
type: 'document-change';
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1074
|
+
/**
|
|
1075
|
+
* This event is sent when the spreadsheet selection changes. Use the
|
|
1076
|
+
* `GetSelection` method to get the address of the current selection.
|
|
1077
|
+
*/
|
|
1078
|
+
export interface SelectionEvent {
|
|
1079
|
+
type: 'selection';
|
|
1080
|
+
}
|