@lexaxai/spreadsheet-engine 0.0.0-stage → 0.1.0-dryrun.1

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.
@@ -0,0 +1,432 @@
1
+ // A worksheet's and a workbook's settings: views, properties, columns as
2
+ // defined, protection, the AutoFilter and calculation.
3
+
4
+ import type { HeaderFooter, PageSetup } from './page';
5
+ import type { Color, Style } from './styles';
6
+ import type { CellValue } from './values';
7
+
8
+ /**
9
+ * The options every worksheet view has, whatever its state. Used by `WorksheetView`.
10
+ */
11
+ export interface WorksheetViewCommon {
12
+ /**
13
+ * Sets the worksheet view's orientation to right-to-left, `false` by default
14
+ */
15
+ rightToLeft: boolean;
16
+
17
+ /**
18
+ * The currently selected cell
19
+ */
20
+ activeCell: string;
21
+
22
+ /**
23
+ * Shows or hides the ruler in Page Layout, `true` by default
24
+ */
25
+ showRuler: boolean;
26
+
27
+ /**
28
+ * Shows or hides the row and column headers (for example A1, B1 at the top and 1,2,3 on the left,
29
+ * `true` by default
30
+ */
31
+ showRowColHeaders: boolean;
32
+
33
+ /**
34
+ * Shows or hides the gridlines (shown for cells where borders have not been defined),
35
+ * `true` by default
36
+ */
37
+ showGridLines: boolean;
38
+
39
+ /**
40
+ * Percentage zoom to use for the view, `100` by default
41
+ */
42
+ zoomScale: number;
43
+
44
+ /**
45
+ * Normal zoom for the view, `100` by default
46
+ */
47
+ zoomScaleNormal: number;
48
+ }
49
+
50
+ /**
51
+ * A worksheet view in the normal state, with no frozen or split panes. Used by `WorksheetView`.
52
+ */
53
+ export interface WorksheetViewNormal {
54
+ /**
55
+ * Controls the view state
56
+ */
57
+ state: 'normal';
58
+
59
+ /**
60
+ * Presentation style
61
+ */
62
+ style: 'pageBreakPreview' | 'pageLayout';
63
+ }
64
+
65
+ /**
66
+ * A worksheet view with rows or columns frozen in place, as Freeze Panes sets them. Used by `WorksheetView`.
67
+ */
68
+ export interface WorksheetViewFrozen {
69
+ /**
70
+ * Where a number of rows and columns to the top and left are frozen in place.
71
+ * Only the bottom left section will scroll
72
+ */
73
+ state: 'frozen';
74
+
75
+ /**
76
+ * Presentation style
77
+ */
78
+ style?: 'pageBreakPreview';
79
+
80
+ /**
81
+ * How many columns to freeze. To freeze rows only, set this to 0 or undefined
82
+ */
83
+ xSplit?: number;
84
+
85
+ /**
86
+ * How many rows to freeze. To freeze columns only, set this to 0 or undefined
87
+ */
88
+ ySplit?: number;
89
+
90
+ /**
91
+ * Which cell will be top-left in the bottom-right pane. Note: cannot be a frozen cell.
92
+ * Defaults to first unfrozen cell
93
+ */
94
+ topLeftCell?: string;
95
+ }
96
+
97
+ /**
98
+ * A worksheet view split into up to four panes, each of which scrolls on its own. Used by `WorksheetView`.
99
+ */
100
+ export interface WorksheetViewSplit {
101
+ /**
102
+ * Where the view is split into 4 sections, each semi-independently scrollable.
103
+ */
104
+ state: 'split';
105
+
106
+ /**
107
+ * Presentation style
108
+ */
109
+ style?: 'pageBreakPreview' | 'pageLayout';
110
+
111
+ /**
112
+ * How many points from the left to place the splitter.
113
+ * To split vertically, set this to 0 or undefined
114
+ */
115
+ xSplit?: number;
116
+
117
+ /**
118
+ * How many points from the top to place the splitter.
119
+ * To split horizontally, set this to 0 or undefined
120
+ */
121
+ ySplit?: number;
122
+
123
+ /**
124
+ * Which cell will be top-left in the bottom-right pane
125
+ */
126
+ topLeftCell?: string;
127
+
128
+ /**
129
+ * Which pane will be active
130
+ */
131
+ activePane?: 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight';
132
+ }
133
+
134
+ /**
135
+ * A worksheet's view: its state, `normal`, `frozen` or `split`, with the options every view has. Set in
136
+ * `Worksheet.views`.
137
+ */
138
+ export type WorksheetView =
139
+ & WorksheetViewCommon
140
+ & (WorksheetViewNormal | WorksheetViewFrozen | WorksheetViewSplit);
141
+
142
+ /**
143
+ * The position and size of a workbook window, and which worksheet tab is active. Held in `Workbook.views`.
144
+ */
145
+ export interface WorkbookView {
146
+ /**
147
+ * The horizontal position of the workbook window.
148
+ */
149
+ x: number;
150
+ /**
151
+ * The vertical position of the workbook window.
152
+ */
153
+ y: number;
154
+ /**
155
+ * The width of the workbook window.
156
+ */
157
+ width: number;
158
+ /**
159
+ * The height of the workbook window.
160
+ */
161
+ height: number;
162
+ /**
163
+ * The index of the first worksheet tab shown in the tab bar.
164
+ */
165
+ firstSheet: number;
166
+ /**
167
+ * The index of the active worksheet tab.
168
+ */
169
+ activeTab: number;
170
+ /**
171
+ * The visibility of the workbook window, such as `visible` or `hidden`.
172
+ */
173
+ visibility: string;
174
+ }
175
+
176
+ /**
177
+ * The state of a worksheet: visible, hidden (listed by Excel's Unhide dialog box), or veryHidden (left out of
178
+ * that dialog box, so shown only by code).
179
+ */
180
+ export type WorksheetState = 'visible' | 'hidden' | 'veryHidden';
181
+
182
+ /**
183
+ * The properties of a worksheet: its tab color, its outline levels and summary rows and columns, and its
184
+ * default row height and column width.
185
+ */
186
+ export interface WorksheetProperties {
187
+ /**
188
+ * Color of the tab
189
+ */
190
+ tabColor: Partial<Color>;
191
+
192
+ /**
193
+ * The worksheet column outline level (default: 0)
194
+ */
195
+ outlineLevelCol: number;
196
+
197
+ /**
198
+ * The worksheet row outline level (default: 0)
199
+ */
200
+ outlineLevelRow: number;
201
+
202
+ /**
203
+ * The outline properties which controls how it will summarize rows and columns
204
+ */
205
+ outlineProperties: {
206
+ summaryBelow: boolean,
207
+ summaryRight: boolean,
208
+ };
209
+ /**
210
+ * Default row height (default: 15)
211
+ */
212
+ defaultRowHeight: number;
213
+
214
+ /**
215
+ * Default column width (optional)
216
+ */
217
+ defaultColWidth?: number;
218
+
219
+ /**
220
+ * default: 55
221
+ */
222
+ dyDescent: number;
223
+ showGridLines: boolean;
224
+ }
225
+
226
+ /**
227
+ * A column as `Worksheet.columns` defines it: its header, the key that names it in the objects `addRow`
228
+ * takes, and its look.
229
+ */
230
+ export interface ColumnDefinition {
231
+ /**
232
+ * The column's header: one value, or several written down from row 1.
233
+ */
234
+ header?: CellValue | CellValue[];
235
+ /**
236
+ * The key that names the column in the objects `addRow` takes.
237
+ */
238
+ key?: string;
239
+ /**
240
+ * The width of the column in characters.
241
+ */
242
+ width?: number;
243
+ /**
244
+ * The style of the column's cells.
245
+ */
246
+ style?: Partial<Style>;
247
+ /**
248
+ * Whether the column is hidden.
249
+ */
250
+ hidden?: boolean;
251
+ /**
252
+ * The column's outline level, 0 to 7.
253
+ */
254
+ outlineLevel?: number;
255
+ /**
256
+ * The column's number from 1, as a streamed worksheet's `columns` gives it; not read when defining.
257
+ */
258
+ number?: number;
259
+ }
260
+
261
+ /**
262
+ * The options Workbook.addWorksheet takes. Each one left out takes its default.
263
+ */
264
+ export interface AddWorksheetOptions {
265
+ /**
266
+ * The properties of the new worksheet, as WorksheetProperties.
267
+ */
268
+ properties: Partial<WorksheetProperties>;
269
+ /**
270
+ * The page setup of the new worksheet.
271
+ */
272
+ pageSetup: Partial<PageSetup>;
273
+ /**
274
+ * The header and footer the new worksheet prints with.
275
+ */
276
+ headerFooter: Partial<HeaderFooter>;
277
+ /**
278
+ * The views of the new worksheet, each a pane and its settings.
279
+ */
280
+ views: Array<Partial<WorksheetView>>;
281
+ /**
282
+ * The state of the new worksheet, as WorksheetState. Visible by default.
283
+ */
284
+ state: WorksheetState;
285
+ }
286
+
287
+ /**
288
+ * The options of a worksheet's protection: which actions stay allowed while the worksheet is protected. Given
289
+ * to `Worksheet.protect`; each left out takes its default.
290
+ */
291
+ export interface WorksheetProtection {
292
+ /**
293
+ * Whether users may edit objects while the worksheet is protected, `false` by default.
294
+ */
295
+ objects?: boolean;
296
+ /**
297
+ * Whether users may edit scenarios while the worksheet is protected, `false` by default.
298
+ */
299
+ scenarios?: boolean;
300
+ /**
301
+ * Whether users may select locked cells while the worksheet is protected, `true` by default.
302
+ */
303
+ selectLockedCells?: boolean;
304
+ /**
305
+ * Whether users may select unlocked cells while the worksheet is protected, `true` by default.
306
+ */
307
+ selectUnlockedCells?: boolean;
308
+ /**
309
+ * Whether users may format cells while the worksheet is protected, `false` by default.
310
+ */
311
+ formatCells?: boolean;
312
+ /**
313
+ * Whether users may format columns while the worksheet is protected, `false` by default.
314
+ */
315
+ formatColumns?: boolean;
316
+ /**
317
+ * Whether users may format rows while the worksheet is protected, `false` by default.
318
+ */
319
+ formatRows?: boolean;
320
+ /**
321
+ * Whether users may insert columns while the worksheet is protected, `false` by default.
322
+ */
323
+ insertColumns?: boolean;
324
+ /**
325
+ * Whether users may insert rows while the worksheet is protected, `false` by default.
326
+ */
327
+ insertRows?: boolean;
328
+ /**
329
+ * Whether users may insert hyperlinks while the worksheet is protected, `false` by default.
330
+ */
331
+ insertHyperlinks?: boolean;
332
+ /**
333
+ * Whether users may delete columns while the worksheet is protected, `false` by default.
334
+ */
335
+ deleteColumns?: boolean;
336
+ /**
337
+ * Whether users may delete rows while the worksheet is protected, `false` by default.
338
+ */
339
+ deleteRows?: boolean;
340
+ /**
341
+ * Whether users may sort while the worksheet is protected, `false` by default.
342
+ */
343
+ sort?: boolean;
344
+ /**
345
+ * Whether users may use AutoFilter while the worksheet is protected, `false` by default.
346
+ */
347
+ autoFilter?: boolean;
348
+ /**
349
+ * Whether users may use PivotTables and PivotCharts while the worksheet is protected, `false` by default.
350
+ */
351
+ pivotTables?: boolean;
352
+ /**
353
+ * The number of times the password is hashed when the worksheet is protected, `100000` by default.
354
+ */
355
+ spinCount?: number;
356
+ }
357
+
358
+ /**
359
+ * A worksheet's protection as the file holds it (`sheetProtection`, ECMA-376 Part 1, 18.3.1.85): what stays
360
+ * allowed, and the password's hash. Each key is present only where the file or the setter gives it.
361
+ */
362
+ export interface SheetProtectionModel extends WorksheetProtection {
363
+ /**
364
+ * Whether the worksheet is protected.
365
+ */
366
+ sheet?: boolean;
367
+ /**
368
+ * The 16-bit hash of the password, as older files hold it.
369
+ */
370
+ password?: string;
371
+ /**
372
+ * The name of the hash algorithm, such as `SHA-512`.
373
+ */
374
+ algorithmName?: string;
375
+ /**
376
+ * The password's hash, in base64.
377
+ */
378
+ hashValue?: string;
379
+ /**
380
+ * The salt the password was hashed with, in base64.
381
+ */
382
+ saltValue?: string;
383
+ }
384
+
385
+ /**
386
+ * The range an AutoFilter covers, given as an address such as `A1:D9`, or as its first and last cells. Used
387
+ * by `Worksheet.autoFilter`.
388
+ */
389
+ export type AutoFilter = string | {
390
+ from: string | { row: number; column: number };
391
+ to: string | { row: number; column: number };
392
+ };
393
+
394
+ /**
395
+ * The calculation settings of a workbook, as Workbook.calcProperties holds them.
396
+ */
397
+ export interface CalculationProperties {
398
+ /**
399
+ * Whether the application shall perform a full recalculation when the workbook is opened
400
+ */
401
+ fullCalcOnLoad: boolean;
402
+ /**
403
+ * When Excel calculates: 'auto' (the default), 'manual', or 'autoNoTable' (all but data tables)
404
+ */
405
+ calcMode?: 'auto' | 'manual' | 'autoNoTable';
406
+ /**
407
+ * Iterative calculation: cycles worked out round and round (calcPr iterate, false by default)
408
+ */
409
+ iterate?: boolean;
410
+ /**
411
+ * The rounds of an iterative calculation at most (100 by default)
412
+ */
413
+ iterateCount?: number;
414
+ /**
415
+ * The change under which an iterative calculation stops (0.001 by default)
416
+ */
417
+ iterateDelta?: number;
418
+ /**
419
+ * Results kept to every digit, not as shown (true by default)
420
+ */
421
+ fullPrecision?: boolean;
422
+ }
423
+
424
+ /**
425
+ * The properties of a workbook, as Workbook.properties holds them: its date system.
426
+ */
427
+ export interface WorkbookProperties {
428
+ /**
429
+ * Set workbook dates to 1904 date system
430
+ */
431
+ date1904: boolean;
432
+ }