@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.
- package/LICENSE +202 -0
- package/index.d.ts +2282 -0
- package/index.js +865 -0
- package/lexax.darwin-arm64.node +0 -0
- package/lexax.darwin-x64.node +0 -0
- package/lexax.linux-arm64-gnu.node +0 -0
- package/lexax.linux-x64-gnu.node +0 -0
- package/package.json +29 -4
- package/types/calc.d.ts +260 -0
- package/types/chart.d.ts +479 -0
- package/types/chart_ex.d.ts +379 -0
- package/types/chart_format.d.ts +440 -0
- package/types/chart_series.d.ts +336 -0
- package/types/drawings.d.ts +383 -0
- package/types/files.d.ts +367 -0
- package/types/formats.d.ts +380 -0
- package/types/page.d.ts +352 -0
- package/types/render.d.ts +137 -0
- package/types/sheet.d.ts +432 -0
- package/types/styles.d.ts +383 -0
- package/types/tables.d.ts +420 -0
- package/types/validation.d.ts +151 -0
- package/types/values.d.ts +280 -0
- package/README.md +0 -3
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
// Conditional formats: each kind of rule, the thresholds they take, and
|
|
2
|
+
// the options of addConditionalFormatting and addConditionalFormat.
|
|
3
|
+
|
|
4
|
+
import type { Color, Style } from './styles';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The comparison a cellIs conditional formatting rule makes: equal, greaterThan, lessThan, or between.
|
|
8
|
+
*/
|
|
9
|
+
export type CellIsOperators = 'equal' | 'greaterThan' | 'lessThan' | 'between';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The test a containsText conditional formatting rule makes: whether the text contains, does not contain,
|
|
13
|
+
* begins or ends with the rule's text, or whether the cell contains blanks or errors.
|
|
14
|
+
*/
|
|
15
|
+
export type ContainsTextOperators = 'containsText' | 'notContainsText' | 'beginsWith' | 'endsWith' | 'containsBlanks'
|
|
16
|
+
| 'notContainsBlanks' | 'containsErrors' | 'notContainsErrors';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* The period a timePeriod conditional formatting rule tests dates against, relative to today: yesterday,
|
|
20
|
+
* today, tomorrow, the last seven days, or last, this or next week or month.
|
|
21
|
+
*/
|
|
22
|
+
export type TimePeriodTypes = 'lastWeek' | 'thisWeek' | 'nextWeek' | 'yesterday' | 'today' | 'tomorrow' | 'last7Days' | 'lastMonth'
|
|
23
|
+
| 'thisMonth' | 'nextMonth';
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The icon set of an iconSet conditional formatting rule: arrows, flags, stars, symbols, traffic lights,
|
|
27
|
+
* ratings, triangles or boxes, in three, four or five icons, or NoIcons for none.
|
|
28
|
+
*/
|
|
29
|
+
export type IconSetTypes = '5Arrows' | '5ArrowsGray' | '5Boxes' | '5Quarters' | '5Rating' | '4Arrows' | '4ArrowsGray'
|
|
30
|
+
| '4Rating' | '4RedToBlack' | '4TrafficLights' | 'NoIcons' | '3Arrows' | '3ArrowsGray' | '3Flags' | '3Signs'
|
|
31
|
+
| '3Stars' | '3Symbols' | '3Symbols2' | '3TrafficLights1' | '3TrafficLights2' | '3Triangles';
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* How a threshold of a conditional formatting rule finds its value: a percentile, a percent, a number, the
|
|
35
|
+
* lowest or highest value (min or max), the automatic minimum or maximum (autoMin or autoMax), or a formula.
|
|
36
|
+
*/
|
|
37
|
+
export type CfvoTypes = 'percentile' | 'percent' | 'num' | 'min' | 'max' | 'formula' | 'autoMin' | 'autoMax';
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* A threshold of a color scale, data bar or icon set rule: its type, and the value it takes for that type.
|
|
41
|
+
*/
|
|
42
|
+
export interface Cvfo {
|
|
43
|
+
/**
|
|
44
|
+
* How the threshold finds its value, as CfvoTypes.
|
|
45
|
+
*/
|
|
46
|
+
type: CfvoTypes;
|
|
47
|
+
/**
|
|
48
|
+
* The value of the threshold, for the types that take one.
|
|
49
|
+
*/
|
|
50
|
+
value?: number;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* The properties every conditional formatting rule has: its priority, and the format its cells take where the
|
|
55
|
+
* rule holds.
|
|
56
|
+
*/
|
|
57
|
+
export interface ConditionalFormattingBaseRule {
|
|
58
|
+
/**
|
|
59
|
+
* The rule's priority among the conditional formatting rules of the worksheet, 1 the highest.
|
|
60
|
+
*/
|
|
61
|
+
priority: number;
|
|
62
|
+
/**
|
|
63
|
+
* The format the cells take where the rule holds, as a style.
|
|
64
|
+
*/
|
|
65
|
+
style?: Partial<Style>;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* A conditional formatting rule that formats the cells for which a formula is true.
|
|
70
|
+
*/
|
|
71
|
+
export interface ExpressionRuleType extends ConditionalFormattingBaseRule {
|
|
72
|
+
/**
|
|
73
|
+
* The type of the rule, `expression`.
|
|
74
|
+
*/
|
|
75
|
+
type: 'expression';
|
|
76
|
+
/**
|
|
77
|
+
* The formula the cells are tested by.
|
|
78
|
+
*/
|
|
79
|
+
formulae?: any[];
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* A conditional formatting rule that formats the cells whose values pass a comparison, set by operator and
|
|
84
|
+
* formulae.
|
|
85
|
+
*/
|
|
86
|
+
export interface CellIsRuleType extends ConditionalFormattingBaseRule {
|
|
87
|
+
/**
|
|
88
|
+
* The type of the rule, `cellIs`.
|
|
89
|
+
*/
|
|
90
|
+
type: 'cellIs';
|
|
91
|
+
/**
|
|
92
|
+
* The values the cells are compared with: one for equal, greaterThan or lessThan, two for between.
|
|
93
|
+
*/
|
|
94
|
+
formulae?: any[];
|
|
95
|
+
/**
|
|
96
|
+
* The comparison the cells are tested with, as CellIsOperators.
|
|
97
|
+
*/
|
|
98
|
+
operator?: CellIsOperators;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* A conditional formatting rule that formats the highest or the lowest values of the range.
|
|
103
|
+
*/
|
|
104
|
+
export interface Top10RuleType extends ConditionalFormattingBaseRule {
|
|
105
|
+
/**
|
|
106
|
+
* The type of the rule, `top10`.
|
|
107
|
+
*/
|
|
108
|
+
type: 'top10';
|
|
109
|
+
/**
|
|
110
|
+
* The number of values the rule formats, 10 by default, or the percent of the values when percent is true.
|
|
111
|
+
*/
|
|
112
|
+
rank: number;
|
|
113
|
+
/**
|
|
114
|
+
* Whether rank counts a percent of the values, not a number of them.
|
|
115
|
+
*/
|
|
116
|
+
percent: boolean;
|
|
117
|
+
/**
|
|
118
|
+
* Whether the rule formats the lowest values, not the highest.
|
|
119
|
+
*/
|
|
120
|
+
bottom: boolean;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* A conditional formatting rule that formats the values above or below the average of the range.
|
|
125
|
+
*/
|
|
126
|
+
export interface AboveAverageRuleType extends ConditionalFormattingBaseRule {
|
|
127
|
+
/**
|
|
128
|
+
* The type of the rule, `aboveAverage`.
|
|
129
|
+
*/
|
|
130
|
+
type: 'aboveAverage';
|
|
131
|
+
/**
|
|
132
|
+
* Whether the rule formats the values above the average, or those below it when false.
|
|
133
|
+
*/
|
|
134
|
+
aboveAverage: boolean;
|
|
135
|
+
/**
|
|
136
|
+
* Whether the rule also formats the values equal to the average. False by default.
|
|
137
|
+
*/
|
|
138
|
+
equalAverage?: boolean;
|
|
139
|
+
/**
|
|
140
|
+
* The number of standard deviations from the average a value must be to be formatted.
|
|
141
|
+
*/
|
|
142
|
+
stdDev?: number;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* A conditional formatting rule that formats the duplicate values or the unique values of the range.
|
|
147
|
+
*/
|
|
148
|
+
export interface ValuesRuleType extends ConditionalFormattingBaseRule {
|
|
149
|
+
/**
|
|
150
|
+
* The type of the rule: duplicateValues for duplicate values, or uniqueValues for unique values.
|
|
151
|
+
*/
|
|
152
|
+
type: 'duplicateValues' | 'uniqueValues';
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* A conditional formatting rule that shades each cell of the range along a color scale.
|
|
157
|
+
*/
|
|
158
|
+
export interface ColorScaleRuleType extends ConditionalFormattingBaseRule {
|
|
159
|
+
/**
|
|
160
|
+
* The type of the rule, `colorScale`.
|
|
161
|
+
*/
|
|
162
|
+
type: 'colorScale';
|
|
163
|
+
/**
|
|
164
|
+
* The thresholds of the scale, one for each color, from the lowest.
|
|
165
|
+
*/
|
|
166
|
+
cfvo?: Cvfo[];
|
|
167
|
+
/**
|
|
168
|
+
* The colors of the scale, one for each threshold in cfvo, from the lowest.
|
|
169
|
+
*/
|
|
170
|
+
color?: Partial<Color>[];
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* A conditional formatting rule that shows an icon in each cell, the icon chosen by where the cell's value
|
|
175
|
+
* falls among the thresholds.
|
|
176
|
+
*/
|
|
177
|
+
export interface IconSetRuleType extends ConditionalFormattingBaseRule {
|
|
178
|
+
/**
|
|
179
|
+
* The type of the rule, `iconSet`.
|
|
180
|
+
*/
|
|
181
|
+
type: 'iconSet';
|
|
182
|
+
/**
|
|
183
|
+
* Whether the cell's value shows beside its icon. True by default.
|
|
184
|
+
*/
|
|
185
|
+
showValue?: boolean;
|
|
186
|
+
/**
|
|
187
|
+
* Whether the icons are in reverse order, as Excel's Reverse Icon Order sets them.
|
|
188
|
+
*/
|
|
189
|
+
reverse?: boolean;
|
|
190
|
+
/**
|
|
191
|
+
* Whether each threshold has an icon of its own, as Excel's custom icon sets do, not the icons of iconSet.
|
|
192
|
+
*/
|
|
193
|
+
custom?: boolean;
|
|
194
|
+
/**
|
|
195
|
+
* The icon set the rule shows, as IconSetTypes.
|
|
196
|
+
*/
|
|
197
|
+
iconSet?: IconSetTypes;
|
|
198
|
+
/**
|
|
199
|
+
* The thresholds at which the icon changes, from the lowest.
|
|
200
|
+
*/
|
|
201
|
+
cfvo?: Cvfo[];
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* A conditional formatting rule that formats the cells whose text meets its test, given by operator and text.
|
|
206
|
+
*/
|
|
207
|
+
export interface ContainsTextRuleType extends ConditionalFormattingBaseRule {
|
|
208
|
+
/**
|
|
209
|
+
* The type of the rule, `containsText`.
|
|
210
|
+
*/
|
|
211
|
+
type: 'containsText';
|
|
212
|
+
/**
|
|
213
|
+
* The test the cells' text is checked with, as ContainsTextOperators.
|
|
214
|
+
*/
|
|
215
|
+
operator?: ContainsTextOperators;
|
|
216
|
+
/**
|
|
217
|
+
* The text the cells are tested for, where the test takes text.
|
|
218
|
+
*/
|
|
219
|
+
text?: string;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* A conditional formatting rule that formats the cells holding dates within a period relative to today.
|
|
224
|
+
*/
|
|
225
|
+
export interface TimePeriodRuleType extends ConditionalFormattingBaseRule {
|
|
226
|
+
/**
|
|
227
|
+
* The type of the rule, `timePeriod`.
|
|
228
|
+
*/
|
|
229
|
+
type: 'timePeriod';
|
|
230
|
+
/**
|
|
231
|
+
* The period the dates are tested in, as TimePeriodTypes.
|
|
232
|
+
*/
|
|
233
|
+
timePeriod?: TimePeriodTypes;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* A conditional formatting rule that draws a bar in each cell, its length in proportion to the cell's value.
|
|
238
|
+
*/
|
|
239
|
+
export interface DataBarRuleType extends ConditionalFormattingBaseRule {
|
|
240
|
+
/**
|
|
241
|
+
* The type of the rule, `dataBar`.
|
|
242
|
+
*/
|
|
243
|
+
type: 'dataBar';
|
|
244
|
+
/**
|
|
245
|
+
* Whether the bar is shaded from one end to the other, as a gradient. True by default; false draws a solid
|
|
246
|
+
* bar.
|
|
247
|
+
*/
|
|
248
|
+
gradient?: boolean;
|
|
249
|
+
/**
|
|
250
|
+
* The length of the shortest bar, as a percent of the cell's width. 10 by default.
|
|
251
|
+
*/
|
|
252
|
+
minLength?: number;
|
|
253
|
+
/**
|
|
254
|
+
* The length of the longest bar, as a percent of the cell's width. 90 by default.
|
|
255
|
+
*/
|
|
256
|
+
maxLength?: number;
|
|
257
|
+
/**
|
|
258
|
+
* Whether the cell's value shows beside its bar. True by default.
|
|
259
|
+
*/
|
|
260
|
+
showValue?: boolean;
|
|
261
|
+
/**
|
|
262
|
+
* Whether the bar has a border.
|
|
263
|
+
*/
|
|
264
|
+
border?: boolean;
|
|
265
|
+
/** false (the schema's default) draws negative bars in negativeFillColor, red where none is given */
|
|
266
|
+
negativeBarColorSameAsPositive?: boolean;
|
|
267
|
+
/**
|
|
268
|
+
* Whether a negative bar's border takes the border color of the positive bars. When false, it takes
|
|
269
|
+
* negativeBorderColor.
|
|
270
|
+
*/
|
|
271
|
+
negativeBarBorderColorSameAsPositive?: boolean;
|
|
272
|
+
/** 'automatic' by default; 'auto' is taken for it */
|
|
273
|
+
axisPosition?: 'automatic' | 'auto' | 'middle' | 'none';
|
|
274
|
+
/** 'context', the sheet's, by default */
|
|
275
|
+
direction?: 'context' | 'leftToRight' | 'rightToLeft';
|
|
276
|
+
/** the bar's colour (ECMA-376 Part 1, 18.3.1.28's color) */
|
|
277
|
+
color?: Partial<Color>;
|
|
278
|
+
/**
|
|
279
|
+
* The color of the bar's border.
|
|
280
|
+
*/
|
|
281
|
+
borderColor?: Partial<Color>;
|
|
282
|
+
/**
|
|
283
|
+
* The color of the negative bars. Red by default.
|
|
284
|
+
*/
|
|
285
|
+
negativeFillColor?: Partial<Color>;
|
|
286
|
+
/**
|
|
287
|
+
* The color of the border of the negative bars. The negative fill color by default.
|
|
288
|
+
*/
|
|
289
|
+
negativeBorderColor?: Partial<Color>;
|
|
290
|
+
/**
|
|
291
|
+
* The color of the axis the bars are drawn from. Black by default.
|
|
292
|
+
*/
|
|
293
|
+
axisColor?: Partial<Color>;
|
|
294
|
+
/**
|
|
295
|
+
* The minimum and the maximum the bar lengths are measured between, the lower threshold first.
|
|
296
|
+
*/
|
|
297
|
+
cfvo?: Cvfo[];
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* A conditional formatting rule of any kind: one of the rule types above, as
|
|
302
|
+
* ConditionalFormattingOptions.rules takes them.
|
|
303
|
+
*/
|
|
304
|
+
export type ConditionalFormattingRule = ExpressionRuleType | CellIsRuleType | Top10RuleType | AboveAverageRuleType | ColorScaleRuleType | IconSetRuleType
|
|
305
|
+
| ContainsTextRuleType | TimePeriodRuleType | DataBarRuleType | ValuesRuleType;
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* The options of Worksheet.addConditionalFormatting: the range the rules apply to and the rules.
|
|
309
|
+
*/
|
|
310
|
+
export interface ConditionalFormattingOptions {
|
|
311
|
+
/**
|
|
312
|
+
* The range the rules apply to, as an address such as A1:B9.
|
|
313
|
+
*/
|
|
314
|
+
ref: string;
|
|
315
|
+
/**
|
|
316
|
+
* The rules applied to the range.
|
|
317
|
+
*/
|
|
318
|
+
rules: ConditionalFormattingRule[];
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* The kinds of conditional formatting rule `addConditionalFormat` adds, such as `dataBar`, `colorScale`,
|
|
323
|
+
* `top`, `duplicates`, `formula` and the comparisons from `greaterThan` to `notBetween`.
|
|
324
|
+
*/
|
|
325
|
+
export type ConditionalFormatIntent =
|
|
326
|
+
| 'dataBar' | 'colorScale' | 'iconSet' | 'top' | 'bottom' | 'aboveAverage' | 'belowAverage' | 'duplicates'
|
|
327
|
+
| 'unique' | 'textContains' | 'dateOccurring' | 'formula' | 'greaterThan' | 'lessThan' | 'between' | 'equal'
|
|
328
|
+
| 'notEqual' | 'greaterThanOrEqual' | 'lessThanOrEqual' | 'notBetween';
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* The options of `addConditionalFormat`, which apply to the type of rule given.
|
|
332
|
+
*/
|
|
333
|
+
export interface ConditionalFormatOptions {
|
|
334
|
+
/** a data bar's gallery colour or an RGB colour ('#4472C4', 'FF4472C4') */
|
|
335
|
+
color?: 'blue' | 'green' | 'red' | 'orange' | 'lightBlue' | 'purple' | string;
|
|
336
|
+
/** a data bar's fill, gradient by default */
|
|
337
|
+
fill?: 'gradient' | 'solid';
|
|
338
|
+
/**
|
|
339
|
+
* The colour scale of a `colorScale` rule, by its name in Excel's gallery, such as `redYellowGreen`.
|
|
340
|
+
*/
|
|
341
|
+
scale?:
|
|
342
|
+
| 'greenYellowRed' | 'redYellowGreen' | 'greenWhiteRed' | 'redWhiteGreen' | 'blueWhiteRed' | 'redWhiteBlue'
|
|
343
|
+
| 'whiteRed' | 'redWhite' | 'greenWhite' | 'whiteGreen' | 'greenYellow' | 'yellowGreen';
|
|
344
|
+
/**
|
|
345
|
+
* The icon set of an `iconSet` rule.
|
|
346
|
+
*/
|
|
347
|
+
icons?: IconSetTypes;
|
|
348
|
+
/** a comparison's value, a number, text, a date or a formula starting `=` */
|
|
349
|
+
value?: number | string | Date;
|
|
350
|
+
/**
|
|
351
|
+
* The lower bound of a `between` rule: a number, text or a date.
|
|
352
|
+
*/
|
|
353
|
+
from?: number | string | Date;
|
|
354
|
+
/**
|
|
355
|
+
* The upper bound of a `between` rule: a number, text or a date.
|
|
356
|
+
*/
|
|
357
|
+
to?: number | string | Date;
|
|
358
|
+
/** top and bottom's count, 10 by default, or percent */
|
|
359
|
+
rank?: number;
|
|
360
|
+
/**
|
|
361
|
+
* Whether the count of a `top` or `bottom` rule is a percentage of the values.
|
|
362
|
+
*/
|
|
363
|
+
percent?: boolean;
|
|
364
|
+
/**
|
|
365
|
+
* The text a `textContains` rule looks for.
|
|
366
|
+
*/
|
|
367
|
+
text?: string;
|
|
368
|
+
/**
|
|
369
|
+
* The period a `dateOccurring` rule tests, such as `thisMonth` or `last7Days`.
|
|
370
|
+
*/
|
|
371
|
+
period?: 'yesterday' | 'today' | 'tomorrow' | 'last7Days' | 'lastWeek' | 'thisWeek' | 'nextWeek' | 'lastMonth' | 'thisMonth' | 'nextMonth';
|
|
372
|
+
/**
|
|
373
|
+
* The formula a `formula` rule tests.
|
|
374
|
+
*/
|
|
375
|
+
formula?: string;
|
|
376
|
+
/** one of the preset formats, Light Red Fill with Dark Red Text by default */
|
|
377
|
+
format?: 'lightRedDarkRed' | 'yellowDarkYellow' | 'greenDarkGreen' | 'lightRed' | 'redText';
|
|
378
|
+
/** a format of one's own in place of a preset */
|
|
379
|
+
style?: Partial<Style>;
|
|
380
|
+
}
|