@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,383 @@
1
+ // What lies over the cells: pictures and where they sit, shapes and their
2
+ // connectors, and sparklines with their settings and colours.
3
+
4
+ /**
5
+ * A corner of a drawing, as the file holds it and lexax gives it: a column and row, and the offsets into them.
6
+ */
7
+ export interface Anchor {
8
+ /**
9
+ * The column of the corner, counted from 0 for column A, with the fraction of the column's width that the
10
+ * corner is past.
11
+ */
12
+ col: number;
13
+ /**
14
+ * The row of the corner, counted from 0 for row 1, with the fraction of the row's height that the corner is
15
+ * past.
16
+ */
17
+ row: number;
18
+ /**
19
+ * The column of the corner, counted from 0, as the file holds it.
20
+ */
21
+ nativeCol: number;
22
+ /**
23
+ * The row of the corner, counted from 0, as the file holds it.
24
+ */
25
+ nativeRow: number;
26
+ /**
27
+ * The offset of the corner into its column, in EMUs, 914,400 to the inch.
28
+ */
29
+ nativeColOff: number;
30
+ /**
31
+ * The offset of the corner into its row, in EMUs, 914,400 to the inch.
32
+ */
33
+ nativeRowOff: number;
34
+ }
35
+
36
+ /**
37
+ * The position of a picture by its top-left and bottom-right corners. Used by `Worksheet.addImage`.
38
+ */
39
+ export interface ImageRange {
40
+ /**
41
+ * The top-left corner of the picture: an anchor, or a column and row counted from 0.
42
+ */
43
+ tl: Anchor | { col: number; row: number };
44
+ /**
45
+ * The bottom-right corner of the picture: an anchor, or a column and row counted from 0.
46
+ */
47
+ br: Anchor | { col: number; row: number };
48
+ }
49
+
50
+ /**
51
+ * The position of a picture by its top-left cell and its size in pixels. Used by `Worksheet.addImage`.
52
+ */
53
+ export interface ImagePosition {
54
+ /**
55
+ * The top-left cell of the picture, its column and row counted from 0.
56
+ */
57
+ tl: { col: number; row: number };
58
+ /**
59
+ * The size of the picture in pixels.
60
+ */
61
+ ext: { width: number; height: number };
62
+ }
63
+
64
+ /**
65
+ * A hyperlink on a picture, given to `Worksheet.addImage`.
66
+ */
67
+ export interface ImageHyperlinkValue {
68
+ /**
69
+ * The address the picture links to.
70
+ */
71
+ hyperlink: string;
72
+ /**
73
+ * The text shown when the pointer rests on the picture's link.
74
+ */
75
+ tooltip?: string;
76
+ }
77
+
78
+ /**
79
+ * Where `Worksheet.addImage` puts a picture: its top-left corner, and its bottom-right corner or its size in
80
+ * pixels.
81
+ */
82
+ export interface ImagePlacement {
83
+ /**
84
+ * The top-left corner: an address such as `B2`, a column and row counted from 0, or an anchor.
85
+ */
86
+ tl: string | Anchor | { col: number; row: number };
87
+ /**
88
+ * The bottom-right corner, in the same forms as `tl`.
89
+ */
90
+ br?: string | Anchor | { col: number; row: number };
91
+ /**
92
+ * The size of the picture in pixels, where `br` is not given.
93
+ */
94
+ ext?: { width: number; height: number };
95
+ /**
96
+ * How the picture moves and sizes with the cells under it.
97
+ */
98
+ editAs?: 'oneCell' | 'twoCell' | 'absolute';
99
+ /**
100
+ * The link the picture follows when clicked.
101
+ */
102
+ hyperlinks?: ImageHyperlinkValue;
103
+ }
104
+
105
+ /**
106
+ * Where a drawing lies, as lexax gives it for a picture (`Worksheet.getImages`), a chart and a slicer: each
107
+ * corner an anchor.
108
+ */
109
+ export interface DrawingRange {
110
+ /**
111
+ * The top-left corner.
112
+ */
113
+ tl: Anchor;
114
+ /**
115
+ * The bottom-right corner, where the drawing has one.
116
+ */
117
+ br?: Anchor;
118
+ /**
119
+ * The size of the drawing in pixels, where the file gives one.
120
+ */
121
+ ext?: { width: number; height: number };
122
+ /**
123
+ * How the drawing moves and sizes with the cells under it.
124
+ */
125
+ editAs?: 'oneCell' | 'twoCell' | 'absolute';
126
+ /**
127
+ * The link a picture follows when clicked.
128
+ */
129
+ hyperlinks?: ImageHyperlinkValue;
130
+ }
131
+
132
+ /**
133
+ * A picture over a sheet's cells, as `Worksheet.getImages` gives it.
134
+ */
135
+ export interface SheetImage {
136
+ /**
137
+ * Always `image`.
138
+ */
139
+ type: 'image';
140
+ /**
141
+ * The id of the workbook's image it shows, from `Workbook.addImage`.
142
+ */
143
+ imageId: number;
144
+ /**
145
+ * Where it lies.
146
+ */
147
+ range: DrawingRange;
148
+ /**
149
+ * Its id among the sheet's drawings, where the file gives one.
150
+ */
151
+ id?: number;
152
+ /**
153
+ * Its name, where the file gives one.
154
+ */
155
+ name?: string;
156
+ }
157
+
158
+ /**
159
+ * An image to add to a workbook with `Workbook.addImage`.
160
+ */
161
+ export interface Image {
162
+ /**
163
+ * The format of the image, such as `png`, `jpeg` or `gif`, which names its media part.
164
+ */
165
+ extension: string;
166
+ /**
167
+ * The image's data as a base64 string, as an alternative to `buffer` and `filename`.
168
+ */
169
+ base64?: string;
170
+ /**
171
+ * The path of an image file to read the image from, as an alternative to `buffer` and `base64`.
172
+ */
173
+ filename?: string;
174
+ /**
175
+ * The image's data as a Buffer or any Uint8Array, as an alternative to `base64` and `filename`.
176
+ */
177
+ buffer?: Uint8Array;
178
+ /**
179
+ * Always `image`, as `Workbook.getImage` gives an image back.
180
+ */
181
+ type?: 'image';
182
+ }
183
+
184
+ /** a line's look: its colour as RRGGBB and its width in points, or none */
185
+ export type ShapeLine = {color?: string; width?: number} | 'none';
186
+
187
+ /**
188
+ * The options of `addShape`, which draws a preset shape over a range of cells.
189
+ */
190
+ export interface ShapeOptions {
191
+ /** a DrawingML preset geometry: rect (the default), ellipse, roundRect, rightArrow, star5... */
192
+ type?: string;
193
+ /** the cells it lies over, B2:D6 */
194
+ range: string;
195
+ /** a paragraph a line */
196
+ text?: string;
197
+ /** Excel's name for it (Rectangle 1, Oval 2) by default */
198
+ name?: string;
199
+ /** a colour as RRGGBB, or none; the theme's accent 1 by default (a text box: none) */
200
+ fill?: string;
201
+ /**
202
+ * The shape's outline: its colour and width in points, or `none`.
203
+ */
204
+ line?: ShapeLine;
205
+ /** size in points, 11 by default */
206
+ font?: {size?: number; bold?: boolean; italic?: boolean; color?: string};
207
+ }
208
+
209
+ /** a connector's end: a shape by its name, or that and its connection site's index */
210
+ export type ConnectorEnd = string | {shape: string; site?: number};
211
+
212
+ /**
213
+ * The options of `addConnector`, which draws a line between two cells.
214
+ */
215
+ export interface ConnectorOptions {
216
+ /** straightConnector1 by default */
217
+ type?: 'straightConnector1' | 'bentConnector3' | 'curvedConnector3';
218
+ /** from its first cell to its second: D4:F3 runs up and right */
219
+ range: string;
220
+ /** the end with an arrowhead, end by default */
221
+ arrow?: 'end' | 'start' | 'both' | 'none';
222
+ /**
223
+ * The connector's line: its colour and width in points, or `none`.
224
+ */
225
+ line?: ShapeLine;
226
+ /**
227
+ * The shape the connector starts at, and the connection site it joins.
228
+ */
229
+ from?: ConnectorEnd;
230
+ /**
231
+ * The shape the connector ends at, and the connection site it joins.
232
+ */
233
+ to?: ConnectorEnd;
234
+ /**
235
+ * The connector's name; Excel's own name, such as `Straight Arrow Connector 3`, when left out.
236
+ */
237
+ name?: string;
238
+ }
239
+
240
+ /** A sparkline group's colour: an ARGB, a theme colour with its tint, or an indexed one. */
241
+ export interface SparklineColor {
242
+ /**
243
+ * The color as an ARGB value, such as FF376092.
244
+ */
245
+ argb?: string;
246
+ /**
247
+ * The index of a color in the workbook's theme.
248
+ */
249
+ theme?: number;
250
+ /**
251
+ * The tint of a theme color, from -1 to 1: a positive tint lightens the color, and a negative one darkens
252
+ * it.
253
+ */
254
+ tint?: number;
255
+ /**
256
+ * The index of a color in the workbook's indexed palette.
257
+ */
258
+ indexed?: number;
259
+ /**
260
+ * Whether the color is Excel's automatic color.
261
+ */
262
+ auto?: boolean;
263
+ }
264
+
265
+ /** Set over the group's colours: those not named stay, one given null goes. */
266
+ export interface SparklineColors {
267
+ /**
268
+ * The color of the sparkline's line or columns.
269
+ */
270
+ series?: SparklineColor | null;
271
+ /**
272
+ * The color of the negative points.
273
+ */
274
+ negative?: SparklineColor | null;
275
+ /**
276
+ * The color of the horizontal axis.
277
+ */
278
+ axis?: SparklineColor | null;
279
+ /**
280
+ * The color of the markers.
281
+ */
282
+ markers?: SparklineColor | null;
283
+ /**
284
+ * The color of the marker on the first point.
285
+ */
286
+ first?: SparklineColor | null;
287
+ /**
288
+ * The color of the marker on the last point.
289
+ */
290
+ last?: SparklineColor | null;
291
+ /**
292
+ * The color of the marker on the highest point.
293
+ */
294
+ high?: SparklineColor | null;
295
+ /**
296
+ * The color of the marker on the lowest point.
297
+ */
298
+ low?: SparklineColor | null;
299
+ }
300
+
301
+ /**
302
+ * The settings of a sparkline group: which points are marked, whether the axis and hidden data show, how
303
+ * empty cells are drawn, the scale, the style and the colors. Each setting left out takes the default Excel
304
+ * gives a new group.
305
+ */
306
+ export interface SparklineSettings {
307
+ /**
308
+ * Whether the points are marked. Off by default.
309
+ */
310
+ markers?: boolean;
311
+ /**
312
+ * Whether the highest point is marked. Off by default.
313
+ */
314
+ high?: boolean;
315
+ /**
316
+ * Whether the lowest point is marked. Off by default.
317
+ */
318
+ low?: boolean;
319
+ /**
320
+ * Whether the first point is marked. Off by default.
321
+ */
322
+ first?: boolean;
323
+ /**
324
+ * Whether the last point is marked. Off by default.
325
+ */
326
+ last?: boolean;
327
+ /**
328
+ * Whether the negative points are marked. Off by default, and on for a win/loss group.
329
+ */
330
+ negative?: boolean;
331
+ /** the horizontal axis shown */
332
+ axis?: boolean;
333
+ /** data in hidden rows and columns drawn */
334
+ hidden?: boolean;
335
+ /**
336
+ * Whether the points are plotted from right to left. Off by default.
337
+ */
338
+ rightToLeft?: boolean;
339
+ /**
340
+ * How empty cells are drawn: gap leaves a gap, zero draws them as zero, and span joins the points either
341
+ * side. gap by default.
342
+ */
343
+ emptyCells?: 'gap' | 'zero' | 'span';
344
+ /** in points */
345
+ lineWeight?: number;
346
+ /**
347
+ * The lowest value of the scale: individual for the sparkline's own lowest value, group for the lowest value
348
+ * of the group, or a number. individual by default.
349
+ */
350
+ min?: 'individual' | 'group' | number;
351
+ /**
352
+ * The highest value of the scale: individual for the sparkline's own highest value, group for the highest
353
+ * value of the group, or a number. individual by default.
354
+ */
355
+ max?: 'individual' | 'group' | number;
356
+ /** an item of Excel's Sparkline Style gallery, 1 to 36, row by row; its colours are set before `colors` */
357
+ style?: number;
358
+ /**
359
+ * The colors of the group's sparklines, set over the group's current colors.
360
+ */
361
+ colors?: SparklineColors;
362
+ }
363
+
364
+ /**
365
+ * The options of `Worksheet.addSparklines`: the cells the sparklines stand in, the data they draw, and the
366
+ * settings every sparkline in the group takes.
367
+ */
368
+ export interface AddSparklinesOptions extends SparklineSettings {
369
+ /** one row or one column of cells, a sparkline in each */
370
+ location: string;
371
+ /**
372
+ * a range with a row (or column) for each cell, or one line for a single cell; or a
373
+ * table's data rows: 'Sales', 'Sales[Q1]' or 'Sales[[Q1]:[Q4]]', written as the range;
374
+ * or a PivotTable's values as laid out, by its name, its grand totals left out
375
+ */
376
+ data: string | {pivotTable: string};
377
+ /**
378
+ * The type of sparkline: `'line'` (the default), `'column'`, or `'winLoss'` for win and loss bars.
379
+ */
380
+ type?: 'line' | 'column' | 'winLoss';
381
+ /** the dates the points stand at */
382
+ dateRange?: string;
383
+ }