@ex-grid/sheet-engine 0.0.0-stage → 0.2.0-beta.3
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 +21 -0
- package/README.md +26 -2
- package/dist/index.d.ts +3250 -0
- package/dist/index.js +17776 -0
- package/dist/index.js.map +7 -0
- package/package.json +23 -4
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,3250 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ExSheet's formula engine in TypeScript (ADR-0370, section 2): a Workbook of Sheets of Entries, Excel's formula
|
|
3
|
+
* syntax, a declared set of functions that answer as Excel does or refuse, incremental recalculation, number
|
|
4
|
+
* formats, Cell Formats, the edits a Sheet takes with their undo steps, and the documents that carry a Sheet and a
|
|
5
|
+
* Workbook. It is held to the same cases as ExSheet.Engine.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/** A cell's address with its state. @internal */
|
|
11
|
+
declare interface AddressedState {
|
|
12
|
+
readonly address: CellAddress;
|
|
13
|
+
readonly state: CellState;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** An inclusive rectangle of cells, zero-based. */
|
|
17
|
+
declare class Area {
|
|
18
|
+
readonly row1: number;
|
|
19
|
+
readonly column1: number;
|
|
20
|
+
readonly row2: number;
|
|
21
|
+
readonly column2: number;
|
|
22
|
+
constructor(row1: number, column1: number, row2: number, column2: number);
|
|
23
|
+
get isSingleCell(): boolean;
|
|
24
|
+
get cellCount(): number;
|
|
25
|
+
get rows(): number;
|
|
26
|
+
get columns(): number;
|
|
27
|
+
contains(address: CellAddress): boolean;
|
|
28
|
+
equals(other: Area): boolean;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** The argument hint (ADR-0051): the function whose argument list holds the caret, and which argument it is in. */
|
|
32
|
+
export declare interface ArgumentHint {
|
|
33
|
+
/** The declared function. */
|
|
34
|
+
readonly function: DeclaredFunction;
|
|
35
|
+
/** Which argument the caret is in, from 0. */
|
|
36
|
+
readonly argumentIndex: number;
|
|
37
|
+
/**
|
|
38
|
+
* That argument's name as `DeclaredFunction.arguments` lists it — for an open-ended function past its named
|
|
39
|
+
* arguments, the one that repeats — or `undefined` when the caret is past the last argument the function takes.
|
|
40
|
+
*/
|
|
41
|
+
readonly currentArgument: string | undefined;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** One of a fixed list of values an argument takes, as completion lists it (ADR-0058): the value, and Excel's text for it. */
|
|
45
|
+
export declare interface ArgumentValue {
|
|
46
|
+
/** What choosing it writes into the Formula: `-1`. */
|
|
47
|
+
readonly value: string;
|
|
48
|
+
/** The text the list shows, Excel's: `-1 - Exact match or next smaller item`. */
|
|
49
|
+
readonly text: string;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** The parts of a Cell Format recorded on a whole row or a whole column: `undefined` where that level records nothing. @internal */
|
|
53
|
+
declare class AxisFormat {
|
|
54
|
+
readonly numberFormat: NumberFormat | undefined;
|
|
55
|
+
readonly alignment: HorizontalAlignment | undefined;
|
|
56
|
+
readonly font: CellFont | undefined;
|
|
57
|
+
readonly fill: CellFill | undefined;
|
|
58
|
+
readonly borders: CellBorders | undefined;
|
|
59
|
+
constructor(numberFormat: NumberFormat | undefined, alignment: HorizontalAlignment | undefined, font: CellFont | undefined, fill: CellFill | undefined, borders: CellBorders | undefined);
|
|
60
|
+
/** The level that records nothing. */
|
|
61
|
+
static readonly empty: AxisFormat;
|
|
62
|
+
get isEmpty(): boolean;
|
|
63
|
+
/** What the level shows over `under`: each part it records, else `under`'s. */
|
|
64
|
+
over(under: CellFormat): CellFormat;
|
|
65
|
+
/** The level with each part `change` sets taken from `next`, and recorded as nothing where it equals what shows under the level anyway. */
|
|
66
|
+
with(change: CellFormatChange, next: CellFormat, under: CellFormat): AxisFormat;
|
|
67
|
+
/** This level with the parts given replaced; a part given as `undefined` records nothing. */
|
|
68
|
+
replacing(parts: {
|
|
69
|
+
numberFormat?: NumberFormat | undefined;
|
|
70
|
+
alignment?: HorizontalAlignment | undefined;
|
|
71
|
+
fill?: CellFill | undefined;
|
|
72
|
+
borders?: CellBorders | undefined;
|
|
73
|
+
}): AxisFormat;
|
|
74
|
+
/** A key two equal levels share and two different ones do not. */
|
|
75
|
+
get key(): string;
|
|
76
|
+
equals(other: AxisFormat): boolean;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* A binary operator. Excel's operators associate to the left, so `=1+1+…+1` is a chain of these down their
|
|
81
|
+
* left operands, as long as the Formula: a walk over one loops along that chain (`spine`, `operands`) and
|
|
82
|
+
* descends only into the right operands, so a chain of thousands of operators never deepens the stack.
|
|
83
|
+
*/
|
|
84
|
+
declare class BinaryNode extends NodeBase {
|
|
85
|
+
#private;
|
|
86
|
+
readonly kind = "binary";
|
|
87
|
+
readonly operator: string;
|
|
88
|
+
readonly left: Node_2;
|
|
89
|
+
readonly right: Node_2;
|
|
90
|
+
constructor(operator: string, left: Node_2, right: Node_2);
|
|
91
|
+
get depth(): number;
|
|
92
|
+
references(): Generator<Reference>;
|
|
93
|
+
structuredReferences(): Generator<StructuredReferenceNode>;
|
|
94
|
+
calls(): Generator<FunctionNode>;
|
|
95
|
+
/**
|
|
96
|
+
* This operator and those down its left operands, innermost (the first applied) first: the chain `1+2-3`
|
|
97
|
+
* is the `+`, then the `-`. The innermost's left operand is `leftmost`.
|
|
98
|
+
*/
|
|
99
|
+
get spine(): BinaryNode[];
|
|
100
|
+
/** The first operand of the chain: the left operand of its innermost operator, which is no operator. */
|
|
101
|
+
get leftmost(): Node_2;
|
|
102
|
+
/** The chain's operands in the text's order: `leftmost`, then each operator's right operand. */
|
|
103
|
+
operands(): Generator<Node_2>;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
declare class BooleanNode extends NodeBase {
|
|
107
|
+
readonly kind = "boolean";
|
|
108
|
+
readonly value: boolean;
|
|
109
|
+
constructor(value: boolean);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* The Borders a change sets, relative to each range it is set on (ADR-0071), as Excel's Format Cells sets them:
|
|
114
|
+
* each edge given is set — to a line, or to `BorderLine.none` to take the line away — and every other edge is left
|
|
115
|
+
* as each cell has it. `outline`, `inside` and `none` are Excel's presets. As Excel keeps the line between two
|
|
116
|
+
* cells (the twelfth Windows run): an outer edge is recorded on the range's own cells, and the cells beside it lose
|
|
117
|
+
* their record of the same edge.
|
|
118
|
+
*/
|
|
119
|
+
export declare class BorderChange implements BorderChangeParts {
|
|
120
|
+
#private;
|
|
121
|
+
/** {@inheritDoc BorderChangeParts.top} */
|
|
122
|
+
readonly top: BorderLine | undefined;
|
|
123
|
+
/** {@inheritDoc BorderChangeParts.bottom} */
|
|
124
|
+
readonly bottom: BorderLine | undefined;
|
|
125
|
+
/** {@inheritDoc BorderChangeParts.left} */
|
|
126
|
+
readonly left: BorderLine | undefined;
|
|
127
|
+
/** {@inheritDoc BorderChangeParts.right} */
|
|
128
|
+
readonly right: BorderLine | undefined;
|
|
129
|
+
/** {@inheritDoc BorderChangeParts.insideHorizontal} */
|
|
130
|
+
readonly insideHorizontal: BorderLine | undefined;
|
|
131
|
+
/** {@inheritDoc BorderChangeParts.insideVertical} */
|
|
132
|
+
readonly insideVertical: BorderLine | undefined;
|
|
133
|
+
constructor(parts: BorderChangeParts);
|
|
134
|
+
/** Excel's Outline: `line` on the range's four outer edges. */
|
|
135
|
+
static outline(line: BorderLine): BorderChange;
|
|
136
|
+
/** Excel's Inside: `line` on every edge inside the range. */
|
|
137
|
+
static inside(line: BorderLine): BorderChange;
|
|
138
|
+
/** Excel's None: every edge of the range, outer and inner, without a line. */
|
|
139
|
+
static readonly none: BorderChange;
|
|
140
|
+
/** Whether the change sets no edge. @internal */
|
|
141
|
+
get isEmpty(): boolean;
|
|
142
|
+
/** The four sides a cell at `place` in its range shows once the change is set, from `borders`. @internal */
|
|
143
|
+
applyTo(borders: CellBorders, place: PlaceInRange): CellBorders;
|
|
144
|
+
/**
|
|
145
|
+
* The change as it is set on `range`. Over whole rows short of the whole Sheet, the left of column A is the
|
|
146
|
+
* range's left edge, and where the change sets no left edge of its own it takes the inside vertical line (the
|
|
147
|
+
* fourteenth Windows run, case 14). Over any other range the change is as it is. @internal
|
|
148
|
+
*/
|
|
149
|
+
on(range: CellRange): BorderChange;
|
|
150
|
+
/**
|
|
151
|
+
* The cells beside `range` across each outer edge the change sets, with the change that clears their record of
|
|
152
|
+
* it (the twelfth Windows run). An edge on the Sheet's outer edge has none. @internal
|
|
153
|
+
*/
|
|
154
|
+
beside(range: CellRange): Generator<{
|
|
155
|
+
range: CellRange;
|
|
156
|
+
borders: BorderChange;
|
|
157
|
+
}>;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/** The edges a Border change may set. */
|
|
161
|
+
export declare interface BorderChangeParts {
|
|
162
|
+
/** The range's top edge: the top side of its first row's cells. The cells above them lose their record of it. */
|
|
163
|
+
readonly top?: BorderLine | undefined;
|
|
164
|
+
/** The range's bottom edge: the bottom side of its last row's cells. The cells below them lose their record of it. */
|
|
165
|
+
readonly bottom?: BorderLine | undefined;
|
|
166
|
+
/** The range's left edge: the left side of its first column's cells. The cells to their left lose their record of it. */
|
|
167
|
+
readonly left?: BorderLine | undefined;
|
|
168
|
+
/** The range's right edge: the right side of its last column's cells. The cells to their right lose their record of it. */
|
|
169
|
+
readonly right?: BorderLine | undefined;
|
|
170
|
+
/** Every edge between two of the range's rows: the bottom side of the upper cell and the top side of the lower. */
|
|
171
|
+
readonly insideHorizontal?: BorderLine | undefined;
|
|
172
|
+
/** Every edge between two of the range's columns: the right side of the left cell and the left side of the right. */
|
|
173
|
+
readonly insideVertical?: BorderLine | undefined;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/** A Border (CONTEXT.md; ADR-0071): the line on one side of a cell, in one of Excel's thirteen line styles and a colour, or `none`. */
|
|
177
|
+
export declare class BorderLine {
|
|
178
|
+
/** The line style; `none` for no line. */
|
|
179
|
+
readonly style: BorderLineStyle;
|
|
180
|
+
/** The line's colour; Automatic for no line. */
|
|
181
|
+
readonly colour: CellColour;
|
|
182
|
+
/** A line in `style` and `colour`. `none` is no line, and has no colour. Throws a RangeError for a style that is not one. */
|
|
183
|
+
constructor(style: BorderLineStyle, colour?: CellColour);
|
|
184
|
+
/** No line. */
|
|
185
|
+
static readonly none: BorderLine;
|
|
186
|
+
/** Whether this is no line. */
|
|
187
|
+
get isNone(): boolean;
|
|
188
|
+
/** A value equal ones share, to key a map by. @internal */
|
|
189
|
+
get key(): string;
|
|
190
|
+
/** Whether `other` is the same line. */
|
|
191
|
+
equals(other: BorderLine): boolean;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/** Excel's thirteen line styles for a Border (ADR-0071), and `none`. No diagonals. */
|
|
195
|
+
export declare type BorderLineStyle = 'none' | 'hair' | 'thin' | 'medium' | 'thick' | 'double' | 'dotted' | 'dashed' | 'dashDot' | 'dashDotDot' | 'mediumDashed' | 'mediumDashDot' | 'mediumDashDotDot' | 'slantedDashDot';
|
|
196
|
+
|
|
197
|
+
/** One cell the Sheet holds. @internal */
|
|
198
|
+
declare class Cell {
|
|
199
|
+
entry: Entry | undefined;
|
|
200
|
+
value: Value | undefined;
|
|
201
|
+
/** The cell's own Number Format; `undefined` when it takes its row's or column's (ADR-0047). */
|
|
202
|
+
numberFormat: NumberFormat | undefined;
|
|
203
|
+
alignment: HorizontalAlignment | undefined;
|
|
204
|
+
font: CellFont | undefined;
|
|
205
|
+
fill: CellFill | undefined;
|
|
206
|
+
borders: CellBorders | undefined;
|
|
207
|
+
/** For an Anchor, the array its Formula computed (ADR-0125); `undefined` for a result of one Value. */
|
|
208
|
+
array: ValueArray | undefined;
|
|
209
|
+
/** For an Anchor: whether the last layout found its Spill Range in the way, so that it shows `#SPILL!`. */
|
|
210
|
+
spillBlocked: boolean;
|
|
211
|
+
/** For a cell of a Spill Range, the Anchor whose array gives its Value; it holds no Entry of its own. */
|
|
212
|
+
spilledFrom: CellAddress | undefined;
|
|
213
|
+
readonly address: CellAddress;
|
|
214
|
+
constructor(address: CellAddress);
|
|
215
|
+
/** Whether the cell records any part of a Cell Format of its own. */
|
|
216
|
+
get isFormatted(): boolean;
|
|
217
|
+
get isEmpty(): boolean;
|
|
218
|
+
/** What the cell shows over `inherited`: each part its own, else the level's. */
|
|
219
|
+
over(inherited: CellFormat): CellFormat;
|
|
220
|
+
/** Records the Cell Format `other` records of its own, and nothing else of it. */
|
|
221
|
+
takeFormatOf(other: Cell): void;
|
|
222
|
+
/** Records each part `change` sets as `shown` has it, and nothing where `inherited` gives the same; whether anything changed. */
|
|
223
|
+
take(change: CellFormatChange, shown: CellFormat, inherited: CellFormat): boolean;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Where a cell is on a Sheet: a zero-based row and column inside Excel's extent. Written in A1 form (`A1` is
|
|
228
|
+
* row 0, column 0; `XFD1048576` is the last cell). An address is where a cell is; a Reference is how a
|
|
229
|
+
* Formula names it (CONTEXT.md).
|
|
230
|
+
*/
|
|
231
|
+
export declare class CellAddress {
|
|
232
|
+
#private;
|
|
233
|
+
/** An address; one outside the Sheet's extent is refused with a `RangeError`, never clamped. */
|
|
234
|
+
constructor(row: number, column: number);
|
|
235
|
+
/** The zero-based row, 0 to 1,048,575. */
|
|
236
|
+
get row(): number;
|
|
237
|
+
/** The zero-based column, 0 to 16,383. */
|
|
238
|
+
get column(): number;
|
|
239
|
+
/** A number that names the address alone, row-major: two addresses are equal exactly where their keys are. */
|
|
240
|
+
get key(): number;
|
|
241
|
+
/** The address a key names. */
|
|
242
|
+
static fromKey(key: number): CellAddress;
|
|
243
|
+
/** Whether the two name the same cell. */
|
|
244
|
+
equals(other: CellAddress): boolean;
|
|
245
|
+
/** Row-major order: by row, then by column. */
|
|
246
|
+
compareTo(other: CellAddress): number;
|
|
247
|
+
/** Parses an address in A1 form, such as `B7` or `xfd1048576`; anything else is refused with a `FormatError`. */
|
|
248
|
+
static parse(text: string): CellAddress;
|
|
249
|
+
/**
|
|
250
|
+
* Parses an address in A1 form, or `undefined`. Letters may be in either case; `$` markers are not part
|
|
251
|
+
* of an address (they belong to a Reference) and are refused here.
|
|
252
|
+
*/
|
|
253
|
+
static tryParse(text: string): CellAddress | undefined;
|
|
254
|
+
/** The column's letters: 0 is `A`, 25 is `Z`, 26 is `AA`, 16,383 is `XFD`. */
|
|
255
|
+
static columnName(column: number): string;
|
|
256
|
+
/** Parses column letters (`A` to `XFD`, either case) to a zero-based column, or `undefined`. */
|
|
257
|
+
static tryParseColumn(letters: string): number | undefined;
|
|
258
|
+
/** The address in A1 form, such as `C12`. */
|
|
259
|
+
toString(): string;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* A cell's Borders (ADR-0071): the line on each of its four sides. Each cell records its own four sides, as Excel's
|
|
264
|
+
* files do, and the edge two cells share shows one line from either side: the upper cell's, or the left cell's for
|
|
265
|
+
* a vertical edge, where both record one, and otherwise whichever does (the twelfth Windows run). A border command
|
|
266
|
+
* records the edge on the cells it sets and clears the neighbour's record of it, so the later setting wins from
|
|
267
|
+
* either side (the eleventh run, case 7).
|
|
268
|
+
*/
|
|
269
|
+
export declare class CellBorders {
|
|
270
|
+
/** The line on the cell's top side. */
|
|
271
|
+
readonly top: BorderLine;
|
|
272
|
+
/** The line on the cell's bottom side. */
|
|
273
|
+
readonly bottom: BorderLine;
|
|
274
|
+
/** The line on the cell's left side. */
|
|
275
|
+
readonly left: BorderLine;
|
|
276
|
+
/** The line on the cell's right side. */
|
|
277
|
+
readonly right: BorderLine;
|
|
278
|
+
constructor(sides?: {
|
|
279
|
+
top?: BorderLine;
|
|
280
|
+
bottom?: BorderLine;
|
|
281
|
+
left?: BorderLine;
|
|
282
|
+
right?: BorderLine;
|
|
283
|
+
});
|
|
284
|
+
/** No line on any side. */
|
|
285
|
+
static readonly none: CellBorders;
|
|
286
|
+
/** These Borders with the sides given replaced. */
|
|
287
|
+
with(sides: {
|
|
288
|
+
top?: BorderLine;
|
|
289
|
+
bottom?: BorderLine;
|
|
290
|
+
left?: BorderLine;
|
|
291
|
+
right?: BorderLine;
|
|
292
|
+
}): CellBorders;
|
|
293
|
+
/** A value equal ones share, to key a map by. @internal */
|
|
294
|
+
get key(): string;
|
|
295
|
+
/** Whether `other` is the same Borders. */
|
|
296
|
+
equals(other: CellBorders): boolean;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* A colour a Cell Format records (ADR-0071): `automatic`, or an RGB value. A colour picked from the theme part of a
|
|
301
|
+
* palette is recorded as its RGB value. Automatic is not a recorded colour: a Font's Automatic is the Ink.
|
|
302
|
+
*/
|
|
303
|
+
export declare class CellColour {
|
|
304
|
+
#private;
|
|
305
|
+
private constructor();
|
|
306
|
+
/** Automatic: no colour recorded, so what is painted is decided where it is painted. */
|
|
307
|
+
static readonly automatic: CellColour;
|
|
308
|
+
/** An RGB colour, as `0xRRGGBB`. Throws a RangeError for a value outside `0x000000` to `0xFFFFFF`. */
|
|
309
|
+
static fromRgb(rgb: number): CellColour;
|
|
310
|
+
/** An RGB colour, from its red, green and blue, each 0 to 255. */
|
|
311
|
+
static fromParts(red: number, green: number, blue: number): CellColour;
|
|
312
|
+
/** A colour written `#RRGGBB`, in either case, or `undefined` for any other text. @internal */
|
|
313
|
+
static fromHex(text: string | undefined): CellColour | undefined;
|
|
314
|
+
/** Whether the colour is Automatic. */
|
|
315
|
+
get isAutomatic(): boolean;
|
|
316
|
+
/** The RGB value, as `0xRRGGBB`. Throws for Automatic, which records no RGB value. */
|
|
317
|
+
get rgb(): number;
|
|
318
|
+
/** A value equal ones share, to key a map by. @internal */
|
|
319
|
+
get key(): number;
|
|
320
|
+
/** Whether `other` is the same colour. */
|
|
321
|
+
equals(other: CellColour): boolean;
|
|
322
|
+
/** `Automatic`, or the RGB value as `#RRGGBB`. */
|
|
323
|
+
toString(): string;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* What a cell shows: its Value formatted by the cell's number format under the Sheet's culture, and where it sits.
|
|
328
|
+
* Whether it fits its column is the grid's to decide (ADR-0016): a number that does not fit becomes `####`, never a
|
|
329
|
+
* shorter number.
|
|
330
|
+
*/
|
|
331
|
+
export declare interface CellDisplay {
|
|
332
|
+
/** The formatted text; empty for a blank cell, and empty when `cannotShow` is set. */
|
|
333
|
+
readonly text: string;
|
|
334
|
+
/** The alignment resolved from the cell's setting: never `general`. */
|
|
335
|
+
readonly alignment: Exclude<HorizontalAlignment, 'general'>;
|
|
336
|
+
/** Whether the Value is a number (a date included). A number too wide for its column is shown as `####`; text is not (ADR-0016). */
|
|
337
|
+
readonly isNumber: boolean;
|
|
338
|
+
/**
|
|
339
|
+
* The number cannot be shown in its format at any width — a negative date, or a date after 31 December 9999 —
|
|
340
|
+
* or, from `Sheet.getDisplay` with a width, not in the width asked, and the cell shows `####`, as Excel's does.
|
|
341
|
+
*/
|
|
342
|
+
readonly cannotShow: boolean;
|
|
343
|
+
/**
|
|
344
|
+
* The colour the Number Format names for the section that showed the Value, kept where the number cannot be
|
|
345
|
+
* shown; `undefined` where that section names none, or where no section showed it (ADR-0071, SH-40). It takes
|
|
346
|
+
* precedence over the cell's Font colour, as Excel's does.
|
|
347
|
+
*/
|
|
348
|
+
readonly colour: NumberFormatColour | undefined;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* A cell's Fill (CONTEXT.md; ADR-0071): the one solid colour behind its text, or `none`, where the Paper shows. No
|
|
353
|
+
* patterns and no gradients.
|
|
354
|
+
*/
|
|
355
|
+
export declare class CellFill {
|
|
356
|
+
/** The Fill's colour, always an RGB value; `undefined` for `none`. */
|
|
357
|
+
readonly colour: CellColour | undefined;
|
|
358
|
+
private constructor();
|
|
359
|
+
/** No Fill: the Paper shows. Recorded on a cell, it hides a Fill its row or column records. */
|
|
360
|
+
static readonly none: CellFill;
|
|
361
|
+
/**
|
|
362
|
+
* A solid Fill in `colour`. Throws for Automatic: Excel's Fill offers No Color and colours, never Automatic, so
|
|
363
|
+
* there is nothing an Automatic Fill would mean.
|
|
364
|
+
*/
|
|
365
|
+
static solid(colour: CellColour): CellFill;
|
|
366
|
+
/** Whether this is `none`. */
|
|
367
|
+
get isNone(): boolean;
|
|
368
|
+
/** A value equal ones share, to key a map by. @internal */
|
|
369
|
+
get key(): number;
|
|
370
|
+
/** Whether `other` is the same Fill. */
|
|
371
|
+
equals(other: CellFill): boolean;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* A cell's Font (CONTEXT.md; ADR-0071): the colour and emphasis of its text. Not its size or typeface: every row
|
|
376
|
+
* has one height, and one digit width decides what fits.
|
|
377
|
+
*/
|
|
378
|
+
export declare class CellFont {
|
|
379
|
+
/** The text's colour; Automatic is the Ink. */
|
|
380
|
+
readonly colour: CellColour;
|
|
381
|
+
/** Bold. */
|
|
382
|
+
readonly bold: boolean;
|
|
383
|
+
/** Italic. */
|
|
384
|
+
readonly italic: boolean;
|
|
385
|
+
/** A single underline. */
|
|
386
|
+
readonly underline: boolean;
|
|
387
|
+
/** Strikethrough. */
|
|
388
|
+
readonly strikethrough: boolean;
|
|
389
|
+
constructor(parts?: {
|
|
390
|
+
colour?: CellColour;
|
|
391
|
+
bold?: boolean;
|
|
392
|
+
italic?: boolean;
|
|
393
|
+
underline?: boolean;
|
|
394
|
+
strikethrough?: boolean;
|
|
395
|
+
});
|
|
396
|
+
/** What a cell's text shows where no level records a Font: Automatic, with no emphasis. */
|
|
397
|
+
static readonly default: CellFont;
|
|
398
|
+
/** This Font with the parts given replaced. */
|
|
399
|
+
with(parts: {
|
|
400
|
+
colour?: CellColour;
|
|
401
|
+
bold?: boolean;
|
|
402
|
+
italic?: boolean;
|
|
403
|
+
underline?: boolean;
|
|
404
|
+
strikethrough?: boolean;
|
|
405
|
+
}): CellFont;
|
|
406
|
+
/** A value equal ones share, to key a map by. @internal */
|
|
407
|
+
get key(): string;
|
|
408
|
+
/** Whether `other` is the same Font. */
|
|
409
|
+
equals(other: CellFont): boolean;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
/**
|
|
413
|
+
* A cell's Cell Format as it shows (CONTEXT.md; ADR-0047, ADR-0071): each part from the level that records it, cell
|
|
414
|
+
* over row over column, and the part's default where no level does.
|
|
415
|
+
*/
|
|
416
|
+
export declare class CellFormat {
|
|
417
|
+
/** The Number Format. */
|
|
418
|
+
readonly numberFormat: NumberFormat;
|
|
419
|
+
/** The horizontal alignment. */
|
|
420
|
+
readonly alignment: HorizontalAlignment;
|
|
421
|
+
/** The Font. */
|
|
422
|
+
readonly font: CellFont;
|
|
423
|
+
/** The Fill. */
|
|
424
|
+
readonly fill: CellFill;
|
|
425
|
+
/** The Borders. */
|
|
426
|
+
readonly borders: CellBorders;
|
|
427
|
+
constructor(numberFormat: NumberFormat, alignment: HorizontalAlignment, font: CellFont, fill: CellFill, borders: CellBorders);
|
|
428
|
+
/** A value equal ones share, to key a map by. @internal */
|
|
429
|
+
get key(): string;
|
|
430
|
+
/** Whether `other` is the same Cell Format. */
|
|
431
|
+
equals(other: CellFormat): boolean;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
/**
|
|
435
|
+
* What a formatting command sets on the Cell Format of ranges (ADR-0071): every part that is given, each Font
|
|
436
|
+
* emphasis on its own, and every other part left as each cell has it. Its `borders` are relative to each range it
|
|
437
|
+
* is set on, so several ranges each get their own outline, as in Excel.
|
|
438
|
+
*/
|
|
439
|
+
export declare class CellFormatChange implements CellFormatChangeParts {
|
|
440
|
+
#private;
|
|
441
|
+
/** {@inheritDoc CellFormatChangeParts.numberFormat} */
|
|
442
|
+
readonly numberFormat: NumberFormat | undefined;
|
|
443
|
+
/** {@inheritDoc CellFormatChangeParts.alignment} */
|
|
444
|
+
readonly alignment: HorizontalAlignment | undefined;
|
|
445
|
+
/** {@inheritDoc CellFormatChangeParts.fontColour} */
|
|
446
|
+
readonly fontColour: CellColour | undefined;
|
|
447
|
+
/** {@inheritDoc CellFormatChangeParts.bold} */
|
|
448
|
+
readonly bold: boolean | undefined;
|
|
449
|
+
/** {@inheritDoc CellFormatChangeParts.italic} */
|
|
450
|
+
readonly italic: boolean | undefined;
|
|
451
|
+
/** {@inheritDoc CellFormatChangeParts.underline} */
|
|
452
|
+
readonly underline: boolean | undefined;
|
|
453
|
+
/** {@inheritDoc CellFormatChangeParts.strikethrough} */
|
|
454
|
+
readonly strikethrough: boolean | undefined;
|
|
455
|
+
/** {@inheritDoc CellFormatChangeParts.fill} */
|
|
456
|
+
readonly fill: CellFill | undefined;
|
|
457
|
+
/** {@inheritDoc CellFormatChangeParts.borders} */
|
|
458
|
+
readonly borders: BorderChange | undefined;
|
|
459
|
+
constructor(parts: CellFormatChangeParts);
|
|
460
|
+
/** This change with its Borders replaced. @internal */
|
|
461
|
+
withBorders(borders: BorderChange): CellFormatChange;
|
|
462
|
+
/** Whether the change sets no part at all. */
|
|
463
|
+
get isEmpty(): boolean;
|
|
464
|
+
/** Whether the change sets any part of the Font. @internal */
|
|
465
|
+
get setsFont(): boolean;
|
|
466
|
+
/** Whether the change sets any side. @internal */
|
|
467
|
+
get setsBorders(): boolean;
|
|
468
|
+
/** Whether the change sets a part that `level` records. @internal */
|
|
469
|
+
touches(level: AxisFormat): boolean;
|
|
470
|
+
/** What a cell that showed `shown` shows once the change is set on it, at `place` in its range. @internal */
|
|
471
|
+
applyTo(shown: CellFormat, place: PlaceInRange): CellFormat;
|
|
472
|
+
/** `font` with the emphases and the colour the change sets. @internal */
|
|
473
|
+
applyToFont(font: CellFont): CellFont;
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
/** The parts a Cell Format change may set. */
|
|
477
|
+
export declare interface CellFormatChangeParts {
|
|
478
|
+
/** The Number Format to set; `NumberFormat.general` sets General. */
|
|
479
|
+
readonly numberFormat?: NumberFormat | undefined;
|
|
480
|
+
/** The horizontal alignment to set; `general` sets General. */
|
|
481
|
+
readonly alignment?: HorizontalAlignment | undefined;
|
|
482
|
+
/** The Font colour to set; Automatic sets the Ink. */
|
|
483
|
+
readonly fontColour?: CellColour | undefined;
|
|
484
|
+
/** Bold set on, or off. */
|
|
485
|
+
readonly bold?: boolean | undefined;
|
|
486
|
+
/** Italic set on, or off. */
|
|
487
|
+
readonly italic?: boolean | undefined;
|
|
488
|
+
/** A single underline set on, or off. */
|
|
489
|
+
readonly underline?: boolean | undefined;
|
|
490
|
+
/** Strikethrough set on, or off. */
|
|
491
|
+
readonly strikethrough?: boolean | undefined;
|
|
492
|
+
/** The Fill to set; `CellFill.none` takes it away. */
|
|
493
|
+
readonly fill?: CellFill | undefined;
|
|
494
|
+
/** The Borders to set, relative to each range the change is set on. */
|
|
495
|
+
readonly borders?: BorderChange | undefined;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
/** What a formatting command did, and what undoing it puts back. @internal */
|
|
499
|
+
declare interface CellFormatOutcome {
|
|
500
|
+
readonly change: SheetChange;
|
|
501
|
+
readonly before: readonly AddressedState[];
|
|
502
|
+
readonly rowsBefore: ReadonlyMap<number, AxisFormat>;
|
|
503
|
+
readonly columnsBefore: ReadonlyMap<number, AxisFormat>;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
/** What a change set on several ranges did: each range's outcome, in the order they were set. @internal */
|
|
507
|
+
declare interface CellFormatsOutcome {
|
|
508
|
+
readonly change: SheetChange;
|
|
509
|
+
readonly parts: readonly CellFormatOutcome[];
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
/**
|
|
513
|
+
* A rectangle of cells on a Sheet, inclusive at both corners, held from its top-left corner (`first`) to its
|
|
514
|
+
* bottom-right one (`last`) whichever corners it was made from. Written `A1` for one cell and `A1:B2`
|
|
515
|
+
* otherwise.
|
|
516
|
+
*/
|
|
517
|
+
export declare class CellRange {
|
|
518
|
+
#private;
|
|
519
|
+
/** The rectangle spanned by two corners, in either order; one corner alone is that one cell. */
|
|
520
|
+
constructor(corner1: CellAddress, corner2?: CellAddress);
|
|
521
|
+
/** The top-left cell. */
|
|
522
|
+
get first(): CellAddress;
|
|
523
|
+
/** The bottom-right cell. */
|
|
524
|
+
get last(): CellAddress;
|
|
525
|
+
/** How many rows it spans. */
|
|
526
|
+
get rowCount(): number;
|
|
527
|
+
/** How many columns it spans. */
|
|
528
|
+
get columnCount(): number;
|
|
529
|
+
/** How many cells it holds. */
|
|
530
|
+
get cellCount(): number;
|
|
531
|
+
/** Whether `address` lies inside it. */
|
|
532
|
+
contains(address: CellAddress): boolean;
|
|
533
|
+
/** Whether it spans every row: whole columns, such as `B:D` (ADR-0047). */
|
|
534
|
+
get isWholeColumns(): boolean;
|
|
535
|
+
/** Whether it spans every column: whole rows, such as `2:4` (ADR-0047). */
|
|
536
|
+
get isWholeRows(): boolean;
|
|
537
|
+
/** Whether the two are the same rectangle. */
|
|
538
|
+
equals(other: CellRange): boolean;
|
|
539
|
+
/** Whole columns `first` to `last` (0 is `A`), as `A:A` names one. */
|
|
540
|
+
static wholeColumns(first: number, last: number): CellRange;
|
|
541
|
+
/** Whole rows `first` to `last` (0 is row `1`), as `1:1` names one. */
|
|
542
|
+
static wholeRows(first: number, last: number): CellRange;
|
|
543
|
+
/** Its cells in row-major order. */
|
|
544
|
+
cells(): IterableIterator<CellAddress>;
|
|
545
|
+
/** Parses `B7`, `B7:C9` (corners in either order, letters in either case), whole columns `B:D` or whole rows `2:4`; no `$`. Anything else is a `FormatError`. */
|
|
546
|
+
static parse(text: string): CellRange;
|
|
547
|
+
/** Parses as `parse` does, or `undefined`. */
|
|
548
|
+
static tryParse(text: string): CellRange | undefined;
|
|
549
|
+
/** `A1` for one cell, `A1:B2` otherwise. */
|
|
550
|
+
toString(): string;
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
/** What the evaluator reads cells through: the Values of one recalculation, blank as `undefined`. */
|
|
554
|
+
declare interface CellReader {
|
|
555
|
+
read(address: CellAddress): Value | undefined;
|
|
556
|
+
/** The addresses inside `area` that are not blank, in row-major order. */
|
|
557
|
+
nonBlankIn(area: Area): Iterable<CellAddress>;
|
|
558
|
+
/**
|
|
559
|
+
* A Linked Table's column (ADR-0049): the column's Values, or `#NAME?` for a table never declared, `#REF!`
|
|
560
|
+
* for a column it does not have, and `#GETTING_DATA` before its first snapshot.
|
|
561
|
+
*/
|
|
562
|
+
tableColumn(table: string, column: string): Operand;
|
|
563
|
+
/** Whether a Linked Table of this name is declared, the name read without regard to case (ADR-0049). */
|
|
564
|
+
isLinkedTable(name: string): boolean;
|
|
565
|
+
/** The Sheet Day `TODAY` answers (ADR-0121), or `undefined` while it is not known. */
|
|
566
|
+
readonly today: SheetDay | undefined;
|
|
567
|
+
/** The moment `NOW` answers, read once for the recalculation (ADR-0124); `undefined` while it is not known. */
|
|
568
|
+
readonly now: SheetMoment | undefined;
|
|
569
|
+
/**
|
|
570
|
+
* The cells of the Sheet a Reference's qualifier names, as this recalculation reads them: this Sheet's for
|
|
571
|
+
* no qualifier, another Sheet's of the Workbook for its name, without regard to case; `undefined` for a
|
|
572
|
+
* name no Sheet of the Workbook has, which is `#REF!` (ADR-0331).
|
|
573
|
+
*/
|
|
574
|
+
resolve(sheetName: string | undefined): CellReader | undefined;
|
|
575
|
+
/**
|
|
576
|
+
* The cells of every Sheet a 3D Reference spans (ADR-0331 §7), in tab order; `undefined` when the Workbook
|
|
577
|
+
* has no Sheet of one of the names, which is `#NAME?`, as Excel's.
|
|
578
|
+
*/
|
|
579
|
+
resolveSpan(first: string, last: string): readonly CellReader[] | undefined;
|
|
580
|
+
/**
|
|
581
|
+
* The draw of the `RAND` or `RANDBETWEEN` call at `place` in the Formula of `cell` (ADR-0180), from the
|
|
582
|
+
* Sheet Seed and the count of changes; `undefined` while the Sheet has no seed.
|
|
583
|
+
*/
|
|
584
|
+
draw(cell: CellAddress, place: number): bigint | undefined;
|
|
585
|
+
/** `A1#` (ADR-0125): the array the Anchor at `anchor` spills, as this recalculation leaves it; `#REF!` when it does not spill. */
|
|
586
|
+
spill(anchor: CellAddress): Operand;
|
|
587
|
+
/**
|
|
588
|
+
* The Formula whose result a cell shows: its own, or for a cell of a Spill Range its Anchor's (ADR-0125);
|
|
589
|
+
* `undefined` for a constant or a blank.
|
|
590
|
+
*/
|
|
591
|
+
formulaAt(address: CellAddress): Node_2 | undefined;
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
/**
|
|
595
|
+
* What one cell holds and shows, compared before and after an operation. The parts of its Cell Format are the
|
|
596
|
+
* cell's own; `undefined` takes the row's or the column's (ADR-0047, ADR-0071). @internal
|
|
597
|
+
*/
|
|
598
|
+
declare class CellState {
|
|
599
|
+
readonly entry: Entry | undefined;
|
|
600
|
+
readonly value: Value | undefined;
|
|
601
|
+
readonly numberFormat: NumberFormat | undefined;
|
|
602
|
+
readonly alignment: HorizontalAlignment | undefined;
|
|
603
|
+
readonly font: CellFont | undefined;
|
|
604
|
+
readonly fill: CellFill | undefined;
|
|
605
|
+
readonly borders: CellBorders | undefined;
|
|
606
|
+
constructor(entry: Entry | undefined, value: Value | undefined, numberFormat: NumberFormat | undefined, alignment: HorizontalAlignment | undefined, font: CellFont | undefined, fill: CellFill | undefined, borders: CellBorders | undefined);
|
|
607
|
+
static readonly blank: CellState;
|
|
608
|
+
/** The same cell as recorded: Entry and Cell Format, the Value left out. */
|
|
609
|
+
get recorded(): CellState;
|
|
610
|
+
/** This state with its Entry replaced. */
|
|
611
|
+
withEntry(entry: Entry | undefined): CellState;
|
|
612
|
+
/** This state with its Cell Format replaced, part by part. */
|
|
613
|
+
withFormat(format: {
|
|
614
|
+
numberFormat: NumberFormat | undefined;
|
|
615
|
+
alignment: HorizontalAlignment | undefined;
|
|
616
|
+
font: CellFont | undefined;
|
|
617
|
+
fill: CellFill | undefined;
|
|
618
|
+
borders: CellBorders | undefined;
|
|
619
|
+
}): CellState;
|
|
620
|
+
sameRecord(other: CellState): boolean;
|
|
621
|
+
/** Whether the two record the same Cell Format of their own. */
|
|
622
|
+
sameFormat(other: {
|
|
623
|
+
numberFormat: NumberFormat | undefined;
|
|
624
|
+
alignment: HorizontalAlignment | undefined;
|
|
625
|
+
font: CellFont | undefined;
|
|
626
|
+
fill: CellFill | undefined;
|
|
627
|
+
borders: CellBorders | undefined;
|
|
628
|
+
}): boolean;
|
|
629
|
+
/** The Cell Format the state shows, where it records nothing of a part, the part's default. */
|
|
630
|
+
get cellFormat(): CellFormat;
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
/** Excel's extent: how many columns a Sheet has, 16,384 (`A` to `XFD`). */
|
|
634
|
+
export declare const columnCount = 16384;
|
|
635
|
+
|
|
636
|
+
/**
|
|
637
|
+
* What completion offers at the caret, following Excel's triggers (ADR-0051, ADR-0058):
|
|
638
|
+
*
|
|
639
|
+
* - at the end of a name standing where an operand can start, the declared functions and `linkedTables`
|
|
640
|
+
* beginning with it, without regard to case;
|
|
641
|
+
*
|
|
642
|
+
* - inside the brackets of `Table[`, the columns of that table beginning with the column typed so far, in the
|
|
643
|
+
* table's order, and nothing else: not `@` or `#All`, which the grammar refuses (ADR-0047). The brackets are
|
|
644
|
+
* a context of their own, so at an argument whose values are a fixed list they list the columns too;
|
|
645
|
+
*
|
|
646
|
+
* - at an argument that takes one of a fixed list of values (`DeclaredFunction.valuesOf`), those values, in
|
|
647
|
+
* Excel's order, and nothing else. They are listed before anything is typed, and only while nothing of the
|
|
648
|
+
* argument stands after the caret, white space included. A number lists the value it is alone (`0` lists
|
|
649
|
+
* `0 - Exact match`) and nothing when it is no value (`4`); any other text lists every value.
|
|
650
|
+
*
|
|
651
|
+
* `undefined` anywhere else — after `=`, an operator, `(` or `,` at any other argument or inside a grouping
|
|
652
|
+
* parenthesis, inside text in quotes, a Reference, a number — and when nothing matches.
|
|
653
|
+
*
|
|
654
|
+
* @param text - The text being edited.
|
|
655
|
+
* @param caret - Where the caret stands in it. Throws a RangeError outside 0 to the text's length.
|
|
656
|
+
* @param linkedTables - The Linked Tables' names.
|
|
657
|
+
* @param columnsOf - The columns of the Linked Table a name names, found without regard to case, in the
|
|
658
|
+
* table's order; `undefined` for a name no table has. Left out, no table's columns are known, and nothing is
|
|
659
|
+
* listed after `Table[`.
|
|
660
|
+
*/
|
|
661
|
+
export declare function completeFormula(text: string, caret: number, linkedTables: Iterable<string>, columnsOf?: (name: string) => readonly string[] | undefined): FormulaCompletion | undefined;
|
|
662
|
+
|
|
663
|
+
/** One candidate completion offers (ADR-0051, ADR-0058). */
|
|
664
|
+
export declare interface CompletionCandidate {
|
|
665
|
+
/** What the list shows: the name as declared, or for an argument's value, Excel's text for it (`0 - Exact match`). */
|
|
666
|
+
readonly name: string;
|
|
667
|
+
/** What it names. */
|
|
668
|
+
readonly kind: CompletionKind;
|
|
669
|
+
/**
|
|
670
|
+
* What accepting it writes in place of what was typed: a function's name and its `(`, a table's name, a
|
|
671
|
+
* column's name with any character the grammar reads specially escaped by `'`, an argument's value (`0`).
|
|
672
|
+
*/
|
|
673
|
+
readonly insertText: string;
|
|
674
|
+
/** One sentence for a function; `undefined` for the others. */
|
|
675
|
+
readonly description: string | undefined;
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
/**
|
|
679
|
+
* What a completion candidate names: a function of the declared set (`DeclaredFunction`), a Linked Table
|
|
680
|
+
* declared on the Workbook (ADR-0049), a column of the Linked Table named before `[` (ADR-0058), or one of the
|
|
681
|
+
* values an argument takes from a fixed list (ADR-0058).
|
|
682
|
+
*/
|
|
683
|
+
export declare type CompletionKind = 'function' | 'linkedTable' | 'linkedTableColumn' | 'argumentValue';
|
|
684
|
+
|
|
685
|
+
/**
|
|
686
|
+
* A Value written as a Formula writes a constant of its kind (ADR-0058): text in double quotes, with any `"`
|
|
687
|
+
* in it doubled (`"R-4471"`); a number in the invariant form the engine writes a number constant in (`1250`,
|
|
688
|
+
* `-0.5`); a boolean as `TRUE` or `FALSE`. `undefined` for an Error Value: a lookup by one finds nothing, so
|
|
689
|
+
* nothing is written for it.
|
|
690
|
+
*/
|
|
691
|
+
export declare function constantText(value: Value): string | undefined;
|
|
692
|
+
|
|
693
|
+
/**
|
|
694
|
+
* A Sheet's culture, read from its locale: a BCP 47 tag, or `"invariant"` for .NET's invariant culture
|
|
695
|
+
* (ADR-0370, section 10). Only the locales whose data the engine is held to are known; any other is
|
|
696
|
+
* refused by name, never read as some other culture's.
|
|
697
|
+
*/
|
|
698
|
+
export declare class Culture {
|
|
699
|
+
#private;
|
|
700
|
+
private constructor();
|
|
701
|
+
/** The invariant culture, which reads as .NET's `InvariantCulture` does. */
|
|
702
|
+
static readonly invariant: Culture;
|
|
703
|
+
/**
|
|
704
|
+
* The culture of a locale: `"invariant"`, or one of `en-US`, `en-GB`, `de-DE`, `ja-JP` and `fr-FR`, in
|
|
705
|
+
* any case. Another tag is refused with a `RangeError`: the engine holds no data for it that it has
|
|
706
|
+
* checked against .NET's.
|
|
707
|
+
*/
|
|
708
|
+
static of(locale: string): Culture;
|
|
709
|
+
/** `CultureInfo.Name`: the BCP 47 tag; empty for the invariant culture, as .NET writes it in a Sheet Document. */
|
|
710
|
+
get name(): string;
|
|
711
|
+
/** The locale the culture was asked for by, `"invariant"` for the invariant culture. */
|
|
712
|
+
get locale(): string;
|
|
713
|
+
/** The culture's data: its separators, names and patterns, as .NET's culture records them. @internal */
|
|
714
|
+
get data(): CultureData;
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
/** The parts of a culture the engine reads: `CultureInfo`'s number and date formats, for one locale. */
|
|
718
|
+
declare interface CultureData {
|
|
719
|
+
/** The locale's BCP 47 tag, as `CultureInfo.Name`; empty for the invariant culture. */
|
|
720
|
+
readonly name: string;
|
|
721
|
+
/** `TwoLetterISOLanguageName`: `en`, `de`, `ja`; `iv` for the invariant culture. */
|
|
722
|
+
readonly twoLetterLanguage: string;
|
|
723
|
+
readonly numberDecimalSeparator: string;
|
|
724
|
+
readonly numberGroupSeparator: string;
|
|
725
|
+
/** `NumberFormatInfo.NumberGroupSizes`: the digits in each group, the units' group first. */
|
|
726
|
+
readonly numberGroupSizes: readonly number[];
|
|
727
|
+
readonly negativeSign: string;
|
|
728
|
+
readonly currencySymbol: string;
|
|
729
|
+
/** `NumberFormatInfo.CurrencyPositivePattern`: 0 is `$n`, 1 `n$`, 2 `$ n`, 3 `n $`. */
|
|
730
|
+
readonly currencyPositivePattern: number;
|
|
731
|
+
/** `NumberFormatInfo.CurrencyNegativePattern`, 0 to 16. */
|
|
732
|
+
readonly currencyNegativePattern: number;
|
|
733
|
+
readonly currencyDecimalDigits: number;
|
|
734
|
+
readonly shortDatePattern: string;
|
|
735
|
+
readonly longTimePattern: string;
|
|
736
|
+
readonly shortTimePattern: string;
|
|
737
|
+
readonly dateSeparator: string;
|
|
738
|
+
/** The twelve months' names, January first. */
|
|
739
|
+
readonly monthNames: readonly string[];
|
|
740
|
+
readonly abbreviatedMonthNames: readonly string[];
|
|
741
|
+
/** The seven days' names, Sunday first. */
|
|
742
|
+
readonly dayNames: readonly string[];
|
|
743
|
+
readonly abbreviatedDayNames: readonly string[];
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
/**
|
|
747
|
+
* F4 (ADR-0051, 2026-09-29; as Excel does it, the seventeenth Windows run): the Reference at the caret cycled
|
|
748
|
+
* to its next form — `A1` → `$A$1` → `A$1` → `$A1` → `A1` — answered with the span of what was rewritten. The
|
|
749
|
+
* Reference at the caret is the one the caret is inside or touching, on either side; the two ends of a cell
|
|
750
|
+
* range are References of their own, so only the end at the caret cycles, from its own form. With a
|
|
751
|
+
* selection, every end it covers, overlaps or touches cycles, each to the next form of the first one. Whole
|
|
752
|
+
* columns and whole rows are one Reference of two forms (`A:A` ↔ `$A:$A`); a Sheet qualifier is kept, before
|
|
753
|
+
* the first end, and only the cell part cycles. The rewritten parts' column letters are written in upper
|
|
754
|
+
* case; every other character stays as it was typed. The span answered runs from the first Reference
|
|
755
|
+
* rewritten, after its Sheet qualifier, to the end of the last. `undefined` — nothing changes — for text that
|
|
756
|
+
* is not a Formula, and where no Reference is at the caret or in the selection.
|
|
757
|
+
*
|
|
758
|
+
* @param text - The text being edited.
|
|
759
|
+
* @param selectionStart - Where the selection starts, or the caret.
|
|
760
|
+
* @param selectionEnd - Where the selection ends; `selectionStart` for a caret. Throws a RangeError when the
|
|
761
|
+
* selection does not lie inside the text.
|
|
762
|
+
*/
|
|
763
|
+
export declare function cycleReference(text: string, selectionStart: number, selectionEnd: number): ReferenceCycle | undefined;
|
|
764
|
+
|
|
765
|
+
/**
|
|
766
|
+
* A function of the declared set (ADR-0047): each gives Excel's result, and a name outside the set is `#NAME?`.
|
|
767
|
+
* What completion offers and what the argument hint shows (ADR-0051).
|
|
768
|
+
*/
|
|
769
|
+
export declare class DeclaredFunction {
|
|
770
|
+
#private;
|
|
771
|
+
/** The name in upper case, such as `SUM`. */
|
|
772
|
+
readonly name: string;
|
|
773
|
+
/** The argument list as Excel documents it, optional ones in brackets: `number1, [number2], ...`. */
|
|
774
|
+
readonly arguments: string;
|
|
775
|
+
/** One sentence saying what it returns. */
|
|
776
|
+
readonly description: string;
|
|
777
|
+
private constructor();
|
|
778
|
+
/** Every function the engine declares, in alphabetical order. */
|
|
779
|
+
static get all(): readonly DeclaredFunction[];
|
|
780
|
+
/** The signature a hint shows: `SUM(number1, [number2], ...)`. */
|
|
781
|
+
get signature(): string;
|
|
782
|
+
/** The declared function of that name, in any case, or `undefined` when the name is not declared. */
|
|
783
|
+
static find(name: string): DeclaredFunction | undefined;
|
|
784
|
+
/**
|
|
785
|
+
* The values argument `index` (from 0) takes when it takes one of a fixed list, in Excel's order and with
|
|
786
|
+
* Excel's texts, such as `XLOOKUP`'s `match_mode`: what completion lists there (ADR-0058). Empty for an
|
|
787
|
+
* argument that takes any value.
|
|
788
|
+
*/
|
|
789
|
+
valuesOf(index: number): readonly ArgumentValue[];
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
/**
|
|
793
|
+
* Writes each Workbook Document raised as what changed since the one it wrote before: an object of three keys,
|
|
794
|
+
* `"number"`, counting the documents written from 1, `"workbook"`, a Workbook Document recording every part whole but
|
|
795
|
+
* the cells, and `"emptied"`, one entry per Sheet in the same order. A Sheet whose entry is `null` holds all its cells;
|
|
796
|
+
* any other holds only the cells that changed since the Sheet of its name was written, in the document numbered one
|
|
797
|
+
* less, and its entry lists the addresses of the cells emptied since. The first document, and the first after
|
|
798
|
+
* `forget`, are written whole.
|
|
799
|
+
*/
|
|
800
|
+
export declare class DocumentChanges {
|
|
801
|
+
#private;
|
|
802
|
+
/** Forgets what was written, as when its reader stops reading: the next document is written whole. */
|
|
803
|
+
forget(): void;
|
|
804
|
+
/** `document` as what changed since the document written before it, as JSON. */
|
|
805
|
+
write(document: WorkbookDocument): string;
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
/**
|
|
809
|
+
* What a user put into a cell: a constant or a Formula (CONTEXT.md). An Entry is what a Sheet Document records,
|
|
810
|
+
* and what the user sees again when editing the cell. A constant is held already parsed, never as the text that
|
|
811
|
+
* was typed (ADR-0048); a Formula is held in Excel's invariant syntax (ADR-0047). Immutable.
|
|
812
|
+
*/
|
|
813
|
+
export declare class Entry {
|
|
814
|
+
/** The constant, or `undefined` when this Entry is a Formula. */
|
|
815
|
+
readonly constant: Value | undefined;
|
|
816
|
+
/**
|
|
817
|
+
* The Formula in invariant syntax, beginning with `=`: the whitespace as it was typed where Excel keeps it
|
|
818
|
+
* (not at the end, nor before a `,`), and each token as the engine writes it (function names and References
|
|
819
|
+
* in upper case, `,` between arguments, `.` as the decimal separator) (ADR-0047); `undefined` when this Entry
|
|
820
|
+
* is a constant.
|
|
821
|
+
*/
|
|
822
|
+
readonly formula: string | undefined;
|
|
823
|
+
/** The parsed Formula. @internal */
|
|
824
|
+
readonly parsed: Node_2 | undefined;
|
|
825
|
+
private constructor();
|
|
826
|
+
/** Whether this Entry is a Formula. */
|
|
827
|
+
get isFormula(): boolean;
|
|
828
|
+
/**
|
|
829
|
+
* The functions the Formula calls that are outside ExSheet's declared set, in the text's order, each once
|
|
830
|
+
* without regard to case: each gives `#NAME?` (ADR-0047). Empty for a constant, and for a Formula that calls
|
|
831
|
+
* only declared functions. A reader of another program's workbook lists them before the user meets them
|
|
832
|
+
* (ADR-0330 §4).
|
|
833
|
+
*/
|
|
834
|
+
get undeclaredFunctions(): readonly string[];
|
|
835
|
+
/**
|
|
836
|
+
* The names the Formula reads that nothing in it binds — not a function's, not a `LET`'s, not a `LAMBDA`'s
|
|
837
|
+
* parameter, not `TRUE` or `FALSE` — in the text's order, each once without regard to case. ExSheet defines
|
|
838
|
+
* no names, so each gives `#NAME?`; in Excel each is a defined name, or an Excel Table's, where the workbook
|
|
839
|
+
* has one (ADR-0047, ADR-0330 §4). Empty for a constant.
|
|
840
|
+
*/
|
|
841
|
+
get unboundNames(): readonly string[];
|
|
842
|
+
/**
|
|
843
|
+
* The Entry as a copy writes it `rows` down and `columns` across from where it stands, as Excel writes a
|
|
844
|
+
* copied Formula and a shared formula's cells (ADR-0048, ADR-0330 §4): each relative part of a Reference
|
|
845
|
+
* moves by that distance, each absolute part (`$`) stays, a whole column or row spans every row or column
|
|
846
|
+
* still, and a Reference moved off the Sheet is written `#REF!`. A constant, or a move of nothing, is this
|
|
847
|
+
* Entry. Negative distances move up and left.
|
|
848
|
+
*/
|
|
849
|
+
movedBy(rows: number, columns: number): Entry;
|
|
850
|
+
/**
|
|
851
|
+
* The Entry with its References mapped (`rewriteReferences`); the same instance when nothing changed.
|
|
852
|
+
* @internal
|
|
853
|
+
*/
|
|
854
|
+
static rewrite(entry: Entry, map: (reference: Reference) => Reference | undefined, requalify?: (sheet: string) => string | undefined): Entry;
|
|
855
|
+
/**
|
|
856
|
+
* The constant Entry of an Error Value written exactly as Excel writes one in a file, case and all (`#N/A`,
|
|
857
|
+
* `#DIV/0!`, `#SPILL!`), or `undefined` when the text is no Error Value a cell can hold: `#GETTING_DATA` and
|
|
858
|
+
* `#CIRC!` are not one, and nothing else is read as a Formula or a number. A reader of another program's
|
|
859
|
+
* workbook takes an error cell through it (ADR-0330 §4).
|
|
860
|
+
*/
|
|
861
|
+
static fromErrorText(text: string): Entry | undefined;
|
|
862
|
+
/**
|
|
863
|
+
* A constant Entry. `#GETTING_DATA` and `#CIRC!` are states of a computation and cannot be one, and neither
|
|
864
|
+
* can the `#VALUE!` of a cell whose Formula ExSheet refuses, read from it: held as a constant it would be an
|
|
865
|
+
* Error Value a Formula can catch (ADR-0047; 2026-10-12, decided with the user: a refusal is never caught,
|
|
866
|
+
* anywhere). Throws a `RangeError` for one of those.
|
|
867
|
+
*/
|
|
868
|
+
static fromValue(constant: Value): Entry;
|
|
869
|
+
/**
|
|
870
|
+
* A Formula Entry from its invariant text, which begins with `=`; `Entry.parse` reads the same text as the
|
|
871
|
+
* same Formula. Throws a `FormulaSyntaxError` when the Formula cannot be read. @internal
|
|
872
|
+
*/
|
|
873
|
+
static fromFormula(formula: string): Entry;
|
|
874
|
+
/**
|
|
875
|
+
* Reads text as a user typed it into a cell: text beginning with `=` is a Formula in invariant syntax;
|
|
876
|
+
* anything else is a constant read under `culture` and recorded parsed (ADR-0048). Empty text is no Entry,
|
|
877
|
+
* and gives `undefined`. Throws a `FormulaSyntaxError` when the text is a Formula that cannot be read, or
|
|
878
|
+
* text with a leading `+` or `-` that Excel reads as a Formula using syntax the engine does not implement
|
|
879
|
+
* (`-B2 C2`) or nested past the limits the engine reads.
|
|
880
|
+
*/
|
|
881
|
+
static parse(typed: string, culture: Culture): Entry | undefined;
|
|
882
|
+
/**
|
|
883
|
+
* Text typed with a leading `+` or `-` that is not a constant is the Formula it spells after an `=`, as
|
|
884
|
+
* Excel's cell editor reads it: `+A1` is `=+A1` and `-A1` is `=-A1` (observed with real keys). Text that does
|
|
885
|
+
* not read as a Formula that way stays text: `undefined`. Throws where Excel reads the text as a Formula whose
|
|
886
|
+
* syntax the engine does not implement (`-B2 C2`, TYPED-054; ADR-0047, third run), or one refused for its
|
|
887
|
+
* size alone: kept as text it would quietly be another Entry than the one typed. @internal
|
|
888
|
+
*/
|
|
889
|
+
static signedFormula(typed: string): Entry | undefined;
|
|
890
|
+
/** Whether typed text would not be kept as text because of its leading sign: `signedFormula` reads it as a Formula, or refuses it. @internal */
|
|
891
|
+
static isSignedFormula(typed: string): boolean;
|
|
892
|
+
/** Two Entries are equal when they hold the same constant (exactly) or the same Formula text. */
|
|
893
|
+
equals(other: Entry | undefined): boolean;
|
|
894
|
+
/** Whether two Entries that may be absent are equal: both absent, or equal. */
|
|
895
|
+
static same(a: Entry | undefined, b: Entry | undefined): boolean;
|
|
896
|
+
/** The Formula text, or the constant's invariant diagnostic form. */
|
|
897
|
+
toString(): string;
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
/** An Entry set on a cell, or cleared (`undefined`). */
|
|
901
|
+
export declare type EntryOfCell = readonly [CellAddress, Entry | undefined];
|
|
902
|
+
|
|
903
|
+
declare class ErrorNode extends NodeBase {
|
|
904
|
+
readonly kind = "error";
|
|
905
|
+
readonly error: ErrorValue;
|
|
906
|
+
constructor(error: ErrorValue);
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
/**
|
|
910
|
+
* An Error Value, written as a cell shows it: Excel's set, `#GETTING_DATA` with the stricter meaning
|
|
911
|
+
* ADR-0049 gives it, and `#CIRC!`, the one Error Value ExSheet adds (ADR-0047). Error Values are data; they
|
|
912
|
+
* propagate through every Formula that uses them.
|
|
913
|
+
*/
|
|
914
|
+
export declare type ErrorValue = '#NULL!' | '#DIV/0!' | '#VALUE!' | '#REF!' | '#NAME?' | '#NUM!' | '#N/A' | '#GETTING_DATA' | '#CIRC!' | '#SPILL!' | '#CALC!' | '#FIELD!' | '#BLOCKED!' | '#CONNECT!' | '#UNKNOWN!';
|
|
915
|
+
|
|
916
|
+
/**
|
|
917
|
+
* Evaluates a parsed Formula to a Value, as Excel does: IEEE doubles, a blank read as 0, Error Values carried
|
|
918
|
+
* through, left to right (ADR-0047).
|
|
919
|
+
*/
|
|
920
|
+
declare class Evaluator {
|
|
921
|
+
#private;
|
|
922
|
+
readonly culture: Culture;
|
|
923
|
+
readonly cells: CellReader;
|
|
924
|
+
/** The cell whose Formula is being evaluated, which `ROW()` and `COLUMN()` read; `undefined` for a Formula evaluated in no cell. */
|
|
925
|
+
self: CellAddress | undefined;
|
|
926
|
+
constructor(cells: CellReader, culture: Culture);
|
|
927
|
+
/**
|
|
928
|
+
* A Formula's result. It is never blank: a Formula that reads an empty cell shows 0. When the Formula's last
|
|
929
|
+
* operation is an addition or a subtraction whose result nearly cancels, the result is 0, as Excel's is.
|
|
930
|
+
*/
|
|
931
|
+
evaluate(node: Node_2): Value;
|
|
932
|
+
/**
|
|
933
|
+
* A Formula's result as it spills (ADR-0125): a range or an array of more than one Value is returned as it
|
|
934
|
+
* is, for the Sheet to spill; anything else is one Value, never blank. A Formula a call or an operator
|
|
935
|
+
* refused is the refusal, `#VALUE!`, whatever the rest of it made of it.
|
|
936
|
+
*/
|
|
937
|
+
evaluateResult(node: Node_2): Operand;
|
|
938
|
+
/**
|
|
939
|
+
* Refuses the Formula being evaluated: its result is the refusal, `#VALUE!` (`Value.refusal`), whatever the
|
|
940
|
+
* functions and operators around it make of the Error Value returned here, so `IFERROR` cannot catch it
|
|
941
|
+
* (ADR-0047; 2026-10-12, decided with the user: a refusal is never caught, anywhere).
|
|
942
|
+
*/
|
|
943
|
+
refuse(): Operand;
|
|
944
|
+
/**
|
|
945
|
+
* Refuses the Formula being evaluated with `#NAME?` (`Value.refusedName`): a call of a function Excel has and
|
|
946
|
+
* ExSheet does not declare, or a declared Linked Table's bare name (2026-10-13, decided with the user). A
|
|
947
|
+
* refusal by `refuse` in the same Formula comes before it.
|
|
948
|
+
*/
|
|
949
|
+
refuseName(): Operand;
|
|
950
|
+
/** `refuse`, for a function that answers with a Value: the Formula is refused, and the refusal is returned to stand where the Value would. */
|
|
951
|
+
refused(): Value;
|
|
952
|
+
/** An operand read whole, as an array: a range's cells, a Linked Table's column, or one Value. */
|
|
953
|
+
toArray(operand: Operand): ValueArray;
|
|
954
|
+
/**
|
|
955
|
+
* What a node evaluates to. Operators, parentheses and the `LET` names read are computed in a loop with a
|
|
956
|
+
* stack of their own (`#operator`), so the evaluator's recursion goes only through calls and `LET`s, which
|
|
957
|
+
* the parser bounds.
|
|
958
|
+
*/
|
|
959
|
+
operand(node: Node_2): Operand;
|
|
960
|
+
/**
|
|
961
|
+
* An operand used as one Value: a single cell is read; a rectangle of more than one cell refuses the Formula
|
|
962
|
+
* (`refused`), because Excel 365 applies what wants one Value to each Value of it, which ExSheet does not yet
|
|
963
|
+
* (ADR-0125). An empty argument is blank. A 3D Reference is `#REF!` where it is written, and `#VALUE!` where a
|
|
964
|
+
* function handed it on, as Excel answered (ADR-0331 §7).
|
|
965
|
+
*/
|
|
966
|
+
scalarOf(operand: Operand): Value | undefined;
|
|
967
|
+
/** The Values of a range that are not blank, in order: row-major for cells, top to bottom for a Linked Table's column. */
|
|
968
|
+
rangeValues(range: Operand): Generator<Value>;
|
|
969
|
+
scalar(node: Node_2): Value | undefined;
|
|
970
|
+
/**
|
|
971
|
+
* Excel's coercion of an operand to a number: a blank is 0, a boolean 1 or 0, text that reads as a typed
|
|
972
|
+
* number would under the Sheet's culture is that number, other text is `#VALUE!`.
|
|
973
|
+
*/
|
|
974
|
+
toNumber(value: Value | undefined): NumberOrError;
|
|
975
|
+
/** Excel's coercion to text: a blank is empty, a number is written as Excel writes one into text under the Sheet's culture. */
|
|
976
|
+
toText(value: Value | undefined): string;
|
|
977
|
+
}
|
|
978
|
+
|
|
979
|
+
/** Which way a fill extends its source (ADR-0050): along one axis, away from the source. */
|
|
980
|
+
export declare type FillDirection = 'down' | 'right' | 'up' | 'left';
|
|
981
|
+
|
|
982
|
+
/** The formats a fill from whole columns (`columns`) or whole rows writes on its target's columns (rows), by index. @internal */
|
|
983
|
+
declare interface FillLevels {
|
|
984
|
+
readonly columns: boolean;
|
|
985
|
+
readonly levels: readonly {
|
|
986
|
+
readonly index: number;
|
|
987
|
+
readonly level: AxisFormat;
|
|
988
|
+
}[];
|
|
989
|
+
}
|
|
990
|
+
|
|
991
|
+
/** What a fill writes, or why it is refused, and then nothing. @internal */
|
|
992
|
+
declare interface FillPlan {
|
|
993
|
+
readonly refusal: SheetRefusal | undefined;
|
|
994
|
+
readonly states: readonly AddressedState[];
|
|
995
|
+
readonly levels: FillLevels | undefined;
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
/**
|
|
999
|
+
* A text the engine reads that is not in the form it reads: a cell address, a cell range or a number format
|
|
1000
|
+
* code. It is a `TypeError`, so code that catches one still catches it.
|
|
1001
|
+
*/
|
|
1002
|
+
export declare class FormatError extends TypeError {
|
|
1003
|
+
/** Refuses a text, saying why in `message`. */
|
|
1004
|
+
constructor(message: string);
|
|
1005
|
+
}
|
|
1006
|
+
|
|
1007
|
+
/** A Value as a format shows it: the text, whether it cannot be shown (`####`), and the section's colour. */
|
|
1008
|
+
declare interface FormattedValue {
|
|
1009
|
+
readonly text: string;
|
|
1010
|
+
readonly cannotShow: boolean;
|
|
1011
|
+
readonly colour: NumberFormatColour | undefined;
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
/**
|
|
1015
|
+
* The candidates for what is being typed at the caret (ADR-0051): accepting one replaces the `length` characters
|
|
1016
|
+
* from `start` with its `insertText`.
|
|
1017
|
+
*/
|
|
1018
|
+
export declare interface FormulaCompletion {
|
|
1019
|
+
/** Where what is being typed starts in the text: a name, a column after `[`, an argument's value. */
|
|
1020
|
+
readonly start: number;
|
|
1021
|
+
/** How long it is, including any part of it after the caret. */
|
|
1022
|
+
readonly length: number;
|
|
1023
|
+
/**
|
|
1024
|
+
* The candidates, in the order to list them; never empty. Names are in alphabetical order, a table's columns
|
|
1025
|
+
* in the table's order, and an argument's values in Excel's.
|
|
1026
|
+
*/
|
|
1027
|
+
readonly candidates: readonly CompletionCandidate[];
|
|
1028
|
+
}
|
|
1029
|
+
|
|
1030
|
+
/**
|
|
1031
|
+
* The hint for the innermost function call whose argument list holds the caret, counting arguments by the
|
|
1032
|
+
* commas at its own depth; grouping parentheses inside it belong to it, and text in quotes is one argument
|
|
1033
|
+
* whatever it holds. `undefined` outside any call, or when that function is not declared. Throws a RangeError
|
|
1034
|
+
* when the caret lies outside 0 to the text's length.
|
|
1035
|
+
*/
|
|
1036
|
+
export declare function formulaHintAt(text: string, caret: number): ArgumentHint | undefined;
|
|
1037
|
+
|
|
1038
|
+
/**
|
|
1039
|
+
* Whether a Reference can be written at the caret (ADR-0051's Point predicate): the Formula stands after its
|
|
1040
|
+
* `=`, an operator (not `%`), `(` or `,`, with nothing after the caret that the Reference would run into.
|
|
1041
|
+
* `undefined` when it cannot. Throws a RangeError when the caret lies outside 0 to the text's length.
|
|
1042
|
+
*/
|
|
1043
|
+
export declare function formulaPointAt(text: string, caret: number): PointSite | undefined;
|
|
1044
|
+
|
|
1045
|
+
/**
|
|
1046
|
+
* A Reference in the text of a Formula being edited (ADR-0057): where it is written, and what it names — cells on
|
|
1047
|
+
* this Sheet, or a Linked Table's column. Exactly one of `cells` and `linkedColumn` is set.
|
|
1048
|
+
*/
|
|
1049
|
+
export declare interface FormulaReference {
|
|
1050
|
+
/** Where it starts in the text, whose `=` is at 0. */
|
|
1051
|
+
readonly start: number;
|
|
1052
|
+
/** How many characters it spans, its Sheet qualifier included. */
|
|
1053
|
+
readonly length: number;
|
|
1054
|
+
/**
|
|
1055
|
+
* The cells it names, held from their top-left corner however it was written (`B2:A1` names A1:B2), whole
|
|
1056
|
+
* columns for `A:A` and whole rows for `1:1`; `undefined` for a structured reference.
|
|
1057
|
+
*/
|
|
1058
|
+
readonly cells: CellRange | undefined;
|
|
1059
|
+
/** The Linked Table column a structured reference reads; `undefined` for cells. */
|
|
1060
|
+
readonly linkedColumn: LinkedTableColumn | undefined;
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1063
|
+
/**
|
|
1064
|
+
* Every Reference in the text of a Formula being edited, in the order written (ADR-0057): its span, and the
|
|
1065
|
+
* cells it names or, for a structured reference, the Linked Table column it reads. A Reference is what the
|
|
1066
|
+
* formula grammar reads as one over the whole of an operand, as for F4. The text need not parse: an unfinished
|
|
1067
|
+
* Formula (`=SUM(A1,`) is answered as far as it goes, and an unclosed string, quoted Sheet name or bracket
|
|
1068
|
+
* hides only what follows it. Nothing inside a string is a Reference, nor is a function name (`LOG10(`), nor
|
|
1069
|
+
* one qualified with another Sheet's name, which names no cells. A range typed as far as its colon
|
|
1070
|
+
* (`=SUM(A1:`) answers its first corner, the colon left out. Text beginning with `+` or `-` is answered as a
|
|
1071
|
+
* Formula is, as Excel colours it and ExSheet enters it (`=+A1`); other text is answered with nothing (the
|
|
1072
|
+
* eighth Windows run, cases 24–26).
|
|
1073
|
+
*
|
|
1074
|
+
* @param text - The text being edited.
|
|
1075
|
+
* @param sheetName - This Sheet's name: a Reference qualified with it, without regard to case, names this Sheet's cells.
|
|
1076
|
+
*/
|
|
1077
|
+
export declare function formulaReferences(text: string, sheetName: string): readonly FormulaReference[];
|
|
1078
|
+
|
|
1079
|
+
/**
|
|
1080
|
+
* A Formula that cannot be read. Excel refuses to accept such a Formula into a cell, and so does a Sheet:
|
|
1081
|
+
* nothing is recorded and no Value changes.
|
|
1082
|
+
*/
|
|
1083
|
+
export declare class FormulaSyntaxError extends SyntaxError {
|
|
1084
|
+
/** The Formula text as given. */
|
|
1085
|
+
readonly formula: string;
|
|
1086
|
+
/** The zero-based position in `formula` where reading stopped. */
|
|
1087
|
+
readonly position: number;
|
|
1088
|
+
/** Why, in words. */
|
|
1089
|
+
readonly reason: string;
|
|
1090
|
+
/**
|
|
1091
|
+
* Whether the Formula is one Excel reads, using syntax the engine does not implement (the intersection of
|
|
1092
|
+
* two References): typed without `=`, such text is refused by name rather than kept as text, since Excel
|
|
1093
|
+
* makes it a Formula (ADR-0047, third run). @internal
|
|
1094
|
+
*/
|
|
1095
|
+
readonly isUnimplemented: boolean;
|
|
1096
|
+
/**
|
|
1097
|
+
* Whether the Formula is refused for its size alone: functions nested past Excel's 64 levels, or a
|
|
1098
|
+
* Formula nested past the engine's 256 levels (ADR-0047). Such text is still a Formula. @internal
|
|
1099
|
+
*/
|
|
1100
|
+
readonly isBeyondLimit: boolean;
|
|
1101
|
+
/** The refusal of `formula` at `position`, for `reason`. */
|
|
1102
|
+
constructor(formula: string, position: number, reason: string, flags?: {
|
|
1103
|
+
readonly isUnimplemented?: boolean;
|
|
1104
|
+
readonly isBeyondLimit?: boolean;
|
|
1105
|
+
});
|
|
1106
|
+
}
|
|
1107
|
+
|
|
1108
|
+
/** One call of a function: its argument nodes, evaluated only when the function asks (so `IF` is lazy, as in Excel). */
|
|
1109
|
+
declare class FunctionCall {
|
|
1110
|
+
#private;
|
|
1111
|
+
readonly evaluator: Evaluator;
|
|
1112
|
+
/** For `RAND` and `RANDBETWEEN`: which of the Formula's draws this call is, counted in its text (ADR-0180). */
|
|
1113
|
+
readonly place: number;
|
|
1114
|
+
/** What a 3D Reference is to the function called, by argument. */
|
|
1115
|
+
readonly threeD: ((index: number, count: number) => ThreeDArgument) | undefined;
|
|
1116
|
+
constructor(evaluator: Evaluator, args: readonly Node_2[], place?: number, threeD?: (index: number, count: number) => ThreeDArgument);
|
|
1117
|
+
get count(): number;
|
|
1118
|
+
/**
|
|
1119
|
+
* Argument `index`, evaluated. One that holds a kept blank refuses the Formula (`Evaluator.refuse`): what
|
|
1120
|
+
* this function reads it as is a reading no run has settled (ADR-0125).
|
|
1121
|
+
*/
|
|
1122
|
+
operand(index: number): Operand;
|
|
1123
|
+
/** Argument `index`, evaluated, a kept blank included (ADR-0125), for the functions that read it the one way. */
|
|
1124
|
+
keepingBlanks(index: number): Operand;
|
|
1125
|
+
/**
|
|
1126
|
+
* Argument `index`, evaluated, for a function that reads one Value of it. A kept blank given as that one
|
|
1127
|
+
* Value is read as a blank cell's (ADR-0125). An array that holds one refuses the Formula.
|
|
1128
|
+
*/
|
|
1129
|
+
oneValue(index: number): Operand;
|
|
1130
|
+
/** The argument's syntax, when a function must distinguish a literal Reference from a computed one. */
|
|
1131
|
+
argument(index: number): Node_2;
|
|
1132
|
+
/**
|
|
1133
|
+
* The argument evaluated for its extent alone, as `ROWS` and `COLUMNS` read it: no Value of it is read, so a
|
|
1134
|
+
* kept blank is counted in the extent, never refused.
|
|
1135
|
+
*/
|
|
1136
|
+
measured(index: number): Operand;
|
|
1137
|
+
/** Whether argument `index` was given and not left empty (`MissingNode.isEmpty`). */
|
|
1138
|
+
has(index: number): boolean;
|
|
1139
|
+
}
|
|
1140
|
+
|
|
1141
|
+
/** A function of the declared set (ADR-0047): its name, how many arguments it takes, and how it evaluates. */
|
|
1142
|
+
declare class FunctionDefinition {
|
|
1143
|
+
#private;
|
|
1144
|
+
readonly name: string;
|
|
1145
|
+
readonly minimumArguments: number;
|
|
1146
|
+
/** The most arguments it takes; Excel's limit of 255 for the open-ended ones. */
|
|
1147
|
+
readonly maximumArguments: number;
|
|
1148
|
+
/** The argument list as a hint shows it, such as `number1, [number2], ...`. */
|
|
1149
|
+
readonly arguments: string;
|
|
1150
|
+
readonly description: string;
|
|
1151
|
+
readonly values: Readonly<Record<number, readonly ArgumentValue[]>>;
|
|
1152
|
+
readonly inPairs: boolean;
|
|
1153
|
+
readonly pairOffset: number;
|
|
1154
|
+
readonly referenceOnly: {
|
|
1155
|
+
readonly first: number;
|
|
1156
|
+
readonly last: number;
|
|
1157
|
+
} | undefined;
|
|
1158
|
+
readonly returnsReference: boolean;
|
|
1159
|
+
readonly threeD: ((index: number, count: number) => ThreeDArgument) | undefined;
|
|
1160
|
+
constructor(name: string, minimum: number, maximum: number, args: string, description: string, invoke: (call: FunctionCall) => Operand, traits?: FunctionTraits);
|
|
1161
|
+
invoke(call: FunctionCall): Operand;
|
|
1162
|
+
}
|
|
1163
|
+
|
|
1164
|
+
declare class FunctionNode extends NodeBase {
|
|
1165
|
+
#private;
|
|
1166
|
+
readonly kind = "function";
|
|
1167
|
+
/** The name: upper case for a declared function, as typed otherwise. */
|
|
1168
|
+
readonly name: string;
|
|
1169
|
+
readonly arguments: readonly Node_2[];
|
|
1170
|
+
/** The declared function, or `undefined` for a name outside the set (`#NAME?`). */
|
|
1171
|
+
readonly function: FunctionDefinition | undefined;
|
|
1172
|
+
/**
|
|
1173
|
+
* For `RAND` and `RANDBETWEEN`: which of the Formula's draws this call is, counted in the Formula's text
|
|
1174
|
+
* from 0 (ADR-0180). Two calls are two draws; one call read twice, as a `LET` binding is, is one.
|
|
1175
|
+
*/
|
|
1176
|
+
readonly place: number;
|
|
1177
|
+
constructor(name: string, args: readonly Node_2[], definition: FunctionDefinition | undefined, place?: number);
|
|
1178
|
+
references(): Generator<Reference>;
|
|
1179
|
+
structuredReferences(): Generator<StructuredReferenceNode>;
|
|
1180
|
+
calls(): Generator<FunctionNode>;
|
|
1181
|
+
get depth(): number;
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1184
|
+
/** What a function's declaration says beyond its name, arguments and evaluation. */
|
|
1185
|
+
declare interface FunctionTraits {
|
|
1186
|
+
/** The arguments that take one of a fixed list of values, by index, each list in Excel's order with Excel's texts (ADR-0058). */
|
|
1187
|
+
readonly values?: Readonly<Record<number, readonly ArgumentValue[]>>;
|
|
1188
|
+
/** Whether arguments after `pairOffset` come in pairs: an incomplete pair is refused on entry. */
|
|
1189
|
+
readonly inPairs?: boolean;
|
|
1190
|
+
/** Arguments before the repeating pairs: one for the result range of SUMIFS and its partners. */
|
|
1191
|
+
readonly pairOffset?: number;
|
|
1192
|
+
/** The arguments, by index from `first` to `last`, that Excel takes only as a Reference (ADR-0047). */
|
|
1193
|
+
readonly referenceOnly?: {
|
|
1194
|
+
readonly first: number;
|
|
1195
|
+
readonly last: number;
|
|
1196
|
+
};
|
|
1197
|
+
/** Whether a call of it can give a Reference (`INDIRECT`, `OFFSET`, `INDEX`, `CHOOSE`, `IF` and their kin). */
|
|
1198
|
+
readonly returnsReference?: boolean;
|
|
1199
|
+
/** What a 3D Reference given as each argument is to it, by the argument's index and the count of arguments (ADR-0331 §7). */
|
|
1200
|
+
readonly threeD?: (index: number, count: number) => ThreeDArgument;
|
|
1201
|
+
}
|
|
1202
|
+
|
|
1203
|
+
/** A cell's horizontal alignment, settable per cell as in Excel (ADR-0046). `general` is Excel's default: numbers to the right, text to the left, booleans and Error Values centred. */
|
|
1204
|
+
export declare type HorizontalAlignment = 'general' | 'left' | 'center' | 'right';
|
|
1205
|
+
|
|
1206
|
+
/**
|
|
1207
|
+
* The intersection of two operands written with whitespace between them, one of them a name (`item one`):
|
|
1208
|
+
* ExSheet defines no names, so it is `#NAME?` (ADR-0047). The parser refuses an intersection of two References.
|
|
1209
|
+
*/
|
|
1210
|
+
declare class IntersectionNode extends NodeBase {
|
|
1211
|
+
#private;
|
|
1212
|
+
readonly kind = "intersection";
|
|
1213
|
+
readonly left: Node_2;
|
|
1214
|
+
readonly right: Node_2;
|
|
1215
|
+
constructor(left: Node_2, right: Node_2);
|
|
1216
|
+
references(): Generator<Reference>;
|
|
1217
|
+
calls(): Generator<FunctionNode>;
|
|
1218
|
+
get depth(): number;
|
|
1219
|
+
}
|
|
1220
|
+
|
|
1221
|
+
/** A JSON value as JsonDocument holds it: an object's properties in order, two of one name both kept, and a number's text. @internal */
|
|
1222
|
+
declare type JsonElement = {
|
|
1223
|
+
readonly kind: 'object';
|
|
1224
|
+
readonly properties: readonly (readonly [string, JsonElement])[];
|
|
1225
|
+
readonly raw: string;
|
|
1226
|
+
} | {
|
|
1227
|
+
readonly kind: 'array';
|
|
1228
|
+
readonly items: readonly JsonElement[];
|
|
1229
|
+
readonly raw: string;
|
|
1230
|
+
} | {
|
|
1231
|
+
readonly kind: 'string';
|
|
1232
|
+
readonly value: string;
|
|
1233
|
+
} | {
|
|
1234
|
+
readonly kind: 'number';
|
|
1235
|
+
readonly raw: string;
|
|
1236
|
+
} | {
|
|
1237
|
+
readonly kind: 'true';
|
|
1238
|
+
} | {
|
|
1239
|
+
readonly kind: 'false';
|
|
1240
|
+
} | {
|
|
1241
|
+
readonly kind: 'null';
|
|
1242
|
+
};
|
|
1243
|
+
|
|
1244
|
+
/** Writes JSON as Utf8JsonWriter does without indenting: properties in the order written, numbers as .NET writes a double. @internal */
|
|
1245
|
+
declare class JsonWriter {
|
|
1246
|
+
#private;
|
|
1247
|
+
startObject(name?: string): void;
|
|
1248
|
+
endObject(): void;
|
|
1249
|
+
startArray(name?: string): void;
|
|
1250
|
+
endArray(): void;
|
|
1251
|
+
string(name: string | undefined, value: string): void;
|
|
1252
|
+
number(name: string | undefined, value: number): void;
|
|
1253
|
+
boolean(name: string | undefined, value: boolean): void;
|
|
1254
|
+
toString(): string;
|
|
1255
|
+
}
|
|
1256
|
+
|
|
1257
|
+
/** One name a `LET` binds, and the value it is bound to (ADR-0181). */
|
|
1258
|
+
declare class LetBinding {
|
|
1259
|
+
/** The name as typed; names compare without regard to case. */
|
|
1260
|
+
readonly name: string;
|
|
1261
|
+
/** The value's syntax, computed when the name is first read, and at most once (ADR-0181); set by the parser once read. */
|
|
1262
|
+
value: Node_2;
|
|
1263
|
+
constructor(name: string);
|
|
1264
|
+
}
|
|
1265
|
+
|
|
1266
|
+
/**
|
|
1267
|
+
* `LET(name1, value1, …, calculation)` (ADR-0181): names bound inside one Formula, each seen by the values
|
|
1268
|
+
* after it and by the calculation. Its References, Linked Tables and calls are every one its text names, the
|
|
1269
|
+
* bindings' whether they are read or not.
|
|
1270
|
+
*/
|
|
1271
|
+
declare class LetNode extends NodeBase {
|
|
1272
|
+
#private;
|
|
1273
|
+
readonly kind = "let";
|
|
1274
|
+
readonly bindings: readonly LetBinding[];
|
|
1275
|
+
readonly calculation: Node_2;
|
|
1276
|
+
constructor(bindings: readonly LetBinding[], calculation: Node_2);
|
|
1277
|
+
references(): Generator<Reference>;
|
|
1278
|
+
structuredReferences(): Generator<StructuredReferenceNode>;
|
|
1279
|
+
calls(): Generator<FunctionNode>;
|
|
1280
|
+
get depth(): number;
|
|
1281
|
+
}
|
|
1282
|
+
|
|
1283
|
+
/** A Linked Table as a Sheet knows it (CONTEXT.md, ADR-0049): its name, its columns, its key, and whether its data has arrived. */
|
|
1284
|
+
export declare class LinkedTable {
|
|
1285
|
+
/** The name Formulas use, as declared; matched without regard to case. */
|
|
1286
|
+
readonly name: string;
|
|
1287
|
+
/** The column names, in order, as declared; matched without regard to case. */
|
|
1288
|
+
readonly columns: readonly string[];
|
|
1289
|
+
/** Whether no snapshot is held: none has arrived yet, or the last was refused because a key repeated in it. */
|
|
1290
|
+
readonly isWaiting: boolean;
|
|
1291
|
+
/** How many rows the current snapshot holds; 0 while waiting. */
|
|
1292
|
+
readonly rowCount: number;
|
|
1293
|
+
/** The key's columns, as declared there: one, several, or none for a table declared without a key (ADR-0058). */
|
|
1294
|
+
readonly keyColumns: readonly string[];
|
|
1295
|
+
constructor(name: string, columns: readonly string[], isWaiting: boolean, rows: number, keyColumns?: readonly string[]);
|
|
1296
|
+
/** The key column when the key is one column; `undefined` for none, and for a key of several columns. */
|
|
1297
|
+
get key(): string | undefined;
|
|
1298
|
+
}
|
|
1299
|
+
|
|
1300
|
+
/**
|
|
1301
|
+
* A Linked Table's column, as a structured reference names it (`Positions[PV]`): the key a Reference Outline is
|
|
1302
|
+
* told by (ADR-0057). Two are equal when they name the same table and the same column without regard to case, as
|
|
1303
|
+
* the Sheet finds a table and its column (ADR-0049).
|
|
1304
|
+
*/
|
|
1305
|
+
export declare class LinkedTableColumn {
|
|
1306
|
+
/** The table's name, as written. */
|
|
1307
|
+
readonly table: string;
|
|
1308
|
+
/** The column's name, as written, with its `'` escapes read. */
|
|
1309
|
+
readonly column: string;
|
|
1310
|
+
/** The column of `table` named `column`. */
|
|
1311
|
+
constructor(table: string, column: string);
|
|
1312
|
+
/** Whether `other` names the same table and column, without regard to case. */
|
|
1313
|
+
equals(other: LinkedTableColumn): boolean;
|
|
1314
|
+
/** A string two equal columns share, for keying a `Map` as `equals` compares. */
|
|
1315
|
+
get key(): string;
|
|
1316
|
+
}
|
|
1317
|
+
|
|
1318
|
+
/** What a structural edit asks of the Sheet it rewrites: whether a Reference names a cell of that Sheet. */
|
|
1319
|
+
declare interface LocalReferences {
|
|
1320
|
+
isLocal(reference: Reference): boolean;
|
|
1321
|
+
}
|
|
1322
|
+
|
|
1323
|
+
/**
|
|
1324
|
+
* Whether the lookup `lookupText` writes for `key` finds a row whose key is `candidate`: `XLOOKUP`'s exact
|
|
1325
|
+
* match, which tells a number from text and text apart without regard to case, and never matches a blank
|
|
1326
|
+
* (`undefined`) or an Error Value. A Pointing Scope finds the row a press was written for by it, wherever the
|
|
1327
|
+
* grid that shows the table has sorted that row to (ADR-0058, "What is drawn").
|
|
1328
|
+
*
|
|
1329
|
+
* For a key of several columns, `key` and `candidate` are lists, one Value per key column: every part equal as
|
|
1330
|
+
* the `=` operator finds it — of one kind, text without regard to case, numbers at Excel's fifteen digits —
|
|
1331
|
+
* and none blank or an Error Value.
|
|
1332
|
+
*/
|
|
1333
|
+
export declare function lookupFinds(key: Value, candidate: Value | undefined): boolean;
|
|
1334
|
+
|
|
1335
|
+
/**
|
|
1336
|
+
* Whether the lookup `lookupText` writes for `key` finds a row whose key is `candidate`: `XLOOKUP`'s exact
|
|
1337
|
+
* match, which tells a number from text and text apart without regard to case, and never matches a blank
|
|
1338
|
+
* (`undefined`) or an Error Value. A Pointing Scope finds the row a press was written for by it, wherever the
|
|
1339
|
+
* grid that shows the table has sorted that row to (ADR-0058, "What is drawn").
|
|
1340
|
+
*
|
|
1341
|
+
* For a key of several columns, `key` and `candidate` are lists, one Value per key column: every part equal as
|
|
1342
|
+
* the `=` operator finds it — of one kind, text without regard to case, numbers at Excel's fifteen digits —
|
|
1343
|
+
* and none blank or an Error Value.
|
|
1344
|
+
*/
|
|
1345
|
+
export declare function lookupFinds(keys: readonly Value[], candidates: readonly (Value | undefined)[]): boolean;
|
|
1346
|
+
|
|
1347
|
+
/**
|
|
1348
|
+
* What Point writes for a pressed cell of a Linked Table, through a Pointing Scope (ADR-0058): the lookup that
|
|
1349
|
+
* reads the cell by its row's key, `XLOOKUP("R-4471", Positions[Id], Positions[PV])` — the key as a constant
|
|
1350
|
+
* of its kind (`constantText`), then the key column and the pressed column as structured references
|
|
1351
|
+
* (`structuredReferenceText`). It names no position, so the Formula reads the same row after the grid that
|
|
1352
|
+
* showed it is sorted (ADR-0049, rule 2).
|
|
1353
|
+
*
|
|
1354
|
+
* For a key of several columns (ADR-0058, amended 2026-10-03), `keyColumns` and `keys` are lists, one Value
|
|
1355
|
+
* per key column, and the lookup reads the cell by every part of its row's key:
|
|
1356
|
+
* `XLOOKUP(1, (Cds[Entity]="ACME")*(Cds[Tenor]="5Y"), Cds[Spread])`. Each part is compared as the `=`
|
|
1357
|
+
* operator compares, and the row whose parts all match is the one read.
|
|
1358
|
+
*
|
|
1359
|
+
* Throws a RangeError when a name is empty, the key has not one Value per key column, or a part of it is an
|
|
1360
|
+
* Error Value, which no lookup finds.
|
|
1361
|
+
*/
|
|
1362
|
+
export declare function lookupText(table: string, keyColumn: string, key: Value, column: string): string;
|
|
1363
|
+
|
|
1364
|
+
/**
|
|
1365
|
+
* What Point writes for a pressed cell of a Linked Table, through a Pointing Scope (ADR-0058): the lookup that
|
|
1366
|
+
* reads the cell by its row's key, `XLOOKUP("R-4471", Positions[Id], Positions[PV])` — the key as a constant
|
|
1367
|
+
* of its kind (`constantText`), then the key column and the pressed column as structured references
|
|
1368
|
+
* (`structuredReferenceText`). It names no position, so the Formula reads the same row after the grid that
|
|
1369
|
+
* showed it is sorted (ADR-0049, rule 2).
|
|
1370
|
+
*
|
|
1371
|
+
* For a key of several columns (ADR-0058, amended 2026-10-03), `keyColumns` and `keys` are lists, one Value
|
|
1372
|
+
* per key column, and the lookup reads the cell by every part of its row's key:
|
|
1373
|
+
* `XLOOKUP(1, (Cds[Entity]="ACME")*(Cds[Tenor]="5Y"), Cds[Spread])`. Each part is compared as the `=`
|
|
1374
|
+
* operator compares, and the row whose parts all match is the one read.
|
|
1375
|
+
*
|
|
1376
|
+
* Throws a RangeError when a name is empty, the key has not one Value per key column, or a part of it is an
|
|
1377
|
+
* Error Value, which no lookup finds.
|
|
1378
|
+
*/
|
|
1379
|
+
export declare function lookupText(table: string, keyColumns: readonly string[], keys: readonly Value[], column: string): string;
|
|
1380
|
+
|
|
1381
|
+
/** An argument left empty, as in `IF(A1,,1)`. */
|
|
1382
|
+
declare class MissingNode extends NodeBase {
|
|
1383
|
+
readonly kind = "missing";
|
|
1384
|
+
static readonly instance: MissingNode;
|
|
1385
|
+
private constructor();
|
|
1386
|
+
/**
|
|
1387
|
+
* Whether an argument is left empty: written empty, or a `LET` name bound to a value left empty, as in
|
|
1388
|
+
* `LET(x,,IF(A1,x,1))`. Such a name reads as the empty argument it is bound to would read in its place
|
|
1389
|
+
* (ADR-0181; LET-107, run 17).
|
|
1390
|
+
*/
|
|
1391
|
+
static isEmpty(argument: Node_2): boolean;
|
|
1392
|
+
}
|
|
1393
|
+
|
|
1394
|
+
/**
|
|
1395
|
+
* A name that is not a function call, a Reference or a boolean. ExSheet defines no names of its own, so it is
|
|
1396
|
+
* `#NAME?` — unless a `LET` around it binds it (ADR-0181).
|
|
1397
|
+
*/
|
|
1398
|
+
declare class NameNode extends NodeBase {
|
|
1399
|
+
#private;
|
|
1400
|
+
readonly kind = "name";
|
|
1401
|
+
readonly name: string;
|
|
1402
|
+
/** Where the name stands in the Formula's text. */
|
|
1403
|
+
readonly position: number;
|
|
1404
|
+
/** The `LET` binding the name reads, as the text's scopes resolve it; `undefined` for none (`#NAME?`). */
|
|
1405
|
+
readonly binding: LetBinding | undefined;
|
|
1406
|
+
constructor(name: string, position: number, binding: LetBinding | undefined);
|
|
1407
|
+
get depth(): number;
|
|
1408
|
+
}
|
|
1409
|
+
|
|
1410
|
+
/** A node of a parsed Formula. */
|
|
1411
|
+
declare type Node_2 = NumberNode | TextNode | BooleanNode | ErrorNode | MissingNode | ReferenceNode | StructuredReferenceNode | NameNode | LetNode | IntersectionNode | FunctionNode | ParenthesesNode | UnaryNode | PercentNode | BinaryNode;
|
|
1412
|
+
|
|
1413
|
+
/** What every node can say of itself, statically. */
|
|
1414
|
+
declare abstract class NodeBase {
|
|
1415
|
+
/** Every Reference this node reads, statically: the dependency graph's edges. */
|
|
1416
|
+
references(): Generator<Reference>;
|
|
1417
|
+
/** Every structured reference this node reads, statically: a Linked Table's readers (ADR-0049). */
|
|
1418
|
+
structuredReferences(): Generator<StructuredReferenceNode>;
|
|
1419
|
+
/** Every function call this node makes, statically, its arguments' calls included: `TODAY`'s readers (ADR-0121). */
|
|
1420
|
+
calls(): Generator<FunctionNode>;
|
|
1421
|
+
/**
|
|
1422
|
+
* How deep a walk of this node goes, counted in nodes, where a walk that reads an operator's chain loops
|
|
1423
|
+
* along it rather than descending: a leaf is 1, a node one more than its deepest child, except a
|
|
1424
|
+
* `BinaryNode`'s left operand, which stands at the operator's own depth; and a name a `LET` binds one more
|
|
1425
|
+
* than its value. The parser refuses a Formula deeper than its `mostNesting`.
|
|
1426
|
+
*/
|
|
1427
|
+
get depth(): number;
|
|
1428
|
+
}
|
|
1429
|
+
|
|
1430
|
+
/**
|
|
1431
|
+
* An Excel number format code, such as `#,##0.00`, `0%` or `yyyy-mm-dd` (ADR-0046). The code is written in
|
|
1432
|
+
* Excel's stored, invariant form — `,` groups thousands and `.` marks decimals — and shown with the Sheet's
|
|
1433
|
+
* culture's separators and month and day names. A code outside the subset the engine shows as Excel does —
|
|
1434
|
+
* conditions, locales and elapsed time in brackets, fractions, fractional seconds, `*` fill, era codes,
|
|
1435
|
+
* unquoted letters, a numbered colour — is refused rather than shown some other way.
|
|
1436
|
+
*/
|
|
1437
|
+
export declare class NumberFormat {
|
|
1438
|
+
#private;
|
|
1439
|
+
private constructor();
|
|
1440
|
+
/** Excel's `General`: at most 15 significant digits, the culture's decimal separator. */
|
|
1441
|
+
static readonly general: NumberFormat;
|
|
1442
|
+
/** The code as given, such as `#,##0.00`. */
|
|
1443
|
+
get code(): string;
|
|
1444
|
+
/** Whether this is `General`. */
|
|
1445
|
+
get isGeneral(): boolean;
|
|
1446
|
+
/** Whether a number shows as a date or time: its first section holds date or time codes. */
|
|
1447
|
+
get isDate(): boolean;
|
|
1448
|
+
/** Whether a number shows as a date with no time of day. @internal */
|
|
1449
|
+
get isDateOnly(): boolean;
|
|
1450
|
+
/** Whether a number shows as a percentage: its first section holds `%`. */
|
|
1451
|
+
get isPercent(): boolean;
|
|
1452
|
+
/** Reads a format code; one outside the subset is refused with a `FormatError` that says why. */
|
|
1453
|
+
static parse(code: string): NumberFormat;
|
|
1454
|
+
/** Reads a format code, saying why when it cannot. */
|
|
1455
|
+
static tryParse(given: string): NumberFormatReading;
|
|
1456
|
+
/** Whether a number shows in Excel's General form: the format is General, or holds only a text section. @internal */
|
|
1457
|
+
get showsNumbersAsGeneral(): boolean;
|
|
1458
|
+
/**
|
|
1459
|
+
* A Value as this format shows it in a column `characters` wide, each character charged one digit width
|
|
1460
|
+
* (ADR-0047): a number in General is fitted to the width as Excel's General fits it, and any other number
|
|
1461
|
+
* whose text is longer than the width cannot be shown (`####`, ADR-0016). Text, booleans and Error Values
|
|
1462
|
+
* are never fitted. @internal
|
|
1463
|
+
*/
|
|
1464
|
+
formatIn(value: Value, culture: Culture, characters: number): FormattedValue;
|
|
1465
|
+
/**
|
|
1466
|
+
* A Value as this format shows it under a culture, and the colour of the section that showed it
|
|
1467
|
+
* (ADR-0071), `undefined` where it names none or no section showed the Value. @internal
|
|
1468
|
+
*/
|
|
1469
|
+
format(value: Value, culture: Culture): FormattedValue;
|
|
1470
|
+
/** Two formats are equal when their codes are (ordinal). */
|
|
1471
|
+
equals(other: NumberFormat): boolean;
|
|
1472
|
+
/** The code. */
|
|
1473
|
+
toString(): string;
|
|
1474
|
+
/**
|
|
1475
|
+
* Excel's built-in short date, `m/d/yyyy` in the invariant codes: what a typed date records under every
|
|
1476
|
+
* culture. It shows a date in the Sheet culture's own short-date pattern, as Excel's built-in format 14
|
|
1477
|
+
* shows in the system's pattern. @internal
|
|
1478
|
+
*/
|
|
1479
|
+
static readonly shortDate: NumberFormat;
|
|
1480
|
+
/** Excel's built-in short date with a time (`m/d/yyyy h:mm`, format 22). @internal */
|
|
1481
|
+
static readonly shortDateTime: NumberFormat;
|
|
1482
|
+
/**
|
|
1483
|
+
* Excel's built-in currency format under a culture: what Ctrl+Shift+$ records (ADR-0071). It is format 8,
|
|
1484
|
+
* `$#,##0.00_);[Red]($#,##0.00)`, or format 6, `$#,##0_);[Red]($#,##0)`, where the culture's currency has
|
|
1485
|
+
* no decimals; recorded in those codes, it shows in the culture's own currency.
|
|
1486
|
+
*/
|
|
1487
|
+
static builtInCurrency(culture: Culture): NumberFormat;
|
|
1488
|
+
/**
|
|
1489
|
+
* The code as Format Cells' Custom box spells it under a culture, as Excel's local code does (ADR-0071).
|
|
1490
|
+
* A built-in shown in the culture's own form is spelled in that form; a code of its own that spells such
|
|
1491
|
+
* a built-in's code is spelled as it was typed, and any other code as it is.
|
|
1492
|
+
*/
|
|
1493
|
+
localCode(culture: Culture): string;
|
|
1494
|
+
/**
|
|
1495
|
+
* Reads a code typed into Format Cells' Custom box under a culture (ADR-0071). A code is a built-in only
|
|
1496
|
+
* when it spells that built-in's code under the culture (`localCode`), in any case; a code of its own that
|
|
1497
|
+
* spells a built-in's invariant code is recorded with its separators escaped, `d\-mmm\-yy`.
|
|
1498
|
+
*/
|
|
1499
|
+
static tryParseLocal(code: string, culture: Culture): NumberFormatReading;
|
|
1500
|
+
/**
|
|
1501
|
+
* This format as a Sheet Document opened under a culture holds it (ADR-0071, ticket 103): a code of its
|
|
1502
|
+
* own that spells a localised built-in's code as the culture spells that built-in is the built-in. @internal
|
|
1503
|
+
*/
|
|
1504
|
+
openedIn(culture: Culture): NumberFormat;
|
|
1505
|
+
/**
|
|
1506
|
+
* Reads a code a file stores as a format of its own, as `TEXT` reads a code (ADR-0120, ADR-0330): the
|
|
1507
|
+
* invariant spelling, as written. A code that spells a built-in shown in the culture's own form is a code
|
|
1508
|
+
* of its own, recorded with its separators escaped.
|
|
1509
|
+
*/
|
|
1510
|
+
static tryParseAsWritten(code: string): NumberFormatReading;
|
|
1511
|
+
}
|
|
1512
|
+
|
|
1513
|
+
/**
|
|
1514
|
+
* A colour a Number Format names at the start of a section — `[Red]` and the seven others, in any case
|
|
1515
|
+
* (ADR-0047). The text of a Value that section shows is painted in it, over the cell's Font colour (ADR-0071).
|
|
1516
|
+
* A numbered colour (`[Color10]`) is not one of these: it is refused, as Excel refused it.
|
|
1517
|
+
*/
|
|
1518
|
+
export declare type NumberFormatColour = 'black' | 'blue' | 'cyan' | 'green' | 'magenta' | 'red' | 'white' | 'yellow';
|
|
1519
|
+
|
|
1520
|
+
/** The RGB Excel paints a Number Format's colour in, as `0xRRGGBB`: Excel's legacy palette (ADR-0071). */
|
|
1521
|
+
export declare function numberFormatColourRgb(colour: NumberFormatColour): number;
|
|
1522
|
+
|
|
1523
|
+
/** A format code read, or why it could not be. */
|
|
1524
|
+
export declare type NumberFormatReading = {
|
|
1525
|
+
readonly format: NumberFormat;
|
|
1526
|
+
readonly reason?: undefined;
|
|
1527
|
+
} | {
|
|
1528
|
+
readonly format?: undefined;
|
|
1529
|
+
readonly reason: string;
|
|
1530
|
+
};
|
|
1531
|
+
|
|
1532
|
+
declare class NumberNode extends NodeBase {
|
|
1533
|
+
readonly kind = "number";
|
|
1534
|
+
readonly number: number;
|
|
1535
|
+
constructor(number: number);
|
|
1536
|
+
}
|
|
1537
|
+
|
|
1538
|
+
/** A number, or the Error Value met where one was wanted (C#'s `out ErrorValue? error`). */
|
|
1539
|
+
declare type NumberOrError = number | ErrorValue;
|
|
1540
|
+
|
|
1541
|
+
/**
|
|
1542
|
+
* What a node evaluates to before it is used: a Value (or blank), or a rectangle of cells that a function reads
|
|
1543
|
+
* as a range. Excel's functions tell the two apart — `SUM` ignores text in a range but not text typed as an
|
|
1544
|
+
* argument.
|
|
1545
|
+
*/
|
|
1546
|
+
declare class Operand {
|
|
1547
|
+
readonly kind: OperandKind;
|
|
1548
|
+
/** For `scalar`: the Value, or `undefined` for a blank. */
|
|
1549
|
+
readonly scalar: Value | undefined;
|
|
1550
|
+
readonly area: Area;
|
|
1551
|
+
/** For `area`: the Sheet its cells are on, as the recalculation reads it (ADR-0331). */
|
|
1552
|
+
readonly cells: CellReader | undefined;
|
|
1553
|
+
/** For `threeD`: the Sheets of the span, in tab order (ADR-0331 §7). */
|
|
1554
|
+
readonly sheets: readonly CellReader[] | undefined;
|
|
1555
|
+
/**
|
|
1556
|
+
* For `threeD`: whether a function handed it on (`IF`, `CHOOSE`, a `LET` name), rather than its Reference
|
|
1557
|
+
* standing where it is read. Read as one Value, one written there is `#REF!` and one handed on `#VALUE!`.
|
|
1558
|
+
*/
|
|
1559
|
+
readonly handedOn: boolean;
|
|
1560
|
+
/** For `column`: the column's Values top to bottom, blank as `undefined`. */
|
|
1561
|
+
readonly column: readonly (Value | undefined)[] | undefined;
|
|
1562
|
+
/** For `array`: the computed Values. */
|
|
1563
|
+
readonly array: ValueArray | undefined;
|
|
1564
|
+
/** For `array`: whether the Values are a Spill Range's, read through `A1#` (ADR-0125): a Reference to cells in Excel. */
|
|
1565
|
+
readonly isSpillRange: boolean;
|
|
1566
|
+
/**
|
|
1567
|
+
* Whether this holds a kept blank: a blank that `UNIQUE`, `SORT`, `SORTBY`, `FILTER` or `TRANSPOSE` kept
|
|
1568
|
+
* from its array (ADR-0125), as one of its Values or as the one Value `INDEX` picked from it. A function
|
|
1569
|
+
* reads such an operand only through `FunctionCall.keepingBlanks` or `FunctionCall.oneValue`; anywhere else
|
|
1570
|
+
* the Formula is refused.
|
|
1571
|
+
*/
|
|
1572
|
+
readonly keptBlank: boolean;
|
|
1573
|
+
private constructor();
|
|
1574
|
+
/** Whether this is a Reference of cells: a rectangle, or a Spill Range read through `A1#`. */
|
|
1575
|
+
get isReference(): boolean;
|
|
1576
|
+
/** Whether this is a range a function reads cell by cell: a rectangle of cells, a Linked Table's column, an array or a 3D Reference. */
|
|
1577
|
+
get isRange(): boolean;
|
|
1578
|
+
static readonly missing: Operand;
|
|
1579
|
+
static readonly blank: Operand;
|
|
1580
|
+
/** One Value. */
|
|
1581
|
+
static of(value: Value): Operand;
|
|
1582
|
+
/** One Error Value. */
|
|
1583
|
+
static ofError(error: ErrorValue): Operand;
|
|
1584
|
+
/** One Value, or a blank. */
|
|
1585
|
+
static ofScalar(value: Value | undefined): Operand;
|
|
1586
|
+
/** A rectangle of the Sheet `cells` reads (ADR-0331). */
|
|
1587
|
+
static ofArea(area: Area, cells: CellReader): Operand;
|
|
1588
|
+
/** A 3D Reference's rectangle on each Sheet of its span, `sheets` in tab order (ADR-0331 §7). */
|
|
1589
|
+
static ofThreeD(area: Area, sheets: readonly CellReader[]): Operand;
|
|
1590
|
+
/** This operand as a function hands it on (`handedOn`): a 3D Reference marked so, anything else as it is. */
|
|
1591
|
+
handOn(): Operand;
|
|
1592
|
+
/** Another rectangle of the same Sheet as this one, which must be a rectangle. */
|
|
1593
|
+
sameSheet(area: Area): Operand;
|
|
1594
|
+
/** A Linked Table's column (ADR-0049). */
|
|
1595
|
+
static ofColumn(column: readonly (Value | undefined)[]): Operand;
|
|
1596
|
+
/** A computed array; one of a single Value is that Value. */
|
|
1597
|
+
static ofArray(array: ValueArray): Operand;
|
|
1598
|
+
/** A Spill Range's Values, read through `A1#`: an array that is a Reference (`isSpillRange`). */
|
|
1599
|
+
static ofSpillRange(array: ValueArray): Operand;
|
|
1600
|
+
/** One Value as an array of one, for a function that takes an array and is given what a computation reduced to one Value (ADR-0125). */
|
|
1601
|
+
static asArray(value: Value | undefined): Operand;
|
|
1602
|
+
get isError(): boolean;
|
|
1603
|
+
/** Whether this is a blank, or an array that holds one. */
|
|
1604
|
+
get holdsBlank(): boolean;
|
|
1605
|
+
/** This operand marked as holding a kept blank (`keptBlank`), when it holds a blank at all; as it is otherwise. */
|
|
1606
|
+
withKeptBlank(): Operand;
|
|
1607
|
+
/** The array of an `array` operand. */
|
|
1608
|
+
arrayOf(): ValueArray;
|
|
1609
|
+
/** The column of a `column` operand. */
|
|
1610
|
+
columnOf(): readonly (Value | undefined)[];
|
|
1611
|
+
/** The Sheet of an `area` operand. */
|
|
1612
|
+
cellsOf(): CellReader;
|
|
1613
|
+
/** The Sheets of a `threeD` operand. */
|
|
1614
|
+
sheetsOf(): readonly CellReader[];
|
|
1615
|
+
}
|
|
1616
|
+
|
|
1617
|
+
/**
|
|
1618
|
+
* What an operand is: a Value (or a blank read from one cell); a rectangle of cells not yet read; an argument
|
|
1619
|
+
* left empty; a Linked Table's column (ADR-0049); an array a Formula computed (ADR-0125); or a 3D Reference,
|
|
1620
|
+
* one rectangle on each Sheet of a span (ADR-0331 §7).
|
|
1621
|
+
*/
|
|
1622
|
+
declare type OperandKind = 'scalar' | 'area' | 'missing' | 'column' | 'array' | 'threeD';
|
|
1623
|
+
|
|
1624
|
+
declare class ParenthesesNode extends NodeBase {
|
|
1625
|
+
#private;
|
|
1626
|
+
readonly kind = "parentheses";
|
|
1627
|
+
readonly inner: Node_2;
|
|
1628
|
+
constructor(inner: Node_2);
|
|
1629
|
+
references(): Generator<Reference>;
|
|
1630
|
+
structuredReferences(): Generator<StructuredReferenceNode>;
|
|
1631
|
+
calls(): Generator<FunctionNode>;
|
|
1632
|
+
get depth(): number;
|
|
1633
|
+
}
|
|
1634
|
+
|
|
1635
|
+
declare class PercentNode extends NodeBase {
|
|
1636
|
+
#private;
|
|
1637
|
+
readonly kind = "percent";
|
|
1638
|
+
readonly operand: Node_2;
|
|
1639
|
+
constructor(operand: Node_2);
|
|
1640
|
+
references(): Generator<Reference>;
|
|
1641
|
+
structuredReferences(): Generator<StructuredReferenceNode>;
|
|
1642
|
+
calls(): Generator<FunctionNode>;
|
|
1643
|
+
get depth(): number;
|
|
1644
|
+
}
|
|
1645
|
+
|
|
1646
|
+
/** Where a cell lies in a range a change is set on: which of the range's outer edges its sides are. @internal */
|
|
1647
|
+
declare class PlaceInRange {
|
|
1648
|
+
readonly firstRow: boolean;
|
|
1649
|
+
readonly lastRow: boolean;
|
|
1650
|
+
readonly firstColumn: boolean;
|
|
1651
|
+
readonly lastColumn: boolean;
|
|
1652
|
+
constructor(firstRow: boolean, lastRow: boolean, firstColumn: boolean, lastColumn: boolean);
|
|
1653
|
+
/** A cell set on its own: all four sides are outer edges. */
|
|
1654
|
+
static readonly alone: PlaceInRange;
|
|
1655
|
+
/** A cell none of whose sides is an outer edge. */
|
|
1656
|
+
static readonly inside: PlaceInRange;
|
|
1657
|
+
/**
|
|
1658
|
+
* Where `at` lies in `range`, as Excel places an outline: whole columns have no top or bottom edge, whole rows
|
|
1659
|
+
* no right edge, and the whole Sheet no outer edge (the eleventh and twelfth Windows runs).
|
|
1660
|
+
*/
|
|
1661
|
+
static of(range: CellRange, at: CellAddress): PlaceInRange;
|
|
1662
|
+
}
|
|
1663
|
+
|
|
1664
|
+
/** Where Point mode writes a Reference: the `length` characters from `start` are replaced (none, for an insertion at the caret). */
|
|
1665
|
+
export declare interface PointSite {
|
|
1666
|
+
/** Where the Reference goes in the text. */
|
|
1667
|
+
readonly start: number;
|
|
1668
|
+
/** How many characters it replaces. */
|
|
1669
|
+
readonly length: number;
|
|
1670
|
+
}
|
|
1671
|
+
|
|
1672
|
+
/**
|
|
1673
|
+
* The lines drawn along a range's four outer edges, each line once per edge (`Sheet.getEdgeLines`): what Format
|
|
1674
|
+
* Cells shows on a range's outline (ADR-0071; the fourteenth Windows run, case 13). Each list holds distinct lines,
|
|
1675
|
+
* in the order met.
|
|
1676
|
+
*/
|
|
1677
|
+
export declare interface RangeEdgeLines {
|
|
1678
|
+
/** The lines along the range's top edge. */
|
|
1679
|
+
readonly top: readonly BorderLine[];
|
|
1680
|
+
/** The lines along the range's bottom edge. */
|
|
1681
|
+
readonly bottom: readonly BorderLine[];
|
|
1682
|
+
/** The lines along the range's left edge. */
|
|
1683
|
+
readonly left: readonly BorderLine[];
|
|
1684
|
+
/** The lines along the range's right edge. */
|
|
1685
|
+
readonly right: readonly BorderLine[];
|
|
1686
|
+
}
|
|
1687
|
+
|
|
1688
|
+
/** A Cell Format change read from its JSON: each part it sets, by its name. */
|
|
1689
|
+
export declare function readCellFormatChange(json: string): CellFormatChange;
|
|
1690
|
+
|
|
1691
|
+
/** A Linked Table's snapshot read from its JSON: rows of Values, a blank as `null`. */
|
|
1692
|
+
export declare function readLinkedRows(json: string): (Value | undefined)[][];
|
|
1693
|
+
|
|
1694
|
+
/**
|
|
1695
|
+
* A Sheet Edit read from its JSON: an object of one key, the factory, and its arguments as the factory takes them
|
|
1696
|
+
* (ADR-0370 section 1). The factory checks them as it checks any caller's; what is not an edit so written is refused
|
|
1697
|
+
* with a `FormatError`.
|
|
1698
|
+
*/
|
|
1699
|
+
export declare function readSheetEdit(json: string): SheetEdit;
|
|
1700
|
+
|
|
1701
|
+
/**
|
|
1702
|
+
* A Reference as a Formula records it. The target positions are held absolutely, with a flag per axis saying
|
|
1703
|
+
* whether the text wrote `$`; a relative Reference shifts when its Formula is copied (ADR-0048), and every form
|
|
1704
|
+
* survives a structural edit by rewriting the positions. The Sheet qualifier is recorded as written.
|
|
1705
|
+
*/
|
|
1706
|
+
declare class Reference implements ReferenceParts {
|
|
1707
|
+
#private;
|
|
1708
|
+
readonly sheetName: string | undefined;
|
|
1709
|
+
readonly shape: ReferenceShape;
|
|
1710
|
+
readonly row1: number;
|
|
1711
|
+
readonly column1: number;
|
|
1712
|
+
readonly row2: number;
|
|
1713
|
+
readonly column2: number;
|
|
1714
|
+
readonly row1Absolute: boolean;
|
|
1715
|
+
readonly column1Absolute: boolean;
|
|
1716
|
+
readonly row2Absolute: boolean;
|
|
1717
|
+
readonly column2Absolute: boolean;
|
|
1718
|
+
readonly spilled: boolean;
|
|
1719
|
+
readonly lastSheetName: string | undefined;
|
|
1720
|
+
constructor(parts: ReferenceParts);
|
|
1721
|
+
/** One cell's Reference. */
|
|
1722
|
+
static cell(sheet: string | undefined, atRow: number, atColumn: number, rowAbsolute: boolean, columnAbsolute: boolean): Reference;
|
|
1723
|
+
/** This Reference with some of its parts changed. */
|
|
1724
|
+
with(changes: Partial<ReferenceParts>): Reference;
|
|
1725
|
+
/** A C# record's equality: every part the same. */
|
|
1726
|
+
equals(other: Reference): boolean;
|
|
1727
|
+
/** Whether this is a 3D Reference, reading one range on every Sheet of a span (ADR-0331 §7). */
|
|
1728
|
+
get isThreeD(): boolean;
|
|
1729
|
+
/** The rectangle the Reference covers. */
|
|
1730
|
+
get area(): Area;
|
|
1731
|
+
/**
|
|
1732
|
+
* A Reference to a rectangle, in the shape Excel writes it: one spanning every column is whole rows
|
|
1733
|
+
* (`A1:XFD3` is `1:3`, `A:XFD` is `$1:$1048576`), one spanning every row is whole columns (`A1:A1048576`
|
|
1734
|
+
* is `A:A`), and any other is an area. The axis a whole form drops is held absolute, as Excel holds it.
|
|
1735
|
+
*/
|
|
1736
|
+
static rectangle(sheet: string | undefined, row1: number, column1: number, row2: number, column2: number, row1Absolute: boolean, column1Absolute: boolean, row2Absolute: boolean, column2Absolute: boolean): Reference;
|
|
1737
|
+
/** The Reference as Excel writes it: a rectangle in the shape `rectangle` gives it. */
|
|
1738
|
+
write(): string;
|
|
1739
|
+
}
|
|
1740
|
+
|
|
1741
|
+
/**
|
|
1742
|
+
* What F4 makes of the text being edited (ADR-0051): the new text, and the span in it of what was rewritten,
|
|
1743
|
+
* which a grid selects or collapses to a caret at its end as the edit stands.
|
|
1744
|
+
*/
|
|
1745
|
+
export declare interface ReferenceCycle {
|
|
1746
|
+
/** The text with the Reference or References cycled. */
|
|
1747
|
+
readonly text: string;
|
|
1748
|
+
/** Where what was rewritten starts in `text`: at its first column or row part, after any Sheet qualifier before it. */
|
|
1749
|
+
readonly selectionStart: number;
|
|
1750
|
+
/** Where it ends. */
|
|
1751
|
+
readonly selectionEnd: number;
|
|
1752
|
+
}
|
|
1753
|
+
|
|
1754
|
+
declare class ReferenceNode extends NodeBase {
|
|
1755
|
+
readonly kind = "reference";
|
|
1756
|
+
readonly reference: Reference;
|
|
1757
|
+
constructor(reference: Reference);
|
|
1758
|
+
references(): Generator<Reference>;
|
|
1759
|
+
}
|
|
1760
|
+
|
|
1761
|
+
/** The parts of a Reference, for making one with some of them changed (a C# record's `with`). */
|
|
1762
|
+
declare interface ReferenceParts {
|
|
1763
|
+
readonly sheetName: string | undefined;
|
|
1764
|
+
readonly shape: ReferenceShape;
|
|
1765
|
+
readonly row1: number;
|
|
1766
|
+
readonly column1: number;
|
|
1767
|
+
readonly row2: number;
|
|
1768
|
+
readonly column2: number;
|
|
1769
|
+
readonly row1Absolute: boolean;
|
|
1770
|
+
readonly column1Absolute: boolean;
|
|
1771
|
+
readonly row2Absolute: boolean;
|
|
1772
|
+
readonly column2Absolute: boolean;
|
|
1773
|
+
/** `A1#`: the Spill Range of the Formula in this one cell (ADR-0125). */
|
|
1774
|
+
readonly spilled: boolean;
|
|
1775
|
+
/** For a 3D Reference (`Sheet1:Sheet3!B2`, ADR-0331 §7): the name of the Sheet that ends the span, as written. */
|
|
1776
|
+
readonly lastSheetName: string | undefined;
|
|
1777
|
+
}
|
|
1778
|
+
|
|
1779
|
+
/** What a Reference names: one cell, a rectangle, whole columns or whole rows. */
|
|
1780
|
+
declare type ReferenceShape = 'cell' | 'area' | 'columns' | 'rows';
|
|
1781
|
+
|
|
1782
|
+
/**
|
|
1783
|
+
* The Reference Point mode writes for a pointed range: `B7` for one cell, `B7:C9` from its top-left
|
|
1784
|
+
* otherwise. With `sheet`, the name of the Sheet the range was pointed at when that is not the one the
|
|
1785
|
+
* Formula is typed on (ADR-0331 §5), the range qualified with it, quoted where a Reference must quote it —
|
|
1786
|
+
* `Sheet2!B7`, `'Q1 Sales'!B7:C9`. Throws a RangeError when `sheet` is empty.
|
|
1787
|
+
*/
|
|
1788
|
+
export declare function referenceText(range: CellRange, sheet?: string): string;
|
|
1789
|
+
|
|
1790
|
+
/**
|
|
1791
|
+
* Thrown when a snapshot of a Linked Table declared with a key is refused because a key repeats in it (ADR-0049,
|
|
1792
|
+
* 2026-09-30): two rows whose keys `XLOOKUP`'s exact match cannot tell apart. Case does not tell keys apart, and a
|
|
1793
|
+
* blank key is not a key. The snapshot is not taken, and the previous one is not kept: the table waits again, and
|
|
1794
|
+
* every Formula that reads it shows `#GETTING_DATA` until a snapshot in which no key repeats is pushed.
|
|
1795
|
+
*/
|
|
1796
|
+
export declare class RepeatedKeyError extends Error {
|
|
1797
|
+
/** The table's name, as declared. */
|
|
1798
|
+
readonly table: string;
|
|
1799
|
+
/** The key column's name, as declared; for a key of several columns, their names joined by `, `. */
|
|
1800
|
+
readonly keyColumn: string;
|
|
1801
|
+
/** The key that repeats, as the first of its rows holds it; for a key of several columns, its first column's Value. */
|
|
1802
|
+
readonly key: Value;
|
|
1803
|
+
/** The key's columns, as declared (ADR-0058, amended 2026-10-03). */
|
|
1804
|
+
readonly keyColumns: readonly string[];
|
|
1805
|
+
/** The key that repeats, one Value per key column, as the first of its rows holds it. */
|
|
1806
|
+
readonly keys: readonly Value[];
|
|
1807
|
+
/** The first row of the snapshot, from 0, that holds the key. */
|
|
1808
|
+
readonly firstRow: number;
|
|
1809
|
+
/** The row of the snapshot, from 0, that holds it again. */
|
|
1810
|
+
readonly secondRow: number;
|
|
1811
|
+
/** What the table's going back to waiting changed: its readers, and what depends on them, now show `#GETTING_DATA`. */
|
|
1812
|
+
readonly change: SheetChange;
|
|
1813
|
+
/** The key as the second of its rows holds it, one Value per key column, which the message names. @internal */
|
|
1814
|
+
readonly repeats: readonly Value[];
|
|
1815
|
+
/** @internal */
|
|
1816
|
+
constructor(table: string, keyColumns: readonly string[], keys: readonly Value[], firstRow: number, repeats: readonly Value[], secondRow: number, change: SheetChange);
|
|
1817
|
+
}
|
|
1818
|
+
|
|
1819
|
+
/** A Formula rewritten on a Sheet, as it was before. @internal */
|
|
1820
|
+
declare interface RewrittenEntry {
|
|
1821
|
+
readonly sheet: Sheet;
|
|
1822
|
+
readonly address: CellAddress;
|
|
1823
|
+
readonly entry: Entry;
|
|
1824
|
+
}
|
|
1825
|
+
|
|
1826
|
+
/** Excel's extent: how many rows a Sheet has, 1,048,576. */
|
|
1827
|
+
export declare const rowCount = 1048576;
|
|
1828
|
+
|
|
1829
|
+
/** The serial of a calendar day, or `undefined` outside 1900-01-01 … 9999-12-31. 1900-02-29 is 60. */
|
|
1830
|
+
export declare function serialFromDate(year: number, month: number, day: number): number | undefined;
|
|
1831
|
+
|
|
1832
|
+
/**
|
|
1833
|
+
* The grid of cells ExSheet holds: Excel's extent, held sparsely. Not shared between threads of work: one Sheet is
|
|
1834
|
+
* changed and read by one caller at a time. A Sheet belongs to a Workbook (ADR-0331); change it through its
|
|
1835
|
+
* Workbook's `do`.
|
|
1836
|
+
*/
|
|
1837
|
+
export declare class Sheet {
|
|
1838
|
+
#private;
|
|
1839
|
+
/** Excel's row count: 1,048,576 (ADR-0046). */
|
|
1840
|
+
static readonly rowCount = 1048576;
|
|
1841
|
+
/** Excel's column count: 16,384, `A` to `XFD` (ADR-0046). */
|
|
1842
|
+
static readonly columnCount = 16384;
|
|
1843
|
+
/** The name a new Sheet has, as Excel's first sheet does (ADR-0046). */
|
|
1844
|
+
static readonly defaultName = "Sheet1";
|
|
1845
|
+
/** The longest name a Sheet can have: 31 characters, as in Excel. */
|
|
1846
|
+
static readonly maximumNameLength = 31;
|
|
1847
|
+
/** The widest a column can be, in characters: 255, Excel's limit. */
|
|
1848
|
+
static readonly maxColumnWidth = 255;
|
|
1849
|
+
/** Excel's default column width, in characters: 8.43 (ADR-0047). */
|
|
1850
|
+
static readonly defaultColumnWidth = 8.43;
|
|
1851
|
+
/** A number unique to this Sheet in this process, which keys its cells across a Workbook. @internal */
|
|
1852
|
+
readonly id: number;
|
|
1853
|
+
/** The Workbook the Sheet belongs to: one of its own, of this Sheet alone, for a Sheet created on its own (ADR-0331). */
|
|
1854
|
+
readonly workbook: Workbook;
|
|
1855
|
+
/** The Sheet's declared culture (ADR-0048). Formulas are in invariant syntax whatever it is (ADR-0047). */
|
|
1856
|
+
readonly culture: Culture;
|
|
1857
|
+
/** How many passes the last recalculation made (ADR-0124). Layer 1 reads it. @internal */
|
|
1858
|
+
recalculationPasses: number;
|
|
1859
|
+
/** A Sheet named `name` in `workbook`, under its culture (ADR-0331). Throws for a name a Sheet cannot have. @internal */
|
|
1860
|
+
constructor(workbook: Workbook, name: string);
|
|
1861
|
+
/** Records what a document records on this Sheet's columns, rows and cells besides Entries. @internal */
|
|
1862
|
+
openFormats(document: SheetDocument): void;
|
|
1863
|
+
/** Takes a document's Entries, computing every Value again. Opening is no change (ADR-0180). @internal */
|
|
1864
|
+
openEntries(document: SheetDocument): void;
|
|
1865
|
+
/** The Sheet as a Sheet Document declaring `tables` (ADR-0046, ADR-0047, ADR-0048, ADR-0049, ADR-0071). @internal */
|
|
1866
|
+
toDocumentParts(): {
|
|
1867
|
+
cells: SheetDocumentCell[];
|
|
1868
|
+
columns: SheetDocumentAxisFormat[];
|
|
1869
|
+
rows: SheetDocumentAxisFormat[];
|
|
1870
|
+
columnWidths: SheetDocumentColumnWidth[];
|
|
1871
|
+
};
|
|
1872
|
+
/** The cells of this Sheet whose Formula gives an array, spilled or `#SPILL!`: what a new size lays out again (ADR-0460). @internal */
|
|
1873
|
+
get anchors(): SheetCell[];
|
|
1874
|
+
/** The addresses of every cell holding an Entry, in row-major order. */
|
|
1875
|
+
get entryAddresses(): CellAddress[];
|
|
1876
|
+
/**
|
|
1877
|
+
* The text `number` would show in the cell at `address`, under the cell's Number Format and the Sheet's culture
|
|
1878
|
+
* (ADR-0130). `undefined` where the format cannot show it.
|
|
1879
|
+
*/
|
|
1880
|
+
formatAs(address: CellAddress, number: number): string | undefined;
|
|
1881
|
+
/** The addresses of every cell holding a Value — an Entry's, or an array's spilled into it (ADR-0125) — in no particular order. */
|
|
1882
|
+
get valueAddresses(): CellAddress[];
|
|
1883
|
+
/** The cell's Value, or `undefined` for a blank cell. */
|
|
1884
|
+
getValue(address: CellAddress): Value | undefined;
|
|
1885
|
+
/** The cell's Entry, or `undefined` for a blank cell. */
|
|
1886
|
+
getEntry(address: CellAddress): Entry | undefined;
|
|
1887
|
+
/** The text the Cell Editor opens with: the Formula for a Formula, the constant written under the Sheet's culture otherwise. Empty for a blank cell. */
|
|
1888
|
+
getEntryText(address: CellAddress): string;
|
|
1889
|
+
/**
|
|
1890
|
+
* What the cell shows: its Value formatted by its number format under the Sheet's culture, with its alignment
|
|
1891
|
+
* resolved (ADR-0046/0047). Without a width, at no particular width — a number in General in full, at fifteen
|
|
1892
|
+
* significant digits. With a width, in a column `width` characters wide (ADR-0047, ADR-0016): General is fitted
|
|
1893
|
+
* as Excel's General fits it, and a number in any other format whose text is longer cannot be shown.
|
|
1894
|
+
*/
|
|
1895
|
+
getDisplay(address: CellAddress, width?: number): CellDisplay;
|
|
1896
|
+
/** Takes text as the user typed it into a cell, read under the Sheet's culture, and recalculates. @internal */
|
|
1897
|
+
enter(address: CellAddress, typed: string): SheetChange;
|
|
1898
|
+
/**
|
|
1899
|
+
* Takes several typed texts as one change, with one recalculation. If any text is a Formula that cannot be
|
|
1900
|
+
* read, nothing changes. `pasted`: the texts were pasted from another program, and a text beginning with `=`
|
|
1901
|
+
* that cannot be read as a Formula is taken as text (ADR-0048). @internal
|
|
1902
|
+
*/
|
|
1903
|
+
enterMany(typed: Iterable<TypedCell>, pasted?: boolean): SheetChange;
|
|
1904
|
+
/** Excel's Ctrl+Enter (ADR-0050 item 5): `typed` read as entered in `enteredAt`, written into every cell of `cells`. @internal */
|
|
1905
|
+
enterInto(cells: readonly CellAddress[], enteredAt: CellAddress, typed: string): SheetChange;
|
|
1906
|
+
/** Sets or clears one cell's Entry, and recalculates. @internal */
|
|
1907
|
+
setEntry(address: CellAddress, entry: Entry | undefined): SheetChange;
|
|
1908
|
+
/** Sets or clears several cells' Entries as one change, with one recalculation. A later pair for the same cell wins. @internal */
|
|
1909
|
+
setEntries(entries: Iterable<EntryOfCell>): SheetChange;
|
|
1910
|
+
/** The addresses inside `area` that hold something, in no particular order. @internal */
|
|
1911
|
+
cellsIn(area: Area): Generator<CellAddress>;
|
|
1912
|
+
/** The cell held at `address`. @internal */
|
|
1913
|
+
cellAt(address: CellAddress): Cell | undefined;
|
|
1914
|
+
/** The Formula whose result a cell shows: its own, or for a cell of a Spill Range its Anchor's (ADR-0125). @internal */
|
|
1915
|
+
formulaShownAt(address: CellAddress): Node_2 | undefined;
|
|
1916
|
+
/** Every held cell's state, keyed by address. @internal */
|
|
1917
|
+
snapshot(): Map<number, CellState>;
|
|
1918
|
+
/** States about to be written whole, each part kept only where it differs from what its row or column gives it. @internal */
|
|
1919
|
+
settle(states: Iterable<AddressedState>): AddressedState[];
|
|
1920
|
+
/** The change between `before` and now, address by address. @internal */
|
|
1921
|
+
diff(before: ReadonlyMap<number, CellState>, recalculated: Iterable<CellAddress>, shownBefore?: ReadonlyMap<number, CellFormat>): SheetChange;
|
|
1922
|
+
/** Forgets and rebuilds the dependency graph from every Formula held. @internal */
|
|
1923
|
+
rebuildDependencies(): void;
|
|
1924
|
+
/** The cell's Cell Format as it shows: each part the cell's own, else its row's, else its column's, else the part's default (ADR-0047, ADR-0071, SH-38). */
|
|
1925
|
+
getCellFormat(address: CellAddress): CellFormat;
|
|
1926
|
+
/** The cell's Number Format, as it takes effect: cell over row over column, else General (ADR-0047). */
|
|
1927
|
+
getNumberFormat(address: CellAddress): NumberFormat;
|
|
1928
|
+
/** The cell's horizontal alignment setting, as it takes effect: cell over row over column (ADR-0047). */
|
|
1929
|
+
getAlignment(address: CellAddress): HorizontalAlignment;
|
|
1930
|
+
/** The cell's Font, as it takes effect: cell over row over column (ADR-0071, SH-38). */
|
|
1931
|
+
getFont(address: CellAddress): CellFont;
|
|
1932
|
+
/** The cell's Fill, as it takes effect: cell over row over column (ADR-0071, SH-38). */
|
|
1933
|
+
getFill(address: CellAddress): CellFill;
|
|
1934
|
+
/**
|
|
1935
|
+
* The line on each of the cell's four sides as it shows, which is the line on the edge it shares with the cell
|
|
1936
|
+
* beside it, read the same from either cell (ADR-0071; the twelfth Windows run): the upper cell's, or the left
|
|
1937
|
+
* cell's, where both record one; where only one does, that one.
|
|
1938
|
+
*/
|
|
1939
|
+
getBorders(address: CellAddress): CellBorders;
|
|
1940
|
+
/** The Number Format recorded on the whole row, or `undefined` when none is (ADR-0047). */
|
|
1941
|
+
getRowNumberFormat(row: number): NumberFormat | undefined;
|
|
1942
|
+
/** The Number Format recorded on the whole column, or `undefined` when none is (ADR-0047). */
|
|
1943
|
+
getColumnNumberFormat(column: number): NumberFormat | undefined;
|
|
1944
|
+
/** The alignment recorded on the whole row, or `undefined` when none is (ADR-0047). */
|
|
1945
|
+
getRowAlignment(row: number): HorizontalAlignment | undefined;
|
|
1946
|
+
/** The alignment recorded on the whole column, or `undefined` when none is (ADR-0047). */
|
|
1947
|
+
getColumnAlignment(column: number): HorizontalAlignment | undefined;
|
|
1948
|
+
/** Sets the Number Format of cells; `undefined` is General. No Value changes. @internal */
|
|
1949
|
+
setNumberFormatOf(addresses: Iterable<CellAddress>, format: NumberFormat | undefined): SheetChange;
|
|
1950
|
+
/** Sets the Number Format of a range; `undefined` is General. Whole columns and whole rows record one entry each (ADR-0047). @internal */
|
|
1951
|
+
setNumberFormat(range: CellRange, format: NumberFormat | undefined): SheetChange;
|
|
1952
|
+
/** Sets the horizontal alignment of cells. No Value changes. @internal */
|
|
1953
|
+
setAlignmentOf(addresses: Iterable<CellAddress>, alignment: HorizontalAlignment): SheetChange;
|
|
1954
|
+
/** Sets the horizontal alignment of a range, recording whole columns and whole rows as one entry each. @internal */
|
|
1955
|
+
setAlignment(range: CellRange, alignment: HorizontalAlignment): SheetChange;
|
|
1956
|
+
/** Sets the parts `change` names on several ranges at once (ADR-0046, ADR-0071). @internal */
|
|
1957
|
+
setCellFormat(ranges: Iterable<CellRange>, change: CellFormatChange): SheetChange;
|
|
1958
|
+
/** The ranges a change is set on, checked with the change. Throws for no range, a change that sets nothing, or an alignment that is not one. @internal */
|
|
1959
|
+
static checkCellFormat(ranges: Iterable<CellRange>, change: CellFormatChange): CellRange[];
|
|
1960
|
+
/** Sets `change` on each range in turn, as one change. @internal */
|
|
1961
|
+
applyCellFormats(ranges: readonly CellRange[], change: CellFormatChange): CellFormatsOutcome;
|
|
1962
|
+
/** Undoes a change set on several ranges, each range's part in the reverse of the order it was set. @internal */
|
|
1963
|
+
undoCellFormats(outcome: CellFormatsOutcome): SheetChange;
|
|
1964
|
+
/**
|
|
1965
|
+
* A change set on a range, as Excel sets it (ADR-0047, ADR-0071): on the range, and, across each outer edge
|
|
1966
|
+
* the change sets, on the cells beside it, whose record of that edge it clears. Undoing it puts back both. @internal
|
|
1967
|
+
*/
|
|
1968
|
+
applyCellFormat(range: CellRange, change: CellFormatChange): CellFormatOutcome;
|
|
1969
|
+
/** Undoes a formatting command: the row and column levels, then the cells, exactly as they were. @internal */
|
|
1970
|
+
undoCellFormat(outcome: CellFormatOutcome): SheetChange;
|
|
1971
|
+
/**
|
|
1972
|
+
* The Cell Formats the cells of `range` show, each once (ADR-0071): what Format Cells reads to show a part that
|
|
1973
|
+
* differs across the Selection. Its Borders are each cell's own four sides. Read from what the Sheet records,
|
|
1974
|
+
* never cell by cell (principle 5).
|
|
1975
|
+
*/
|
|
1976
|
+
getCellFormats(range: CellRange): CellFormat[];
|
|
1977
|
+
/** The lines drawn along each outer edge of `range`, each once per edge (ADR-0071; the fourteenth Windows run, case 13). */
|
|
1978
|
+
getEdgeLines(range: CellRange): RangeEdgeLines;
|
|
1979
|
+
/** The Formula cells, on any Sheet of the Workbook, that read `address` of this Sheet directly. @internal */
|
|
1980
|
+
dependentsInWorkbook(address: CellAddress): Generator<SheetCell>;
|
|
1981
|
+
/** The Sheet a Reference's qualifier names: this one for none or its own name, another of the Workbook for its name; `undefined` for a name no Sheet has. @internal */
|
|
1982
|
+
sheetNamed(qualifier: string | undefined): Sheet | undefined;
|
|
1983
|
+
/**
|
|
1984
|
+
* One recalculation: what `changed` reaches and every volatile Formula of the Workbook, the moment read once
|
|
1985
|
+
* (ADR-0124); then the spills laid out, Sheet by Sheet, and what their layout changed recalculated with every
|
|
1986
|
+
* volatile Formula, until a layout changes nothing. What it changed on each Sheet it reached; `initiator`'s
|
|
1987
|
+
* always. @internal
|
|
1988
|
+
*/
|
|
1989
|
+
static recalculateWorkbook(workbook: Workbook, changed: SheetCellSet, initiator: Sheet, initiatorRows: Set<number>): Map<Sheet, SheetChange>;
|
|
1990
|
+
/** The Anchor whose array gives a cell its Value, or `undefined` for a cell no array spills into (ADR-0125). */
|
|
1991
|
+
spilledFrom(address: CellAddress): CellAddress | undefined;
|
|
1992
|
+
/** The moment read at the start of the recalculation under way. @internal */
|
|
1993
|
+
get moment(): SheetMoment | undefined;
|
|
1994
|
+
/** Whether any Formula of this Sheet calls a volatile function. @internal */
|
|
1995
|
+
get hasVolatileFormulas(): boolean;
|
|
1996
|
+
/** One recalculation of `cells`, on any Sheet of the Workbook, started from this Sheet, with every volatile Formula: what it changed here. @internal */
|
|
1997
|
+
recalculateCells(cells: SheetCellSet): SheetChange;
|
|
1998
|
+
/** The Formula cells of this Sheet that call `TODAY`. @internal */
|
|
1999
|
+
get todayReaders(): SheetCell[];
|
|
2000
|
+
/** The Formula cells of this Sheet that call `RAND` or `RANDBETWEEN`. @internal */
|
|
2001
|
+
get randomReaders(): SheetCell[];
|
|
2002
|
+
/** Does `operation` as one operation of the Workbook. @internal */
|
|
2003
|
+
asOneChange<T>(operation: () => T): T;
|
|
2004
|
+
/** Counts a change of the Workbook. @internal */
|
|
2005
|
+
countChange(): void;
|
|
2006
|
+
/** The draw for the call at `place` in the Formula of `cell`, or `undefined` without a seed (ADR-0180). @internal */
|
|
2007
|
+
draw(cell: CellAddress, place: number): bigint | undefined;
|
|
2008
|
+
/**
|
|
2009
|
+
* Completion for the Formula being typed (ADR-0051, ADR-0058): the declared functions and the Workbook's Linked
|
|
2010
|
+
* Tables whose names begin with the name at the caret, the columns of one of its tables after `Table[`, and an
|
|
2011
|
+
* argument's values where it takes one of a fixed list (`completeFormula`).
|
|
2012
|
+
*/
|
|
2013
|
+
complete(text: string, caret: number): FormulaCompletion | undefined;
|
|
2014
|
+
/**
|
|
2015
|
+
* The References in the Formula being edited (ADR-0057), a qualifier naming this Sheet by its name as it is now
|
|
2016
|
+
* (`formulaReferences`). A structured reference is kept only when its Linked Table is declared with that
|
|
2017
|
+
* column: one naming a table or a column that is not names nothing, as a Reference to another Sheet does not. A
|
|
2018
|
+
* declared table still waiting for its data is kept.
|
|
2019
|
+
*/
|
|
2020
|
+
references(text: string): readonly FormulaReference[];
|
|
2021
|
+
/** The Linked Tables declared on the Sheet's Workbook, in the order they were declared. @internal */
|
|
2022
|
+
get linkedTables(): LinkedTable[];
|
|
2023
|
+
/** Declares a Linked Table on the Workbook: what it changed on this Sheet. @internal */
|
|
2024
|
+
declareLinkedTable(name: string, columns: readonly string[], key?: readonly string[]): SheetChange;
|
|
2025
|
+
/** Records a Linked Table's declaration on the Workbook, checked already. @internal */
|
|
2026
|
+
declare(name: string, columns: readonly string[], key: readonly string[], order?: number): void;
|
|
2027
|
+
/** Why a name and columns cannot be declared as a Linked Table, or `undefined` when they can. @internal */
|
|
2028
|
+
static whyNotALinkedTable(name: string, columns: readonly string[]): string | undefined;
|
|
2029
|
+
/** Why a key cannot be declared with a table's columns, or `undefined` when it can (ADR-0049, 2026-09-30). @internal */
|
|
2030
|
+
static whyNotAKey(name: string, columns: readonly string[], key: readonly string[]): string | undefined;
|
|
2031
|
+
/** The declarations, as a Sheet Document records them (ADR-0049). @internal */
|
|
2032
|
+
get tableDeclarations(): SheetDocumentTable[];
|
|
2033
|
+
/** Takes a Linked Table's snapshot: what it changed on this Sheet. @internal */
|
|
2034
|
+
pushLinkedTable(name: string, rows: Iterable<readonly (Value | undefined)[]>): SheetChange;
|
|
2035
|
+
/** What a structured reference reads (ADR-0049). @internal */
|
|
2036
|
+
tableColumn(name: string, column: string): Operand;
|
|
2037
|
+
/** Whether a Linked Table's column holds a refusal (ADR-0047; 2026-10-12, decided with the user). @internal */
|
|
2038
|
+
columnHoldsRefusal(name: string, column: string): boolean;
|
|
2039
|
+
/**
|
|
2040
|
+
* The Sheet's name (ADR-0046). A Reference qualified with it (`Sheet1!A1`, matched without regard to case) names
|
|
2041
|
+
* this Sheet's cells.
|
|
2042
|
+
*/
|
|
2043
|
+
get name(): string;
|
|
2044
|
+
/** Gives the Sheet a new name; the Workbook checks it and rewrites the References that name the Sheet. @internal */
|
|
2045
|
+
setName(name: string): void;
|
|
2046
|
+
/**
|
|
2047
|
+
* Why `name` is not a name a Sheet can have, as Excel decides one — 1 to 31 characters, none of `: \ / ? * [ ]`,
|
|
2048
|
+
* not beginning or ending with `'`, and not `History` — or `undefined` when it is one.
|
|
2049
|
+
*/
|
|
2050
|
+
static whyNotAName(name: string): string | undefined;
|
|
2051
|
+
/** Whether `name` is a name a Sheet can have (`whyNotAName`). */
|
|
2052
|
+
static isValidName(name: string): boolean;
|
|
2053
|
+
/** `name`, checked: throws a RangeError for a name a Sheet cannot have. @internal */
|
|
2054
|
+
static checkName(name: string): string;
|
|
2055
|
+
/** Renames the Sheet (ADR-0046) through its Workbook. @internal */
|
|
2056
|
+
rename(name: string): SheetChange;
|
|
2057
|
+
/** Whether `qualifier`, a Reference's Sheet name, names this Sheet: no qualifier, or this Sheet's name without regard to case. @internal */
|
|
2058
|
+
isThisSheet(qualifier: string | undefined): boolean;
|
|
2059
|
+
/** Whether `qualifier` names the Sheet called `name`: no qualifier, or that name without regard to case. @internal */
|
|
2060
|
+
static names(qualifier: string | undefined, name: string): boolean;
|
|
2061
|
+
/** Whether a Reference names this Sheet's cells alone: a 3D Reference never does (ADR-0331 §7). @internal */
|
|
2062
|
+
isLocal(reference: Reference): boolean;
|
|
2063
|
+
/** A typed Formula with every qualifier that names this Sheet written in the Sheet's own name (TEXT-083). The same instance when nothing changes. @internal */
|
|
2064
|
+
inOwnName(entry: Entry): Entry;
|
|
2065
|
+
/** A typed Formula with every structured reference to a declared Linked Table written in the declared case (ticket 180). The same instance when nothing changes. @internal */
|
|
2066
|
+
inDeclaredCase(entry: Entry): Entry;
|
|
2067
|
+
/** Renames the Sheet through its Workbook, which rewrites every Sheet's References to it (ADR-0331). @internal */
|
|
2068
|
+
applyRename(name: string): SheetRename;
|
|
2069
|
+
/** Undoes a rename. @internal */
|
|
2070
|
+
undoRename(rename: SheetRename): SheetChange;
|
|
2071
|
+
/** Every Formula cell and its Entry. @internal */
|
|
2072
|
+
formulaEntries(): {
|
|
2073
|
+
address: CellAddress;
|
|
2074
|
+
entry: Entry;
|
|
2075
|
+
}[];
|
|
2076
|
+
/** The Formula cells with a qualified Reference. @internal */
|
|
2077
|
+
qualifiedFormulas(): CellAddress[];
|
|
2078
|
+
/** Puts an Entry in a cell without recalculating or registering it. @internal */
|
|
2079
|
+
replaceEntry(address: CellAddress, entry: Entry): void;
|
|
2080
|
+
/** Forgets every Reference this Sheet's Formulas make to another Sheet, on the Sheets they name. @internal */
|
|
2081
|
+
unregisterAllRemote(): void;
|
|
2082
|
+
/** The width recorded on the column, and its kind, or `undefined` when none is (ADR-0046). Throws for a column outside `A` to `XFD`. */
|
|
2083
|
+
getColumnWidth(column: number): SheetColumnWidth | undefined;
|
|
2084
|
+
/** Sets the width of every column `columns` spans, as a width the user set; `undefined` puts them back at the default width (ADR-0046). @internal */
|
|
2085
|
+
setColumnWidth(columns: CellRange, width: number | undefined): SheetChange;
|
|
2086
|
+
/** Sets the width of every column `columns` spans, as a width an entry widened them to (ADR-0046, 2026-09-28). @internal */
|
|
2087
|
+
setAutomaticColumnWidth(columns: CellRange, width: number): SheetChange;
|
|
2088
|
+
/** `width`, checked: more than 0 and at most `maxColumnWidth`, or `undefined`. @internal */
|
|
2089
|
+
static checkColumnWidth(width: number | undefined): number | undefined;
|
|
2090
|
+
/** A width set on columns, and the widths before it for undoing it. @internal */
|
|
2091
|
+
applyColumnWidth(columns: CellRange, width: SheetColumnWidth | undefined): {
|
|
2092
|
+
change: SheetChange;
|
|
2093
|
+
before: Map<number, SheetColumnWidth>;
|
|
2094
|
+
};
|
|
2095
|
+
/** Puts every column's width back to `widths`, and says which columns that changed. @internal */
|
|
2096
|
+
restoreColumnWidths(widths: ReadonlyMap<number, SheetColumnWidth>): SheetChange;
|
|
2097
|
+
/** A copy of the widths recorded now. @internal */
|
|
2098
|
+
columnWidthsNow(): Map<number, SheetColumnWidth>;
|
|
2099
|
+
/**
|
|
2100
|
+
* The width, in characters, that the number typed into this cell needs, for widening a column whose width the
|
|
2101
|
+
* user has not set when the number is typed, as Excel does (ADR-0047); `undefined` when what the cell holds never
|
|
2102
|
+
* widens a column.
|
|
2103
|
+
*/
|
|
2104
|
+
getWidthOnEntry(address: CellAddress): number | undefined;
|
|
2105
|
+
/** The cells in `range` that hold an Entry, in no particular order (ADR-0071, case 17). */
|
|
2106
|
+
entryAddressesIn(range: CellRange): CellAddress[];
|
|
2107
|
+
/** Inserts `count` rows at `row` (ADR-0046/0047). @internal */
|
|
2108
|
+
insertRows(row: number, count?: number): SheetChange;
|
|
2109
|
+
/** Deletes `count` rows from `row` (ADR-0047). @internal */
|
|
2110
|
+
deleteRows(row: number, count?: number): SheetChange;
|
|
2111
|
+
/** Inserts columns, as `insertRows` does rows (ADR-0046, ADR-0047, ADR-0071). @internal */
|
|
2112
|
+
insertColumns(column: number, count?: number): SheetChange;
|
|
2113
|
+
/** Deletes columns, as `deleteRows` does rows (ADR-0046). @internal */
|
|
2114
|
+
deleteColumns(column: number, count?: number): SheetChange;
|
|
2115
|
+
/** Whether `edit` would be refused, and why; nothing changes either way. @internal */
|
|
2116
|
+
checkStructural(edit: StructuralEdit): SheetRefusal | undefined;
|
|
2117
|
+
/** An insertion or deletion. `formatInserted`: whether inserted rows or columns take the Cell Format of the one before them (ADR-0046). @internal */
|
|
2118
|
+
restructure(edit: StructuralEdit, formatInserted?: boolean): StructuralOutcome;
|
|
2119
|
+
/** Does `edit` as one operation and returns the step that undoes it (ADR-0048). @internal */
|
|
2120
|
+
do(edit: SheetEdit): SheetStep;
|
|
2121
|
+
/** Whether `do` would refuse `edit` as the Sheet stands, and why. @internal */
|
|
2122
|
+
check(edit: SheetEdit): SheetRefusal | undefined;
|
|
2123
|
+
/** What each of `addresses` records: Entry and Cell Format, never a Value. @internal */
|
|
2124
|
+
record(addresses: Iterable<CellAddress>): AddressedState[];
|
|
2125
|
+
/** Puts cells back to what they recorded, as one change with one recalculation. A changed top or bottom side names the row across it too. @internal */
|
|
2126
|
+
restore(states: Iterable<AddressedState>): SheetChange;
|
|
2127
|
+
/** Undoes a structural edit: the inverse edit, then the rewritten Formulas and the dropped cells put back. @internal */
|
|
2128
|
+
unrestructure(edit: StructuralEdit, outcome: StructuralOutcome): SheetChange;
|
|
2129
|
+
/** Copies a rectangle (ADR-0048): its Entries for a paste inside ExSheet, and its Values for anywhere else. A rectangle holding a `#GETTING_DATA` Value is refused whole (ADR-0049). */
|
|
2130
|
+
copy(range: CellRange): SheetCopy;
|
|
2131
|
+
/** The states a block pasted at `origin` writes; a blank cell of the block clears the cell it lands on. @internal */
|
|
2132
|
+
static place(block: SheetBlock, origin: CellAddress): Generator<AddressedState>;
|
|
2133
|
+
/** A block of `rows` × `columns` at `origin` that would run past the Sheet's edge: Excel's, or the Workbook's size (ADR-0460). @internal */
|
|
2134
|
+
offSheet(origin: CellAddress, rows: number, columns: number): SheetRefusal | undefined;
|
|
2135
|
+
/** The first of `ranges` that runs past the Workbook's size, refused by name (ADR-0460). @internal */
|
|
2136
|
+
pastSize(ranges: Iterable<CellRange>): SheetRefusal | undefined;
|
|
2137
|
+
/** What a Fill Intent writes, as Excel fills (ADR-0050, item 5), or why it is refused. `copyOnly`: Excel's fill keys. @internal */
|
|
2138
|
+
planFill(source: CellRange, target: CellRange, direction: FillDirection, copyOnly?: boolean): FillPlan;
|
|
2139
|
+
/** Does a fill planned with levels: the target columns' (rows') formats first, then each cell's state settled against them, as one step. @internal */
|
|
2140
|
+
doFillWithLevels(plan: FillPlan): SheetStep;
|
|
2141
|
+
}
|
|
2142
|
+
|
|
2143
|
+
/** Which of a Sheet's two axes an insertion or deletion runs along. */
|
|
2144
|
+
declare type SheetAxis = 'rows' | 'columns';
|
|
2145
|
+
|
|
2146
|
+
/**
|
|
2147
|
+
* A rectangle of cells copied inside ExSheet: each cell's Entry and the Cell Format it showed, as they were at the
|
|
2148
|
+
* copy, and where they came from (ADR-0048, ADR-0071). Pasting it writes the Entries with their relative References
|
|
2149
|
+
* shifted by the distance pasted, as Excel does, and the Cell Formats with them. Immutable.
|
|
2150
|
+
*/
|
|
2151
|
+
export declare class SheetBlock {
|
|
2152
|
+
#private;
|
|
2153
|
+
/** The range the block was copied from. */
|
|
2154
|
+
readonly source: CellRange;
|
|
2155
|
+
/** @internal */
|
|
2156
|
+
constructor(source: CellRange, cells: readonly CellState[]);
|
|
2157
|
+
/** How many rows the block holds. */
|
|
2158
|
+
get rowCount(): number;
|
|
2159
|
+
/** How many columns the block holds. */
|
|
2160
|
+
get columnCount(): number;
|
|
2161
|
+
/** The Entry at a position inside the block, as copied; `undefined` for a blank cell. */
|
|
2162
|
+
entryAt(row: number, column: number): Entry | undefined;
|
|
2163
|
+
/** The Cell Format at a position inside the block: what the cell showed at the copy, its Borders its own four sides. */
|
|
2164
|
+
cellFormatAt(row: number, column: number): CellFormat;
|
|
2165
|
+
/** The cell at a position inside the block, as copied: its Entry and the Cell Format it showed. @internal */
|
|
2166
|
+
at(row: number, column: number): CellState;
|
|
2167
|
+
}
|
|
2168
|
+
|
|
2169
|
+
/** A cell of one Sheet of a Workbook. @internal */
|
|
2170
|
+
declare class SheetCell {
|
|
2171
|
+
readonly sheet: Sheet;
|
|
2172
|
+
readonly address: CellAddress;
|
|
2173
|
+
constructor(sheet: Sheet, address: CellAddress);
|
|
2174
|
+
/** A key two SheetCells naming the same cell share. */
|
|
2175
|
+
get key(): string;
|
|
2176
|
+
}
|
|
2177
|
+
|
|
2178
|
+
/** A set of SheetCells, compared by the cell they name, in the order first added. @internal */
|
|
2179
|
+
declare class SheetCellSet implements Iterable<SheetCell> {
|
|
2180
|
+
#private;
|
|
2181
|
+
constructor(cells?: Iterable<SheetCell>);
|
|
2182
|
+
/** Adds `cell`; whether it was not there yet. */
|
|
2183
|
+
add(cell: SheetCell): boolean;
|
|
2184
|
+
addAll(cells: Iterable<SheetCell>): void;
|
|
2185
|
+
has(cell: SheetCell): boolean;
|
|
2186
|
+
delete(cell: SheetCell): boolean;
|
|
2187
|
+
get size(): number;
|
|
2188
|
+
[Symbol.iterator](): Iterator<SheetCell>;
|
|
2189
|
+
}
|
|
2190
|
+
|
|
2191
|
+
/**
|
|
2192
|
+
* What one change to a Sheet did, reported after its recalculation has completed. Every Value it names is already
|
|
2193
|
+
* published, and all of them come from that one recalculation (ADR-0047).
|
|
2194
|
+
*/
|
|
2195
|
+
export declare class SheetChange {
|
|
2196
|
+
/** The cells whose Value changed (a cell becoming blank included), in row-major order. */
|
|
2197
|
+
readonly valueChanges: readonly CellAddress[];
|
|
2198
|
+
/** The Formula cells this change recomputed, in row-major order: the changed cells and the cells that depend on them, and no other (ADR-0047). */
|
|
2199
|
+
readonly recalculated: readonly CellAddress[];
|
|
2200
|
+
/** The rows whose painted content may differ — a Value, an Entry or a cell's formatting changed — in ascending order, each once. */
|
|
2201
|
+
readonly rows: readonly number[];
|
|
2202
|
+
/** The columns whose recorded width changed (ADR-0046) — set, cleared back to the default, or moved by an insertion or deletion — in ascending order, each once. */
|
|
2203
|
+
readonly columns: readonly number[];
|
|
2204
|
+
/**
|
|
2205
|
+
* Whether the Cell Format shown in rows `rows` does not name may have changed (ADR-0071): after a whole row's or
|
|
2206
|
+
* column's Cell Format set, cleared or moved, or rows or columns inserted or deleted. A component that paints a
|
|
2207
|
+
* Cell Format then reads again what each row it paints shows.
|
|
2208
|
+
*/
|
|
2209
|
+
readonly reformatsUnnamedRows: boolean;
|
|
2210
|
+
/** @internal */
|
|
2211
|
+
constructor(valueChanges: readonly CellAddress[], recalculated: readonly CellAddress[], rows: readonly number[], columns?: readonly number[], reformatsUnnamedRows?: boolean);
|
|
2212
|
+
/** A change that changed nothing. @internal */
|
|
2213
|
+
static readonly none: SheetChange;
|
|
2214
|
+
/** This change, also reporting that it may have reformatted rows it does not name. @internal */
|
|
2215
|
+
reformattingUnnamedRows(): SheetChange;
|
|
2216
|
+
/** Several changes made as one, such as the parts of one step. @internal */
|
|
2217
|
+
static merge(changes: Iterable<SheetChange>): SheetChange;
|
|
2218
|
+
}
|
|
2219
|
+
|
|
2220
|
+
/**
|
|
2221
|
+
* A width recorded on a column (ADR-0046): how wide it is, in characters of the default font (Excel's unit,
|
|
2222
|
+
* ADR-0047), and what recorded it. Both kinds are marked custom, as Excel's file marks a column an entry widened as
|
|
2223
|
+
* well as one the user set (`customWidth`; CW-018, CW-027..029).
|
|
2224
|
+
*/
|
|
2225
|
+
export declare class SheetColumnWidth {
|
|
2226
|
+
/** How wide the column is, in characters of the default font. */
|
|
2227
|
+
readonly width: number;
|
|
2228
|
+
/** What recorded it. */
|
|
2229
|
+
readonly kind: SheetColumnWidthKind;
|
|
2230
|
+
constructor(width: number, kind: SheetColumnWidthKind);
|
|
2231
|
+
/** Whether Excel's file marks the width custom (`customWidth`): every recorded width is, whichever its kind. */
|
|
2232
|
+
get isCustom(): boolean;
|
|
2233
|
+
/** Whether the user set the width, so an entry never widens the column. */
|
|
2234
|
+
get isSetByUser(): boolean;
|
|
2235
|
+
/** Whether `other` is the same width, recorded the same way. */
|
|
2236
|
+
equals(other: SheetColumnWidth): boolean;
|
|
2237
|
+
}
|
|
2238
|
+
|
|
2239
|
+
/**
|
|
2240
|
+
* What recorded a column's width (ADR-0046, 2026-09-28; SH-26). `widenedByEntry`: an entry that widened the column,
|
|
2241
|
+
* which a longer entry widens again (CW-028, third run). `setByUser`: a drag, a size to fit, a command, or a column
|
|
2242
|
+
* inserted to the right of a recorded width; an entry never widens it.
|
|
2243
|
+
*/
|
|
2244
|
+
export declare type SheetColumnWidthKind = 'widenedByEntry' | 'setByUser';
|
|
2245
|
+
|
|
2246
|
+
/**
|
|
2247
|
+
* A copy of a rectangle of cells, or its refusal (ADR-0048, ADR-0049): the Entries for a paste inside ExSheet, and
|
|
2248
|
+
* the Values for anywhere else in the two flavours ExGrid puts on the clipboard (ADR-0005).
|
|
2249
|
+
*/
|
|
2250
|
+
export declare class SheetCopy {
|
|
2251
|
+
/** Why the copy is refused — a cell in it is `#GETTING_DATA` (ADR-0049) — or `undefined`. A refused copy carries nothing. */
|
|
2252
|
+
readonly refusal: SheetRefusal | undefined;
|
|
2253
|
+
/** The Entries, for a paste inside ExSheet. */
|
|
2254
|
+
readonly block: SheetBlock | undefined;
|
|
2255
|
+
/** The `text/plain` flavour: each Value as the cell shows it, tab-separated, one line per row ending in CR LF. */
|
|
2256
|
+
readonly text: string | undefined;
|
|
2257
|
+
/** The `text/html` flavour: a table of the unformatted Values, invariant, in Excel's markup. */
|
|
2258
|
+
readonly html: string | undefined;
|
|
2259
|
+
/** @internal */
|
|
2260
|
+
constructor(refusal: SheetRefusal | undefined, block: SheetBlock | undefined, text: string | undefined, html: string | undefined);
|
|
2261
|
+
/** Whether the copy is refused (`refusal`). */
|
|
2262
|
+
get isRefused(): boolean;
|
|
2263
|
+
}
|
|
2264
|
+
|
|
2265
|
+
/** A calendar day: the Sheet Day `TODAY` answers (ADR-0121). */
|
|
2266
|
+
export declare interface SheetDay {
|
|
2267
|
+
/** The year, 1900 to 9999. */
|
|
2268
|
+
readonly year: number;
|
|
2269
|
+
/** 1 to 12. */
|
|
2270
|
+
readonly month: number;
|
|
2271
|
+
/** 1 to 31. */
|
|
2272
|
+
readonly day: number;
|
|
2273
|
+
}
|
|
2274
|
+
|
|
2275
|
+
/**
|
|
2276
|
+
* The serialisable form of a Sheet (CONTEXT.md, ADR-0048): its culture, its name (ADR-0046), the Linked Tables declared
|
|
2277
|
+
* on it — names, columns and keys, never rows (ADR-0049) — its Entries, the Cell Formats recorded on its columns, rows
|
|
2278
|
+
* and cells (ADR-0047, ADR-0071) and the widths set on its columns (ADR-0046), and never a Value: opening one computes
|
|
2279
|
+
* every Value again. The Consumer persists it; ExSheet never does.
|
|
2280
|
+
*
|
|
2281
|
+
* The document is a format with a version. A reader meeting a version it does not know refuses the document rather
|
|
2282
|
+
* than guess at it (ADR-0048); so does a reader meeting anything it does not understand. This engine writes version 9
|
|
2283
|
+
* and reads versions 1 to 9, each as the C# engine's remarks on SheetDocument describe.
|
|
2284
|
+
*/
|
|
2285
|
+
export declare class SheetDocument {
|
|
2286
|
+
/** The version this engine writes. */
|
|
2287
|
+
static readonly currentVersion = 9;
|
|
2288
|
+
/** The oldest version this engine reads. */
|
|
2289
|
+
static readonly oldestReadableVersion = 1;
|
|
2290
|
+
/** The cells that hold something, in row-major order. */
|
|
2291
|
+
readonly cells: readonly SheetDocumentCell[];
|
|
2292
|
+
/** The Cell Formats recorded on whole columns, in column order. Empty for a document read from version 1 or 2. */
|
|
2293
|
+
readonly columns: readonly SheetDocumentAxisFormat[];
|
|
2294
|
+
/** The Cell Formats recorded on whole rows, in row order. Empty for a document read from version 1 or 2. */
|
|
2295
|
+
readonly rows: readonly SheetDocumentAxisFormat[];
|
|
2296
|
+
/** The widths recorded on columns, in column order. Empty for a document read from versions 1 to 3. */
|
|
2297
|
+
readonly columnWidths: readonly SheetDocumentColumnWidth[];
|
|
2298
|
+
/** The name of the Sheet's declared culture, such as `en-US`; empty for the invariant culture, as .NET names it. */
|
|
2299
|
+
readonly culture: string;
|
|
2300
|
+
/** The Sheet's name (ADR-0046); `Sheet1` for a document read from version 1. */
|
|
2301
|
+
readonly name: string;
|
|
2302
|
+
/** The Linked Tables declared on the Sheet, in the order they were declared (ADR-0049). */
|
|
2303
|
+
readonly linkedTables: readonly SheetDocumentTable[];
|
|
2304
|
+
/** @internal */
|
|
2305
|
+
constructor(culture: string, name: string, linkedTables: readonly SheetDocumentTable[], cells: readonly SheetDocumentCell[], layout?: SheetDocumentLayout);
|
|
2306
|
+
/**
|
|
2307
|
+
* A Sheet Document built from its parts, as a reader of another format builds one (ADR-0330): a Sheet named `name`
|
|
2308
|
+
* holding `cells` under `culture`, declaring no Linked Table. The cells are recorded in row-major order whatever
|
|
2309
|
+
* order they come in. Throws a RangeError for a culture this engine does not know, a name a Sheet cannot have, or a
|
|
2310
|
+
* cell that appears twice. Nothing is guessed.
|
|
2311
|
+
*/
|
|
2312
|
+
static of(culture: Culture, name: string, cells: Iterable<SheetDocumentCell>, layout?: SheetDocumentLayout): SheetDocument;
|
|
2313
|
+
/** The format version the document is written in: `currentVersion`, whatever version it was read from. */
|
|
2314
|
+
get version(): number;
|
|
2315
|
+
/** Writes the document as JSON, as the C# engine writes it. */
|
|
2316
|
+
toJson(): string;
|
|
2317
|
+
/** The Linked Tables' declarations, as a Sheet Document and a Workbook Document both write them; nothing for none. @internal */
|
|
2318
|
+
static writeTables(json: JsonWriter, tables: readonly SheetDocumentTable[]): void;
|
|
2319
|
+
/** What a Sheet records of its own: the formats on its columns and rows, its column widths and its cells. @internal */
|
|
2320
|
+
writeBody(json: JsonWriter): void;
|
|
2321
|
+
/** A cell as the document records it, as JSON: two cells record the same exactly when their texts are equal. @internal */
|
|
2322
|
+
static cellJson(cell: SheetDocumentCell): string;
|
|
2323
|
+
/**
|
|
2324
|
+
* Reads a document written by `toJson`, or by the C# engine. Throws a SheetDocumentError when the version is not
|
|
2325
|
+
* one this engine reads (`oldestReadableVersion` to `currentVersion`), or the document holds anything its version
|
|
2326
|
+
* does not define. Nothing is guessed.
|
|
2327
|
+
*/
|
|
2328
|
+
static fromJson(text: string): SheetDocument;
|
|
2329
|
+
/**
|
|
2330
|
+
* Reads one Sheet of a Workbook Document (ADR-0331): its name and what it records of its own, in the current
|
|
2331
|
+
* version, under the Workbook's culture. The version, the culture and the Linked Tables are the Workbook's, and are
|
|
2332
|
+
* refused here. @internal
|
|
2333
|
+
*/
|
|
2334
|
+
static readSheetOfWorkbook(element: JsonElement, culture: string): SheetDocument;
|
|
2335
|
+
/** The Linked Tables' declarations, as a Sheet Document and a Workbook Document both read them; none declared twice. @internal */
|
|
2336
|
+
static readTables(array: JsonElement, version: number): SheetDocumentTable[];
|
|
2337
|
+
/** The culture a document names: `''` is the invariant culture, as .NET names it. Throws a SheetDocumentError for one this engine does not know. @internal */
|
|
2338
|
+
static resolveCulture(name: string): Culture;
|
|
2339
|
+
}
|
|
2340
|
+
|
|
2341
|
+
/**
|
|
2342
|
+
* A Cell Format recorded on whole columns or whole rows, as a Sheet Document records it: one entry for a run of
|
|
2343
|
+
* adjacent columns (rows) recorded alike, never one per cell (ADR-0047, ADR-0071).
|
|
2344
|
+
*/
|
|
2345
|
+
export declare class SheetDocumentAxisFormat {
|
|
2346
|
+
/** The first column (row) of the run, from 0. */
|
|
2347
|
+
readonly first: number;
|
|
2348
|
+
/** The last column (row) of the run. */
|
|
2349
|
+
readonly last: number;
|
|
2350
|
+
/** The Number Format the run records; `undefined` for none. */
|
|
2351
|
+
readonly numberFormat: NumberFormat | undefined;
|
|
2352
|
+
/** The horizontal alignment the run records; `undefined` for none. */
|
|
2353
|
+
readonly alignment: HorizontalAlignment | undefined;
|
|
2354
|
+
/** The Font the run records; `undefined` for none. */
|
|
2355
|
+
readonly font: CellFont | undefined;
|
|
2356
|
+
/** The Fill the run records; `undefined` for none. */
|
|
2357
|
+
readonly fill: CellFill | undefined;
|
|
2358
|
+
/** The Borders the run records; `undefined` for none. */
|
|
2359
|
+
readonly borders: CellBorders | undefined;
|
|
2360
|
+
constructor(first: number, last: number, numberFormat: NumberFormat | undefined, alignment: HorizontalAlignment | undefined, font: CellFont | undefined, fill: CellFill | undefined, borders: CellBorders | undefined);
|
|
2361
|
+
/** The level each row (column) of the run records. @internal */
|
|
2362
|
+
get level(): AxisFormat;
|
|
2363
|
+
}
|
|
2364
|
+
|
|
2365
|
+
/** One cell of a Sheet Document: where it is, its Entry and its own Cell Format. Never its Value (ADR-0048). */
|
|
2366
|
+
export declare class SheetDocumentCell {
|
|
2367
|
+
/** Where the cell is. */
|
|
2368
|
+
readonly address: CellAddress;
|
|
2369
|
+
/** What the user put into it; `undefined` for a cell that holds only a Cell Format. */
|
|
2370
|
+
readonly entry: Entry | undefined;
|
|
2371
|
+
/** The Number Format the cell records itself; `undefined` when it takes its row's or column's (ADR-0047). */
|
|
2372
|
+
readonly numberFormat: NumberFormat | undefined;
|
|
2373
|
+
/** The horizontal alignment the cell records itself; `undefined` when it takes its row's or column's. */
|
|
2374
|
+
readonly alignment: HorizontalAlignment | undefined;
|
|
2375
|
+
/** The Font the cell records itself; `undefined` when it takes its row's or column's (ADR-0071). */
|
|
2376
|
+
readonly font: CellFont | undefined;
|
|
2377
|
+
/** The Fill the cell records itself; `undefined` when it takes its row's or column's (ADR-0071). */
|
|
2378
|
+
readonly fill: CellFill | undefined;
|
|
2379
|
+
/** The Borders the cell records itself; `undefined` for none (ADR-0071). */
|
|
2380
|
+
readonly borders: CellBorders | undefined;
|
|
2381
|
+
constructor(address: CellAddress, entry: Entry | undefined, numberFormat?: NumberFormat, alignment?: HorizontalAlignment, font?: CellFont, fill?: CellFill, borders?: CellBorders);
|
|
2382
|
+
}
|
|
2383
|
+
|
|
2384
|
+
/** A width recorded on columns, as a Sheet Document records it: one entry for a run of adjacent columns of one width and one kind (ADR-0046). */
|
|
2385
|
+
export declare class SheetDocumentColumnWidth {
|
|
2386
|
+
/** The first column of the run, from 0. */
|
|
2387
|
+
readonly first: number;
|
|
2388
|
+
/** The last column of the run. */
|
|
2389
|
+
readonly last: number;
|
|
2390
|
+
/** The width, in characters of the default font (Excel's unit, ADR-0047). */
|
|
2391
|
+
readonly width: number;
|
|
2392
|
+
/** What recorded the width. */
|
|
2393
|
+
readonly kind: SheetColumnWidthKind;
|
|
2394
|
+
constructor(first: number, last: number, width: number, kind?: SheetColumnWidthKind);
|
|
2395
|
+
/** Whether Excel's file marks the width custom: every recorded width is. */
|
|
2396
|
+
get isCustom(): boolean;
|
|
2397
|
+
}
|
|
2398
|
+
|
|
2399
|
+
/** A Sheet Document that cannot be read: an unknown version, or anything the version does not define (ADR-0048). */
|
|
2400
|
+
export declare class SheetDocumentError extends Error {
|
|
2401
|
+
/** The version the document declared, when that is why it was refused. */
|
|
2402
|
+
readonly documentVersion: number | undefined;
|
|
2403
|
+
constructor(message: string, options?: {
|
|
2404
|
+
cause?: unknown;
|
|
2405
|
+
documentVersion?: number;
|
|
2406
|
+
});
|
|
2407
|
+
}
|
|
2408
|
+
|
|
2409
|
+
/** The parts of a Sheet Document besides its culture, name, Linked Tables and cells. */
|
|
2410
|
+
export declare interface SheetDocumentLayout {
|
|
2411
|
+
/** The Cell Formats recorded on whole columns, in column order, adjacent columns recorded alike as one run (ADR-0047, ADR-0071). */
|
|
2412
|
+
readonly columns?: readonly SheetDocumentAxisFormat[];
|
|
2413
|
+
/** The Cell Formats recorded on whole rows, in row order, adjacent rows recorded alike as one run. */
|
|
2414
|
+
readonly rows?: readonly SheetDocumentAxisFormat[];
|
|
2415
|
+
/** The widths recorded on columns, in column order, adjacent columns of one width and one kind as one run (ADR-0046). */
|
|
2416
|
+
readonly columnWidths?: readonly SheetDocumentColumnWidth[];
|
|
2417
|
+
}
|
|
2418
|
+
|
|
2419
|
+
/** A Linked Table's declaration as a Sheet Document records it: its name, its column names and its key, never its rows (ADR-0049). */
|
|
2420
|
+
export declare class SheetDocumentTable {
|
|
2421
|
+
/** The key's columns: one, several for a key of several columns (version 9; ADR-0058), or none. */
|
|
2422
|
+
readonly keyColumns: readonly string[];
|
|
2423
|
+
/** The table's name, as declared. */
|
|
2424
|
+
readonly name: string;
|
|
2425
|
+
/** Its column names, in the declared order. */
|
|
2426
|
+
readonly columns: readonly string[];
|
|
2427
|
+
constructor(name: string, columns: readonly string[], keyColumns?: readonly string[]);
|
|
2428
|
+
/** The key column when the key is one column; `undefined` for none, and for a key of several columns. */
|
|
2429
|
+
get key(): string | undefined;
|
|
2430
|
+
}
|
|
2431
|
+
|
|
2432
|
+
/**
|
|
2433
|
+
* One user operation on a Sheet, described before it is done: an edit, a paste, a Cell Format, an insertion or
|
|
2434
|
+
* deletion, a fill, or an operation on the Workbook's Sheets. `Workbook.do` does it and returns the one step that
|
|
2435
|
+
* undoes it (ADR-0048): a paste over a thousand cells is one step.
|
|
2436
|
+
*/
|
|
2437
|
+
export declare abstract class SheetEdit {
|
|
2438
|
+
/** @internal */
|
|
2439
|
+
protected constructor();
|
|
2440
|
+
/** Text typed into one cell, read under the Sheet's culture (`Sheet.enter`). */
|
|
2441
|
+
static enter(address: CellAddress, typed: string): SheetEdit;
|
|
2442
|
+
/** Several typed texts as one operation, such as a paste from another program. */
|
|
2443
|
+
static enterMany(typed: Iterable<TypedCell>): SheetEdit;
|
|
2444
|
+
/** Entries set or cleared (`undefined`) as one operation. */
|
|
2445
|
+
static setEntries(entries: Iterable<EntryOfCell>): SheetEdit;
|
|
2446
|
+
/** A Number Format set on cells; `undefined` is General. */
|
|
2447
|
+
static setNumberFormatOf(addresses: Iterable<CellAddress>, format: NumberFormat | undefined): SheetEdit;
|
|
2448
|
+
/** A horizontal alignment set on cells. */
|
|
2449
|
+
static setAlignmentOf(addresses: Iterable<CellAddress>, alignment: HorizontalAlignment): SheetEdit;
|
|
2450
|
+
/**
|
|
2451
|
+
* A Number Format set on a range (`Sheet.setNumberFormat`); `undefined` is General. Whole columns and whole rows
|
|
2452
|
+
* are recorded as one entry each, and undoing the step puts back every level exactly (ADR-0047).
|
|
2453
|
+
*/
|
|
2454
|
+
static setNumberFormat(range: CellRange, format: NumberFormat | undefined): SheetEdit;
|
|
2455
|
+
/** A horizontal alignment set on a range, recorded as `setNumberFormat` records a Number Format. Throws a RangeError for one that is not an alignment. */
|
|
2456
|
+
static setAlignment(range: CellRange, alignment: HorizontalAlignment): SheetEdit;
|
|
2457
|
+
/**
|
|
2458
|
+
* The parts `change` names set on several ranges as one step (ADR-0046, ADR-0071), such as a selection of several
|
|
2459
|
+
* rectangles, whole columns and whole rows among them. The change's Borders are relative to each range, so each
|
|
2460
|
+
* range gets its own outline. Undoing the step puts back every level exactly. Throws when there is no range, or the
|
|
2461
|
+
* change sets nothing.
|
|
2462
|
+
*/
|
|
2463
|
+
static setCellFormat(ranges: Iterable<CellRange>, change: CellFormatChange): SheetEdit;
|
|
2464
|
+
/**
|
|
2465
|
+
* A width the user set on every column `columns` spans, in characters (`Sheet.setColumnWidth`): set by the user, so
|
|
2466
|
+
* an entry never widens them; `undefined` puts them back at the default width. Undoing the step puts back every
|
|
2467
|
+
* column's width, and its kind, exactly (ADR-0046). Throws a RangeError for a width not more than 0 and at most 255.
|
|
2468
|
+
*/
|
|
2469
|
+
static setColumnWidth(columns: CellRange, width: number | undefined): SheetEdit;
|
|
2470
|
+
/**
|
|
2471
|
+
* A width an entry widened every column `columns` spans to, in characters (`Sheet.setAutomaticColumnWidth`):
|
|
2472
|
+
* widened by entry, and widened again by a longer entry (ADR-0046, 2026-09-28; CW-028). Undoing the step puts back
|
|
2473
|
+
* every column's width, and its kind, exactly.
|
|
2474
|
+
*/
|
|
2475
|
+
static setAutomaticColumnWidth(columns: CellRange, width: number): SheetEdit;
|
|
2476
|
+
/** Rows inserted (`Sheet.insertRows`). */
|
|
2477
|
+
static insertRows(row: number, count?: number): SheetEdit;
|
|
2478
|
+
/** Rows deleted (`Sheet.deleteRows`). */
|
|
2479
|
+
static deleteRows(row: number, count?: number): SheetEdit;
|
|
2480
|
+
/** Columns inserted (`Sheet.insertColumns`). */
|
|
2481
|
+
static insertColumns(column: number, count?: number): SheetEdit;
|
|
2482
|
+
/** Columns deleted (`Sheet.deleteColumns`). */
|
|
2483
|
+
static deleteColumns(column: number, count?: number): SheetEdit;
|
|
2484
|
+
/**
|
|
2485
|
+
* A block copied inside ExSheet, pasted (ADR-0048, ADR-0071): Entries with their relative References shifted by the
|
|
2486
|
+
* distance pasted (a Reference shifted off the Sheet is `#REF!`, as in Excel), Cell Formats with them.
|
|
2487
|
+
*
|
|
2488
|
+
* - At a cell, its top-left cell lands there. A block that would run past the Sheet's edge is refused by name (ADR-0050).
|
|
2489
|
+
* - Over a range, it is repeated to fill it, as Excel repeats a paste over a selection that is a whole multiple of
|
|
2490
|
+
* the block's size.
|
|
2491
|
+
* - Over several ranges, it is pasted over each as one operation (ADR-0014, ADR-0180); a cell two ranges share is
|
|
2492
|
+
* written once, with what the later range gives it.
|
|
2493
|
+
*
|
|
2494
|
+
* Throws when there is no range, or a range is not a whole multiple of the block in both directions.
|
|
2495
|
+
*/
|
|
2496
|
+
static paste(block: SheetBlock, at: CellAddress | CellRange | Iterable<CellRange>): SheetEdit;
|
|
2497
|
+
/**
|
|
2498
|
+
* Text pasted from another program, each field taken as if the user had typed it into its cell under the Sheet's
|
|
2499
|
+
* culture: `=A1+1` becomes a Formula and `1,234` a number under `en-US` (ADR-0048). A field beginning with `=` that
|
|
2500
|
+
* cannot be read as a Formula is taken as text, as Excel takes a pasted `=1+`. `fields` is rectangular, rows of
|
|
2501
|
+
* columns, with the top-left field at `origin`; an empty field clears its cell. A block that would run past the
|
|
2502
|
+
* Sheet's edge is refused by name (ADR-0050). Throws when the rows are not all the same length, or there are none.
|
|
2503
|
+
*/
|
|
2504
|
+
static pasteText(fields: readonly (readonly string[])[], origin: CellAddress): SheetEdit;
|
|
2505
|
+
/**
|
|
2506
|
+
* Text pasted from another program, given field by field, each taken as `pasteText` takes it; with `entries`,
|
|
2507
|
+
* some cells carry their exact Value, set as they are, such as an invariant number with every digit its double
|
|
2508
|
+
* holds (ADR-0048, ADR-0050 item 10). The fields are read first, so a format typing gives a cell is given before
|
|
2509
|
+
* the Entries are set; a cell named in both takes its Entry. One operation: one step, and one change (ADR-0180).
|
|
2510
|
+
*/
|
|
2511
|
+
static pasteFields(fields: Iterable<TypedCell>, entries?: Iterable<EntryOfCell>): SheetEdit;
|
|
2512
|
+
/**
|
|
2513
|
+
* A Fill Intent resolved as Excel fills (ADR-0050, item 5): `target` extends `source` in `direction`, given as the
|
|
2514
|
+
* new cells alone or as the whole extended range. Formulas are copied with their References shifted, two or more
|
|
2515
|
+
* numbers continue as Excel's linear trend, a single date goes on by day, a single number in a line of a fill from
|
|
2516
|
+
* whole columns or whole rows goes on by one, and any other single number, text without a pattern, booleans, Error
|
|
2517
|
+
* Values and blanks are copied. Any other pattern is refused (`fillPatternNotSupported`), never filled with copies;
|
|
2518
|
+
* `Workbook.check` says so before anything is written.
|
|
2519
|
+
*/
|
|
2520
|
+
static fill(source: CellRange, target: CellRange, direction: FillDirection): SheetEdit;
|
|
2521
|
+
/**
|
|
2522
|
+
* Excel's fill keys, Ctrl+D and Ctrl+R (ADR-0035; ADR-0050, item 5, 2026-09-28): `target` extends `source` in
|
|
2523
|
+
* `direction` as a copy of it, repeated, and never as a series. Only a target that does not extend the source along
|
|
2524
|
+
* one axis is refused.
|
|
2525
|
+
*/
|
|
2526
|
+
static fillCopy(source: CellRange, target: CellRange, direction: FillDirection): SheetEdit;
|
|
2527
|
+
/**
|
|
2528
|
+
* Excel's Ctrl+Enter (ADR-0050, item 5, 2026-09-28): `typed`, read under the Sheet's culture as entered in
|
|
2529
|
+
* `enteredAt`, written into every cell of `targets` as one operation. A Formula is written as entered in
|
|
2530
|
+
* `enteredAt`, and into every other cell with its relative References shifted by that cell's offset from it, by the
|
|
2531
|
+
* rule `fillCopy` shifts them. Anything else is entered into every cell as typed. Overlapping ranges write their
|
|
2532
|
+
* shared cells once. Throws when there is no target, or `enteredAt` lies outside every target; doing it throws a
|
|
2533
|
+
* FormulaSyntaxError for a Formula that cannot be read, and nothing changes.
|
|
2534
|
+
*/
|
|
2535
|
+
static enterInto(targets: Iterable<CellRange>, enteredAt: CellAddress, typed: string): SheetEdit;
|
|
2536
|
+
/**
|
|
2537
|
+
* The Sheet renamed (ADR-0046, ADR-0331): every Reference on every Sheet qualified with the old name is rewritten to
|
|
2538
|
+
* the new one, as Excel rewrites them. A rename is a change, so `RAND` and `RANDBETWEEN` draw again (ADR-0180); a
|
|
2539
|
+
* rename to the name the Sheet already has changes nothing. A name another Sheet has, without regard to case, is
|
|
2540
|
+
* refused (`sheetNameTaken`). Throws a RangeError for a name a Sheet cannot have.
|
|
2541
|
+
*/
|
|
2542
|
+
static rename(name: string): SheetEdit;
|
|
2543
|
+
/**
|
|
2544
|
+
* A new, empty Sheet inserted beside the Sheet the edit is done on — after it, as Excel's `+` button adds one, or
|
|
2545
|
+
* before it, as Shift+F11 does — named `name`, or `Sheet` and the next number of the Workbook's count of the Sheets
|
|
2546
|
+
* it has made, as Excel numbers one (ADR-0331). Undoing it takes the Sheet out again, and gives its number back. The
|
|
2547
|
+
* step's Sheet is the new Sheet.
|
|
2548
|
+
*/
|
|
2549
|
+
static insertSheet(name?: string, before?: boolean): SheetEdit;
|
|
2550
|
+
/**
|
|
2551
|
+
* The Sheet deleted (ADR-0331): every Reference on another Sheet qualified with its name becomes `#REF!`. Undoing it
|
|
2552
|
+
* gives back the Sheet and those Formulas exactly. The Workbook's last Sheet is not deleted (`lastSheet`).
|
|
2553
|
+
*/
|
|
2554
|
+
static deleteSheet(): SheetEdit;
|
|
2555
|
+
/** The Sheet moved to `index` in the order of the Sheets after the move (ADR-0331). Throws a RangeError for a negative index. */
|
|
2556
|
+
static moveSheet(index: number): SheetEdit;
|
|
2557
|
+
/**
|
|
2558
|
+
* A copy of the Sheet — its Entries, Cell Formats and column widths — named as Excel names one, `Name (2)`, placed at
|
|
2559
|
+
* `index` in the order after the copy, or just after the Sheet (ADR-0331). A Reference in it qualified with the
|
|
2560
|
+
* Sheet's name names the copy. The step's Sheet is the copy.
|
|
2561
|
+
*/
|
|
2562
|
+
static copySheet(index?: number): SheetEdit;
|
|
2563
|
+
/** Whether the Sheet would refuse this operation as it stands, and why. Changes nothing. @internal */
|
|
2564
|
+
check(_sheet: Sheet): SheetRefusal | undefined;
|
|
2565
|
+
/** Does the operation on `sheet`, checked already, and answers the step that undoes it. @internal */
|
|
2566
|
+
abstract apply(sheet: Sheet): SheetStep;
|
|
2567
|
+
/** The ranges the operation changes on its Sheet: what an undo or a redo of it selects (ADR-0331 §3). None for an operation on the Sheets. @internal */
|
|
2568
|
+
get ranges(): readonly CellRange[];
|
|
2569
|
+
/** The smallest range holding every one of `cells`; none for no cells. @internal */
|
|
2570
|
+
static bounding(cells: Iterable<CellAddress>): CellRange[];
|
|
2571
|
+
}
|
|
2572
|
+
|
|
2573
|
+
/** A moment in the Workbook's zone: the date and the time of day `NOW` answers (ADR-0124). */
|
|
2574
|
+
export declare interface SheetMoment extends SheetDay {
|
|
2575
|
+
/** 0 to 23. */
|
|
2576
|
+
readonly hour: number;
|
|
2577
|
+
/** 0 to 59. */
|
|
2578
|
+
readonly minute: number;
|
|
2579
|
+
/** 0 to 59. */
|
|
2580
|
+
readonly second: number;
|
|
2581
|
+
/** 0 to 999. */
|
|
2582
|
+
readonly millisecond: number;
|
|
2583
|
+
}
|
|
2584
|
+
|
|
2585
|
+
/** An operation a Sheet refused, and why, with the refusal in words naming what caused it. Nothing was changed. */
|
|
2586
|
+
export declare class SheetRefusal {
|
|
2587
|
+
/** Why it was refused. */
|
|
2588
|
+
readonly reason: SheetRefusalReason;
|
|
2589
|
+
/** The refusal in words, naming what caused it. */
|
|
2590
|
+
readonly message: string;
|
|
2591
|
+
constructor(reason: SheetRefusalReason, message: string);
|
|
2592
|
+
/** Whether `other` is the same refusal, for the same reason and in the same words. */
|
|
2593
|
+
equals(other: SheetRefusal): boolean;
|
|
2594
|
+
}
|
|
2595
|
+
|
|
2596
|
+
/**
|
|
2597
|
+
* Why a Sheet refused an operation. A refusal changes nothing: the engine says an operation cannot be done rather
|
|
2598
|
+
* than do something close to it (ADR-0047, ADR-0050).
|
|
2599
|
+
*
|
|
2600
|
+
* - `entriesWouldLeaveSheet`: an insertion would push a cell holding an Entry off the Sheet's edge.
|
|
2601
|
+
* - `blockWouldLeaveSheet`: a block written at a place would run past the Sheet's edge (ADR-0050).
|
|
2602
|
+
* - `waitingForData`: a copy reaches a cell whose Value is `#GETTING_DATA` (ADR-0049).
|
|
2603
|
+
* - `fillPatternNotSupported`: a fill whose source is a pattern ExSheet does not continue (ADR-0050).
|
|
2604
|
+
* - `fillShapeNotSupported`: a fill whose target does not extend its source along one axis (ADR-0050).
|
|
2605
|
+
* - `editIsOpen`: a command that changes the Sheet, given while an edit is open (ADR-0048, ADR-0049).
|
|
2606
|
+
* - `sheetNameTaken`: a Sheet would be given a name another Sheet of the Workbook has, without regard to case (ADR-0331).
|
|
2607
|
+
* - `lastSheet`: the Workbook's last Sheet would be deleted (ADR-0331).
|
|
2608
|
+
* - `sheetNotNamed`: a command or an address that names no Sheet, given while the Workbook holds several (ADR-0331 §6).
|
|
2609
|
+
* - `selectionMoved`: a change made from the Focus cell's Cell Format away from the Sheet, set once the Selection, or the
|
|
2610
|
+
* Sheet shown, is no longer the one it was read from (ADR-0100).
|
|
2611
|
+
* - `focusFormatChanged`: such a change, set once the Focus cell's Cell Format is no longer the one it was made from
|
|
2612
|
+
* (ADR-0100).
|
|
2613
|
+
*/
|
|
2614
|
+
export declare type SheetRefusalReason = 'entriesWouldLeaveSheet' | 'blockWouldLeaveSheet' | 'waitingForData' | 'fillPatternNotSupported' | 'fillShapeNotSupported' | 'editIsOpen' | 'sheetNameTaken' | 'lastSheet' | 'sheetNotNamed' | 'selectionMoved' | 'focusFormatChanged';
|
|
2615
|
+
|
|
2616
|
+
/** Thrown when an operation the caller asked for is refused. Nothing was changed. */
|
|
2617
|
+
export declare class SheetRefusedError extends Error {
|
|
2618
|
+
/** The refusal. */
|
|
2619
|
+
readonly refusal: SheetRefusal;
|
|
2620
|
+
constructor(refusal: SheetRefusal);
|
|
2621
|
+
}
|
|
2622
|
+
|
|
2623
|
+
/** What a rename did, and the Formulas it rewrote on every Sheet, as they were, for undoing it. @internal */
|
|
2624
|
+
declare interface SheetRename {
|
|
2625
|
+
readonly change: SheetChange;
|
|
2626
|
+
readonly oldName: string;
|
|
2627
|
+
readonly rewritten: readonly RewrittenEntry[];
|
|
2628
|
+
}
|
|
2629
|
+
|
|
2630
|
+
/**
|
|
2631
|
+
* How many rows and columns the Sheets of a Workbook hold (ADR-0460): Excel's 1,048,576 × 16,384 unless a Consumer
|
|
2632
|
+
* gives fewer. It bounds where a cell may hold an Entry and what the user reaches, not the address space: a Reference
|
|
2633
|
+
* past it is still a Reference, to a cell that is empty and can hold nothing.
|
|
2634
|
+
*/
|
|
2635
|
+
export declare class SheetSize {
|
|
2636
|
+
/** Excel's full size, 1,048,576 rows by 16,384 columns (`A1` to `XFD1048576`): what a Sheet holds unless given another. */
|
|
2637
|
+
static readonly excel: SheetSize;
|
|
2638
|
+
/** How many rows, from 1 to 1,048,576. */
|
|
2639
|
+
readonly rows: number;
|
|
2640
|
+
/** How many columns, from 1 to 16,384. */
|
|
2641
|
+
readonly columns: number;
|
|
2642
|
+
/** A size of `rows` by `columns`; one of no rows or no columns, or larger than Excel's, is refused with a `RangeError`. */
|
|
2643
|
+
constructor(rows: number, columns: number);
|
|
2644
|
+
/** The last cell inside the size: `XFD1048576` for Excel's, `J10` for ten by ten. */
|
|
2645
|
+
get lastCell(): CellAddress;
|
|
2646
|
+
/** Whether `address` lies inside the size. */
|
|
2647
|
+
contains(address: CellAddress): boolean;
|
|
2648
|
+
/** Whether a block of `rows` × `columns` with its top-left cell at `origin` lies wholly inside the size. */
|
|
2649
|
+
holds(origin: CellAddress, rows: number, columns: number): boolean;
|
|
2650
|
+
/**
|
|
2651
|
+
* `range` as it stands inside the size, or `undefined` when it runs past it. Whole columns and whole rows are
|
|
2652
|
+
* Excel's lines, inside when their columns or rows are, and are answered as long as the size's: `B:B` of ten rows
|
|
2653
|
+
* is `B1:B10`.
|
|
2654
|
+
*/
|
|
2655
|
+
fit(range: CellRange): CellRange | undefined;
|
|
2656
|
+
/** Whether the two are the same size. */
|
|
2657
|
+
equals(other: SheetSize): boolean;
|
|
2658
|
+
}
|
|
2659
|
+
|
|
2660
|
+
/**
|
|
2661
|
+
* One operation a Sheet has done, as one step of ExSheet's one undo stack (ADR-0048): undoing it restores every
|
|
2662
|
+
* Entry, format and Reference it changed exactly, with one recalculation; redoing it does it again. Steps are
|
|
2663
|
+
* undone in the reverse of the order they were done, and redone in the order they were undone.
|
|
2664
|
+
*/
|
|
2665
|
+
export declare class SheetStep {
|
|
2666
|
+
#private;
|
|
2667
|
+
/** The Sheet the operation was done on. */
|
|
2668
|
+
readonly sheet: Sheet;
|
|
2669
|
+
/** What doing the operation changed. */
|
|
2670
|
+
readonly change: SheetChange;
|
|
2671
|
+
/** @internal */
|
|
2672
|
+
constructor(sheet: Sheet, change: SheetChange, undo: (sheet: Sheet) => SheetChange, redo: (sheet: Sheet) => SheetChange);
|
|
2673
|
+
/** Whether the step is currently undone. */
|
|
2674
|
+
get isUndone(): boolean;
|
|
2675
|
+
/** Undoes the operation, and says what that changed. Throws when the step is already undone. */
|
|
2676
|
+
undo(): SheetChange;
|
|
2677
|
+
/** Does the operation again after `undo`, and says what that changed. Throws when the step is not undone. */
|
|
2678
|
+
redo(): SheetChange;
|
|
2679
|
+
}
|
|
2680
|
+
|
|
2681
|
+
/** One insertion or deletion of whole rows or columns. */
|
|
2682
|
+
declare class StructuralEdit {
|
|
2683
|
+
#private;
|
|
2684
|
+
readonly axis: SheetAxis;
|
|
2685
|
+
readonly start: number;
|
|
2686
|
+
readonly count: number;
|
|
2687
|
+
readonly isInsert: boolean;
|
|
2688
|
+
constructor(axis: SheetAxis, start: number, count: number, isInsert: boolean);
|
|
2689
|
+
get size(): number;
|
|
2690
|
+
/** The edit that undoes this one. */
|
|
2691
|
+
get inverse(): StructuralEdit;
|
|
2692
|
+
equals(other: StructuralEdit): boolean;
|
|
2693
|
+
describe(): string;
|
|
2694
|
+
/** Throws a `RangeError` for a start or count outside the Sheet. */
|
|
2695
|
+
validate(): void;
|
|
2696
|
+
/** Where a cell goes: its new address, or `undefined` when it is deleted or pushed off the edge. */
|
|
2697
|
+
move(address: CellAddress): CellAddress | undefined;
|
|
2698
|
+
/**
|
|
2699
|
+
* A Reference rewritten as Excel rewrites it: an insertion at or before a range's first cell moves it, one
|
|
2700
|
+
* inside it grows it; a deletion shrinks it, moves it, or — when it takes every cell it named — makes it
|
|
2701
|
+
* `#REF!` (`undefined`). A Reference that spans the whole axis (`A:A` for rows) is untouched, as is one
|
|
2702
|
+
* qualified with another Sheet's name (ADR-0046); one qualified with the Sheet's own name is rewritten like
|
|
2703
|
+
* any other. An insertion that pushes the cells a Reference names off the edge does not stop the insertion,
|
|
2704
|
+
* as it does not in Excel (observed, verification/2026-09-27-windows-excel): a range pushed partly off is cut
|
|
2705
|
+
* at the edge (`A2:A1048576`, a row inserted at 1, is `A3:A1048576`), and a Reference pushed wholly off is
|
|
2706
|
+
* `#REF!`.
|
|
2707
|
+
*/
|
|
2708
|
+
map(reference: Reference, sheet: LocalReferences): Reference | undefined;
|
|
2709
|
+
/** Whether a Reference covers any place at or beyond the edit along its axis. */
|
|
2710
|
+
reaches(reference: Reference, sheet: LocalReferences): boolean;
|
|
2711
|
+
}
|
|
2712
|
+
|
|
2713
|
+
/** What a structural edit did, and what undoing it needs besides the inverse edit. @internal */
|
|
2714
|
+
declare interface StructuralOutcome {
|
|
2715
|
+
readonly change: SheetChange;
|
|
2716
|
+
readonly dropped: readonly AddressedState[];
|
|
2717
|
+
readonly rewritten: readonly {
|
|
2718
|
+
readonly address: CellAddress;
|
|
2719
|
+
readonly entry: Entry;
|
|
2720
|
+
}[];
|
|
2721
|
+
readonly rowsBefore: ReadonlyMap<number, AxisFormat>;
|
|
2722
|
+
readonly columnsBefore: ReadonlyMap<number, AxisFormat>;
|
|
2723
|
+
readonly widthsBefore: ReadonlyMap<number, SheetColumnWidth>;
|
|
2724
|
+
readonly rewrittenElsewhere: readonly RewrittenEntry[];
|
|
2725
|
+
}
|
|
2726
|
+
|
|
2727
|
+
/** A structured reference into a Linked Table, `Table[Column]` (ADR-0049). */
|
|
2728
|
+
declare class StructuredReferenceNode extends NodeBase {
|
|
2729
|
+
readonly kind = "structuredReference";
|
|
2730
|
+
readonly table: string;
|
|
2731
|
+
readonly column: string;
|
|
2732
|
+
constructor(table: string, column: string);
|
|
2733
|
+
structuredReferences(): Generator<StructuredReferenceNode>;
|
|
2734
|
+
}
|
|
2735
|
+
|
|
2736
|
+
/**
|
|
2737
|
+
* What Point writes for a pressed column of a Linked Table, through a Pointing Scope (ADR-0058): Excel's
|
|
2738
|
+
* structured reference, `Positions[PV]`, written as the engine writes one back — single brackets, with `'`
|
|
2739
|
+
* before each of `[ ] # ' @` in the column's name. Throws a RangeError when either name is empty.
|
|
2740
|
+
*/
|
|
2741
|
+
export declare function structuredReferenceText(table: string, column: string): string;
|
|
2742
|
+
|
|
2743
|
+
/** A Linked Table's state, which every Sheet of the Workbook reads (ADR-0331). @internal */
|
|
2744
|
+
declare class TableState {
|
|
2745
|
+
/** The current snapshot, column by column; `undefined` until the first arrives, and after one is refused. */
|
|
2746
|
+
data: readonly (readonly (Value | undefined)[])[] | undefined;
|
|
2747
|
+
/** For each column of `data`, whether it holds a refusal. */
|
|
2748
|
+
refusing: readonly boolean[];
|
|
2749
|
+
rowCount: number;
|
|
2750
|
+
readonly name: string;
|
|
2751
|
+
readonly columns: readonly string[];
|
|
2752
|
+
/** Each column's index, by its name read without regard to case. */
|
|
2753
|
+
readonly columnIndex: ReadonlyMap<string, number>;
|
|
2754
|
+
/** The key's columns, as `columns` spells them; empty for none. */
|
|
2755
|
+
readonly key: readonly string[];
|
|
2756
|
+
readonly order: number;
|
|
2757
|
+
constructor(name: string, columns: readonly string[], columnIndex: ReadonlyMap<string, number>, key: readonly string[], order: number);
|
|
2758
|
+
}
|
|
2759
|
+
|
|
2760
|
+
declare class TextNode extends NodeBase {
|
|
2761
|
+
readonly kind = "text";
|
|
2762
|
+
readonly text: string;
|
|
2763
|
+
constructor(text: string);
|
|
2764
|
+
}
|
|
2765
|
+
|
|
2766
|
+
/**
|
|
2767
|
+
* What a function makes of a 3D Reference given as one of its arguments (ADR-0331 §7), as Excel answered for
|
|
2768
|
+
* each function ExSheet declares: read as one Value (`#REF!`, or `#VALUE!` handed on); read as one range across
|
|
2769
|
+
* its span, Sheet by Sheet in tab order (`SUM` and its kin); handed on as it is (`IF`'s and `CHOOSE`'s values);
|
|
2770
|
+
* `#VALUE!` where the function reads it (`IFS`'s and `SWITCH`'s values); or `#VALUE!` before anything of the
|
|
2771
|
+
* call is read, where the function asks for a range of one Sheet.
|
|
2772
|
+
*/
|
|
2773
|
+
declare type ThreeDArgument = 'value' | 'range' | 'handOn' | 'valueError' | 'oneSheet';
|
|
2774
|
+
|
|
2775
|
+
/** A typed text for a cell. */
|
|
2776
|
+
export declare type TypedCell = readonly [CellAddress, string];
|
|
2777
|
+
|
|
2778
|
+
declare class UnaryNode extends NodeBase {
|
|
2779
|
+
#private;
|
|
2780
|
+
readonly kind = "unary";
|
|
2781
|
+
readonly operator: '+' | '-';
|
|
2782
|
+
readonly operand: Node_2;
|
|
2783
|
+
constructor(operator: '+' | '-', operand: Node_2);
|
|
2784
|
+
references(): Generator<Reference>;
|
|
2785
|
+
structuredReferences(): Generator<StructuredReferenceNode>;
|
|
2786
|
+
calls(): Generator<FunctionNode>;
|
|
2787
|
+
get depth(): number;
|
|
2788
|
+
}
|
|
2789
|
+
|
|
2790
|
+
/**
|
|
2791
|
+
* What a cell evaluates to: a number, text, a boolean or an Error Value (CONTEXT.md). A constant Entry is
|
|
2792
|
+
* its own Value; a Formula's Value is its result. Values are never recorded in a Sheet Document (ADR-0048).
|
|
2793
|
+
* A blank is no Value: where one may stand, the engine says `undefined`.
|
|
2794
|
+
*/
|
|
2795
|
+
export declare class Value {
|
|
2796
|
+
#private;
|
|
2797
|
+
private constructor();
|
|
2798
|
+
/** A number. NaN and the infinities are not numbers a cell can hold; Excel's answer to them is `#NUM!`. */
|
|
2799
|
+
static fromNumber(number: number): Value;
|
|
2800
|
+
/** Text, possibly empty. */
|
|
2801
|
+
static fromText(text: string): Value;
|
|
2802
|
+
/** `TRUE` or `FALSE`. */
|
|
2803
|
+
static fromBoolean(value: boolean): Value;
|
|
2804
|
+
/** An Error Value. */
|
|
2805
|
+
static fromError(error: ErrorValue): Value;
|
|
2806
|
+
/**
|
|
2807
|
+
* A refusal (ADR-0047; 2026-10-12, decided with the user: a refusal is never caught, anywhere): the Error
|
|
2808
|
+
* Value `#VALUE!` where ExSheet cannot answer as Excel. It is `#VALUE!` to everything outside the engine,
|
|
2809
|
+
* and the engine carries it as `#CIRC!` is carried. Internal to the engine.
|
|
2810
|
+
*/
|
|
2811
|
+
static readonly refusal: Value;
|
|
2812
|
+
/** A refusal shown as `#NAME?`: a call of a function Excel has and ExSheet does not declare, or a declared Linked Table's bare name. Internal. */
|
|
2813
|
+
static readonly refusedName: Value;
|
|
2814
|
+
/** Which of the four kinds this Value is. */
|
|
2815
|
+
get kind(): ValueKind;
|
|
2816
|
+
/**
|
|
2817
|
+
* Whether this Error Value is a Refused Formula's: `#VALUE!`, or `#NAME?` for a function Excel has and
|
|
2818
|
+
* ExSheet does not declare, which no Formula can catch, in its own cell or in any cell that reads it
|
|
2819
|
+
* (ADR-0047). It is equal to the Error Value it shows.
|
|
2820
|
+
*/
|
|
2821
|
+
get isRefused(): boolean;
|
|
2822
|
+
/** Whether this Value is an Error Value. */
|
|
2823
|
+
get isError(): boolean;
|
|
2824
|
+
/** The number; throws unless the kind is `number`. */
|
|
2825
|
+
get number(): number;
|
|
2826
|
+
/** The text; throws unless the kind is `text`. */
|
|
2827
|
+
get text(): string;
|
|
2828
|
+
/** The boolean; throws unless the kind is `boolean`. */
|
|
2829
|
+
get boolean(): boolean;
|
|
2830
|
+
/** The Error Value; throws unless the kind is `error`. */
|
|
2831
|
+
get error(): ErrorValue;
|
|
2832
|
+
/**
|
|
2833
|
+
* Exact equality: the same kind and the same number, text (ordinal, case-sensitive), boolean or Error
|
|
2834
|
+
* Value. This is "did the Value change", not Excel's `=`, which ignores case. A refusal equals the Error
|
|
2835
|
+
* Value it shows.
|
|
2836
|
+
*/
|
|
2837
|
+
equals(other: Value): boolean;
|
|
2838
|
+
/**
|
|
2839
|
+
* Whether a cell's Value did not change: equal and both refused or neither, or both absent. A `#VALUE!`
|
|
2840
|
+
* that turns from Excel's own into a refusal changes what every Formula reading the cell answers.
|
|
2841
|
+
*/
|
|
2842
|
+
static unchanged(before: Value | undefined, after: Value | undefined): boolean;
|
|
2843
|
+
/** Whether two Values that may be blank are equal: both blank, or equal (`Nullable.Equals`). */
|
|
2844
|
+
static same(a: Value | undefined, b: Value | undefined): boolean;
|
|
2845
|
+
/** A diagnostic form, culture-invariant: a number round-trips, text is as held. What a cell shows is the Sheet's display, not this. */
|
|
2846
|
+
toString(): string;
|
|
2847
|
+
}
|
|
2848
|
+
|
|
2849
|
+
/**
|
|
2850
|
+
* A rectangle of Values a Formula computes (ADR-0125): an operator applied to a range, a function built for
|
|
2851
|
+
* arrays, or a range read whole. Row by row; a blank is `undefined`.
|
|
2852
|
+
*/
|
|
2853
|
+
declare class ValueArray {
|
|
2854
|
+
#private;
|
|
2855
|
+
/**
|
|
2856
|
+
* The most Values one array holds: 2^24, sixteen whole columns. A larger array is not computed, as Excel
|
|
2857
|
+
* runs out of resources before it (ADR-0125: a cap belongs on what cannot be executed); whatever would
|
|
2858
|
+
* build one is `#NUM!`.
|
|
2859
|
+
*/
|
|
2860
|
+
static readonly mostCells: number;
|
|
2861
|
+
readonly rows: number;
|
|
2862
|
+
readonly columns: number;
|
|
2863
|
+
constructor(rows: number, columns: number);
|
|
2864
|
+
/** Whether the array is one Value, which is no array at all to whoever reads it. */
|
|
2865
|
+
get isSingle(): boolean;
|
|
2866
|
+
at(row: number, column: number): Value | undefined;
|
|
2867
|
+
set(row: number, column: number, value: Value | undefined): void;
|
|
2868
|
+
/** Every Value row by row, blanks included as `undefined`. */
|
|
2869
|
+
all(): readonly (Value | undefined)[];
|
|
2870
|
+
/** The Values row by row, blanks left out, as a range's are read. */
|
|
2871
|
+
nonBlank(): Generator<Value>;
|
|
2872
|
+
/**
|
|
2873
|
+
* The element at `row`, `column` as Excel's broadcasting reads it: a single row or column is repeated along
|
|
2874
|
+
* the other array, and past its size an array of more than one row or column is `#N/A`.
|
|
2875
|
+
*/
|
|
2876
|
+
broadcast(row: number, column: number): Value | undefined;
|
|
2877
|
+
static single(value: Value | undefined): ValueArray;
|
|
2878
|
+
}
|
|
2879
|
+
|
|
2880
|
+
/** The four kinds of Value, as in Excel (ADR-0047). A blank cell is not a fifth kind: it has no Value. */
|
|
2881
|
+
export declare type ValueKind = 'number' | 'text' | 'boolean' | 'error';
|
|
2882
|
+
|
|
2883
|
+
/**
|
|
2884
|
+
* The Sheets ExSheet holds, in order, under one culture, with one dependency graph across them (CONTEXT.md, ADR-0331).
|
|
2885
|
+
* A Formula on one Sheet reads another's cells by qualifying a Reference with its name (`=Sheet2!A1`), and a change on
|
|
2886
|
+
* any Sheet recalculates what depends on it on every Sheet, publishing the new Values only when that whole
|
|
2887
|
+
* recalculation has completed (ADR-0047). Linked Tables are declared on the Workbook, and read from any of its Sheets.
|
|
2888
|
+
* Changed and read by one caller at a time.
|
|
2889
|
+
*/
|
|
2890
|
+
export declare class Workbook {
|
|
2891
|
+
#private;
|
|
2892
|
+
/** The Workbook's declared culture, which every one of its Sheets reads and shows under (ADR-0048, ADR-0331). */
|
|
2893
|
+
readonly culture: Culture;
|
|
2894
|
+
/** The Linked Tables' state, which every Sheet of the Workbook reads, by name read without regard to case (ADR-0331). @internal */
|
|
2895
|
+
readonly tables: Map<string, TableState>;
|
|
2896
|
+
/**
|
|
2897
|
+
* Where the engine reads the current moment for `NOW`: the date and time of day in the Workbook's zone, or
|
|
2898
|
+
* `undefined` while it is not known, when `NOW` is `#GETTING_DATA` (ADR-0124). The engine reads no clock itself; it
|
|
2899
|
+
* calls this once at the start of each recalculation, so every `NOW` on every Sheet in one recalculation answers the
|
|
2900
|
+
* same moment. Unset, the default, leaves `NOW` waiting.
|
|
2901
|
+
*/
|
|
2902
|
+
nowSource: (() => SheetMoment | undefined) | undefined;
|
|
2903
|
+
/**
|
|
2904
|
+
* A Workbook of empty Sheets named `sheetNames`, in that order — one, `Sheet1`, when none are given — whose constants
|
|
2905
|
+
* are read and whose Values are shown under `culture` (ADR-0048). Throws a RangeError when no name is given, a name
|
|
2906
|
+
* is not one a Sheet can have (`Sheet.isValidName`), or two names are the same without regard to case. Every Sheet
|
|
2907
|
+
* holds `size`, Excel's unless given (ADR-0460).
|
|
2908
|
+
*/
|
|
2909
|
+
constructor(culture: Culture, sheetNames?: Iterable<string>, size?: SheetSize);
|
|
2910
|
+
/**
|
|
2911
|
+
* Opens a Workbook Document: a Workbook in the document's culture, with its Sheets in order, the Sheet it shows
|
|
2912
|
+
* shown, its Linked Tables declared and waiting for their first snapshot, and each Sheet's Entries, Cell Formats and
|
|
2913
|
+
* column widths, with every Value computed again (ADR-0048, ADR-0049, ADR-0331). A Sheet Document opens as a
|
|
2914
|
+
* Workbook of that one Sheet. The culture of the caller plays no part. Every Sheet holds `size`, Excel's unless given,
|
|
2915
|
+
* and a document with an Entry past it is refused with a `RangeError` naming the first such cell, never opened
|
|
2916
|
+
* without it (ADR-0460).
|
|
2917
|
+
*/
|
|
2918
|
+
static open(document: WorkbookDocument | SheetDocument, size?: SheetSize): Workbook;
|
|
2919
|
+
/** How many rows and columns every Sheet of the Workbook holds (ADR-0460): Excel's unless one was given. */
|
|
2920
|
+
get size(): SheetSize;
|
|
2921
|
+
/**
|
|
2922
|
+
* Gives every Sheet another size (ADR-0460). A size that would leave an Entry past it is refused with a `RangeError`
|
|
2923
|
+
* naming the first such cell, and the Workbook keeps the size it had. Every spilled array is laid out again against
|
|
2924
|
+
* the new edge: one that no longer fits shows `#SPILL!`, and one that now fits spills. It is not an operation a user
|
|
2925
|
+
* undoes.
|
|
2926
|
+
*/
|
|
2927
|
+
resize(size: SheetSize): WorkbookChange;
|
|
2928
|
+
/**
|
|
2929
|
+
* The Sheet named `sheet` as a Sheet Document: the Workbook's culture, the Sheet's name, the Linked Tables'
|
|
2930
|
+
* declarations, its Entries, Cell Formats and column widths — never its Values, nor a table's rows. A Reference to
|
|
2931
|
+
* another Sheet is kept as it is written, so opened on its own it reads `#REF!`. Throws a RangeError when no Sheet
|
|
2932
|
+
* is named so.
|
|
2933
|
+
*/
|
|
2934
|
+
toSheetDocument(sheet: string): SheetDocument;
|
|
2935
|
+
/**
|
|
2936
|
+
* The Workbook as a Workbook Document: its culture, the Sheet shown, its Linked Tables' declarations, and each Sheet
|
|
2937
|
+
* as a Sheet Document records one, in order — never a Value, nor a table's rows (ADR-0331).
|
|
2938
|
+
*/
|
|
2939
|
+
toDocument(): WorkbookDocument;
|
|
2940
|
+
/**
|
|
2941
|
+
* The Sheet shown: the one whose tab is selected (ADR-0331). Showing another Sheet changes nothing a step records.
|
|
2942
|
+
* Setting a Sheet that is not one of this Workbook's throws a RangeError.
|
|
2943
|
+
*/
|
|
2944
|
+
get shown(): Sheet;
|
|
2945
|
+
set shown(sheet: Sheet);
|
|
2946
|
+
/** The Sheets, in the order their tabs stand. Change one through `do`. */
|
|
2947
|
+
get sheets(): readonly Sheet[];
|
|
2948
|
+
/** The Sheet named `name`, without regard to case, as a Reference's qualifier names one; `undefined` when none is. */
|
|
2949
|
+
find(name: string): Sheet | undefined;
|
|
2950
|
+
/** The Linked Tables declared, in the order they were first declared (ADR-0049). */
|
|
2951
|
+
get linkedTables(): LinkedTable[];
|
|
2952
|
+
/**
|
|
2953
|
+
* The current snapshot of the Linked Table named `name`, without regard to case, column by column in the order the
|
|
2954
|
+
* columns are declared, each holding one Value per row (`undefined` for a blank); `undefined` while it waits. A later
|
|
2955
|
+
* snapshot replaces it whole. Throws when no table of that name is declared.
|
|
2956
|
+
*/
|
|
2957
|
+
linkedTableColumns(name: string): readonly (readonly (Value | undefined)[])[] | undefined;
|
|
2958
|
+
/**
|
|
2959
|
+
* Does `edit` on the Sheet named `sheet` as one operation, and returns the step that undoes it (ADR-0048, ADR-0331).
|
|
2960
|
+
* A refused or unreadable operation changes nothing and returns no step. Throws a RangeError when no Sheet is named
|
|
2961
|
+
* so, a SheetRefusedError when the Sheet refuses the operation (`check` says why), and a FormulaSyntaxError when a
|
|
2962
|
+
* typed Formula cannot be read.
|
|
2963
|
+
*/
|
|
2964
|
+
do(sheet: string, edit: SheetEdit): WorkbookStep;
|
|
2965
|
+
/**
|
|
2966
|
+
* Does several edits, each on the Sheet it names, as one operation, and returns the one step that undoes them all
|
|
2967
|
+
* (ADR-0048, ADR-0331 §3): a Replace All over the Workbook (ADR-0332 §5) is one step and one change (ADR-0180). The
|
|
2968
|
+
* edits are done in the order given and undone in the reverse. Every edit is checked before any is done, and one
|
|
2969
|
+
* that cannot be done leaves the Workbook as it was: the edits done before it are put back, and the count of changes
|
|
2970
|
+
* with them. A Sheet operation is done alone, with `do`.
|
|
2971
|
+
*
|
|
2972
|
+
* Each edit is recalculated across the Workbook as it is done, before the next: the operation is one recalculation
|
|
2973
|
+
* per edit, its change reporting them together once the last has completed.
|
|
2974
|
+
*/
|
|
2975
|
+
doAll(edits: readonly (readonly [string, SheetEdit])[]): WorkbookStep;
|
|
2976
|
+
/** Whether `do` would refuse `edit` on the Sheet named `sheet` as it stands, and why; `undefined` when it would not. */
|
|
2977
|
+
check(sheet: string, edit: SheetEdit): SheetRefusal | undefined;
|
|
2978
|
+
/**
|
|
2979
|
+
* Declares a Linked Table by name and columns (ADR-0049), before any of its rows arrive. Formulas that read it stop
|
|
2980
|
+
* being `#NAME?` and show `#GETTING_DATA` until the first snapshot is pushed, on every Sheet. The declaration is
|
|
2981
|
+
* recorded in the document; a table is never undeclared. Declaring it again with the same columns, in the same
|
|
2982
|
+
* order, with the same key, changes nothing; other columns or another key replace the declaration and drop the rows
|
|
2983
|
+
* held so far.
|
|
2984
|
+
*
|
|
2985
|
+
* `key` is the key column, or the key's columns for a table whose rows are told apart by several columns together
|
|
2986
|
+
* (ADR-0058), each one of `columns` named without regard to case; none declares no key. Throws a RangeError when the
|
|
2987
|
+
* name or the columns are not ones a structured reference can name, or a key column is not one of the columns, or is
|
|
2988
|
+
* named twice.
|
|
2989
|
+
*/
|
|
2990
|
+
declareLinkedTable(name: string, columns: readonly string[], key?: string | readonly string[]): WorkbookChange;
|
|
2991
|
+
/**
|
|
2992
|
+
* Replaces a Linked Table's data with a whole snapshot, in one step (ADR-0049): no recalculation sees part of one
|
|
2993
|
+
* snapshot and part of another, and only the Formulas that read the table — and what depends on them — recalculate.
|
|
2994
|
+
* A snapshot of a keyed table in which a key repeats is refused with a RepeatedKeyError, and the table waits again.
|
|
2995
|
+
* Throws when no table of that name is declared, and a RangeError when a row does not have one Value per column or
|
|
2996
|
+
* holds `#GETTING_DATA` or `#CIRC!`.
|
|
2997
|
+
*/
|
|
2998
|
+
pushLinkedTable(name: string, rows: Iterable<readonly (Value | undefined)[]>): WorkbookChange;
|
|
2999
|
+
/** Runs an operation on `sheet`, and reports what it changed there with what its recalculation changed on every other Sheet. @internal */
|
|
3000
|
+
collectOn(sheet: Sheet, operation: () => SheetChange): WorkbookChange;
|
|
3001
|
+
/**
|
|
3002
|
+
* Runs an operation, and reports what it changed on the Sheet it names together with what its recalculation changed
|
|
3003
|
+
* on every other Sheet, and whether it changed which Sheets the Workbook holds. @internal
|
|
3004
|
+
*/
|
|
3005
|
+
collecting(operation: () => {
|
|
3006
|
+
sheet: Sheet;
|
|
3007
|
+
change: SheetChange;
|
|
3008
|
+
}): WorkbookChange;
|
|
3009
|
+
/** Records what a recalculation changed on `sheet`, which the operation under way did not start on. @internal */
|
|
3010
|
+
collect(sheet: Sheet, change: SheetChange): void;
|
|
3011
|
+
/**
|
|
3012
|
+
* The Sheet Day: the calendar day `TODAY()` answers on every Sheet, or `undefined` while it is not known, when every
|
|
3013
|
+
* Formula that calls `TODAY` is `#GETTING_DATA` (ADR-0121). The engine never reads a clock; whoever runs it says
|
|
3014
|
+
* which day it is. It is not part of a document.
|
|
3015
|
+
*/
|
|
3016
|
+
get today(): SheetDay | undefined;
|
|
3017
|
+
/**
|
|
3018
|
+
* The moment `NOW` answers on every Sheet: the one the last recalculation read from `nowSource`, or `undefined`
|
|
3019
|
+
* while none was read (ADR-0124). A copy of the Workbook made in the other engine is given it as its own moment,
|
|
3020
|
+
* so that its `NOW` answers what this one shows.
|
|
3021
|
+
*/
|
|
3022
|
+
get moment(): SheetMoment | undefined;
|
|
3023
|
+
/** Whether any Formula on any Sheet calls a volatile function, so that moving the clock on can change a Value. */
|
|
3024
|
+
get hasVolatileFormulas(): boolean;
|
|
3025
|
+
/**
|
|
3026
|
+
* Sets the Sheet Day, and recalculates only the Formulas that call `TODAY`, on every Sheet, and what reads them, in
|
|
3027
|
+
* one recalculation. Setting the day the Workbook already has changes nothing. It is not an operation a user undoes.
|
|
3028
|
+
* Throws a RangeError for a day that is not a calendar day from 1 January 1900, where Excel's dates begin (ADR-0047).
|
|
3029
|
+
*/
|
|
3030
|
+
setToday(today: SheetDay | undefined): WorkbookChange;
|
|
3031
|
+
/**
|
|
3032
|
+
* Recalculates the Formulas that call a volatile function, on every Sheet, and what reads them, reading the moment
|
|
3033
|
+
* again: what ExSheet does as the minute turns (ADR-0124). It is not an operation a user undoes.
|
|
3034
|
+
*/
|
|
3035
|
+
recalculateVolatile(): WorkbookChange;
|
|
3036
|
+
/**
|
|
3037
|
+
* The seed every draw of `RAND` and `RANDBETWEEN` on every Sheet is made from, with the Sheet's name, the cell, the
|
|
3038
|
+
* call's place in its Formula and `changes` (ADR-0180); `undefined` while it is not set, when every Formula that
|
|
3039
|
+
* calls either is `#GETTING_DATA`. The engine never chooses a random number of its own. It is not part of a document.
|
|
3040
|
+
*/
|
|
3041
|
+
get seed(): bigint | undefined;
|
|
3042
|
+
/**
|
|
3043
|
+
* How many changes the Workbook has had since it was made or opened (ADR-0180): each draws again, on every Sheet. An
|
|
3044
|
+
* edit of an Entry, an insertion or a deletion, a Sheet added, deleted, renamed, moved or copied, the undo or redo of
|
|
3045
|
+
* one of those, a Linked Table's snapshot, and a declaration that declares or replaces one, each count once.
|
|
3046
|
+
*/
|
|
3047
|
+
get changes(): number;
|
|
3048
|
+
/**
|
|
3049
|
+
* Sets the seed — an unsigned 64-bit integer, or `undefined` to make the draws wait again — and with `changes` the
|
|
3050
|
+
* count of changes too, and recalculates only the Formulas that draw, on every Sheet, and what reads them. The same
|
|
3051
|
+
* Entries, seed and count give the same draws (SH-17). Setting what the Workbook already has changes nothing. It is
|
|
3052
|
+
* not a change, and not an operation a user undoes. Throws a RangeError for a seed outside 0 to 2^64 - 1 or a count
|
|
3053
|
+
* below 0.
|
|
3054
|
+
*/
|
|
3055
|
+
setSeed(seed: bigint | undefined, changes?: number): WorkbookChange;
|
|
3056
|
+
/** Does `operation` as one operation: whatever steps it takes, on whichever Sheets, it counts as one change at most. @internal */
|
|
3057
|
+
asOneChange<T>(operation: () => T): T;
|
|
3058
|
+
/** Counts a change (ADR-0180), before the recalculation it brings draws: once for the operation under way, or once on its own. @internal */
|
|
3059
|
+
countChange(): void;
|
|
3060
|
+
/** Opening is no change: the count starts from 0 (ADR-0180). @internal */
|
|
3061
|
+
forgetChanges(): void;
|
|
3062
|
+
/** Where `sheet` stands in the order; -1 for a Sheet the Workbook does not hold. @internal */
|
|
3063
|
+
indexOf(sheet: Sheet): number;
|
|
3064
|
+
/**
|
|
3065
|
+
* The Sheets a 3D Reference from `first` to `last` spans (ADR-0331 §7): those from one to the other in tab order,
|
|
3066
|
+
* both included, whichever stands first; the names are read without regard to case. `undefined` when no Sheet has
|
|
3067
|
+
* one of the names. @internal
|
|
3068
|
+
*/
|
|
3069
|
+
span(first: string, last: string): Sheet[] | undefined;
|
|
3070
|
+
/**
|
|
3071
|
+
* Renames `sheet`: every Reference on every Sheet qualified with its old name is rewritten to the new one, as Excel
|
|
3072
|
+
* rewrites them (ADR-0046, ADR-0331). A rename to the name the Sheet already has changes nothing. Throws a
|
|
3073
|
+
* SheetRefusedError when another Sheet of the Workbook has the name, without regard to case. @internal
|
|
3074
|
+
*/
|
|
3075
|
+
renameSheet(sheet: Sheet, name: string): SheetRename;
|
|
3076
|
+
/** Undoes a rename: the old name back, and the Formulas it rewrote exactly as they were. @internal */
|
|
3077
|
+
undoRename(sheet: Sheet, rename: SheetRename): SheetChange;
|
|
3078
|
+
/** Why `name` cannot be given to `sheet`: another Sheet has it, without regard to case; `undefined` when none does. @internal */
|
|
3079
|
+
nameTaken(name: string, sheet: Sheet | undefined): SheetRefusal | undefined;
|
|
3080
|
+
/**
|
|
3081
|
+
* The name a new Sheet takes, as Excel names one (exsheet-workbook ticket 12, answer 13): `Sheet` and the next number
|
|
3082
|
+
* of the Workbook's count of the Sheets it has made, passing over a name a Sheet has. @internal
|
|
3083
|
+
*/
|
|
3084
|
+
nextSheetName(): string;
|
|
3085
|
+
/** The number `nextSheetName` gives the next new Sheet. @internal */
|
|
3086
|
+
nextSheetNumber(): number;
|
|
3087
|
+
/** `Sheet` and `number`: the name a new Sheet numbered so takes. @internal */
|
|
3088
|
+
sheetName(number: number): string;
|
|
3089
|
+
/** A Workbook just opened from a document: it has made no Sheet yet, as Excel's opened workbook has not. @internal */
|
|
3090
|
+
opened(): void;
|
|
3091
|
+
/**
|
|
3092
|
+
* Counts a new Sheet as made, as Excel counts it: one numbered by the count takes the count to its number, past the
|
|
3093
|
+
* names it passed over; any other counts one. The count before is returned, for `uncountSheetMade`. @internal
|
|
3094
|
+
*/
|
|
3095
|
+
countSheetMade(numbered: number | undefined): number;
|
|
3096
|
+
/** Puts back the count of Sheets made as it stood before an insertion or a copy, when the step is undone. @internal */
|
|
3097
|
+
uncountSheetMade(before: number): void;
|
|
3098
|
+
/** The name a copy of the Sheet named `name` takes, as Excel names one: `Name (2)`, or the next number free, the name cut to fit 31 characters. @internal */
|
|
3099
|
+
copyName(name: string): string;
|
|
3100
|
+
/** Inserts a new, empty Sheet at `index`. @internal */
|
|
3101
|
+
insertSheet(index: number, name: string): {
|
|
3102
|
+
sheet: Sheet;
|
|
3103
|
+
change: SheetChange;
|
|
3104
|
+
};
|
|
3105
|
+
/** Puts back a Sheet taken out, at `index`, with what it held. @internal */
|
|
3106
|
+
putBack(sheet: Sheet, index: number, rewritten: readonly RewrittenEntry[], shown: boolean): SheetChange;
|
|
3107
|
+
/**
|
|
3108
|
+
* Takes `sheet` out of the Workbook. Deleted, every Reference on another Sheet qualified with its name becomes
|
|
3109
|
+
* `#REF!` (ADR-0331), and a 3D Reference it ends hands that end to the Sheet next to it inward; taken out to undo its
|
|
3110
|
+
* insertion or copy, nothing is rewritten. The Sheet shown, if it was this one, becomes the one that takes its place.
|
|
3111
|
+
* @internal
|
|
3112
|
+
*/
|
|
3113
|
+
takeOut(sheet: Sheet, deleting: boolean, rewritten: RewrittenEntry[]): SheetChange;
|
|
3114
|
+
/**
|
|
3115
|
+
* Moves `sheet` to `index` in the order. A 3D Reference whose end it is, moved past the other end, hands that end to
|
|
3116
|
+
* the Sheet next to it inward; each Formula so rewritten is added to `rewritten` as it was, for undoing the move.
|
|
3117
|
+
* @internal
|
|
3118
|
+
*/
|
|
3119
|
+
move(sheet: Sheet, index: number, rewritten: RewrittenEntry[]): SheetChange;
|
|
3120
|
+
/** Undoes a move: `sheet` back at `index`, and the Formulas it rewrote exactly as they were. @internal */
|
|
3121
|
+
moveBack(sheet: Sheet, index: number, rewritten: readonly RewrittenEntry[]): SheetChange;
|
|
3122
|
+
/**
|
|
3123
|
+
* A copy of `source` named `name` at `index`: its Entries, Cell Formats and column widths. A Reference in it
|
|
3124
|
+
* qualified with the source's name names the copy, as Excel's copy does (ADR-0331); a 3D Reference the source ends is
|
|
3125
|
+
* `#REF!` in the copy, and any other is copied as it is (ADR-0331 §7). @internal
|
|
3126
|
+
*/
|
|
3127
|
+
copy(source: Sheet, index: number, name: string): {
|
|
3128
|
+
sheet: Sheet;
|
|
3129
|
+
change: SheetChange;
|
|
3130
|
+
};
|
|
3131
|
+
/** Puts back a copy, or an inserted Sheet, taken out by an undo. @internal */
|
|
3132
|
+
reinsert(sheet: Sheet, index: number): SheetChange;
|
|
3133
|
+
/**
|
|
3134
|
+
* A 3D Reference as a Formula is entered with it (ADR-0331 §7): its ends in tab order, each written in its Sheet's
|
|
3135
|
+
* own name, and a span of one Sheet written as a Reference to that Sheet. One naming a Sheet the Workbook lacks is
|
|
3136
|
+
* left as typed: it is `#NAME?`. @internal
|
|
3137
|
+
*/
|
|
3138
|
+
inTabOrder(reference: Reference): Reference;
|
|
3139
|
+
/** An Entry with every 3D Reference in it written as `inTabOrder` writes one; the same instance when it holds none, or nothing changes. @internal */
|
|
3140
|
+
entryInTabOrder(entry: Entry): Entry;
|
|
3141
|
+
/** Whether `reference` is a 3D Reference whose span holds `sheet`, as the Workbook stands. @internal */
|
|
3142
|
+
spans(reference: Reference, sheet: Sheet): boolean;
|
|
3143
|
+
}
|
|
3144
|
+
|
|
3145
|
+
/**
|
|
3146
|
+
* What one change to a Workbook did, Sheet by Sheet, reported after its recalculation has completed: every Value it
|
|
3147
|
+
* names is already published, and all of them come from that one recalculation (ADR-0047, ADR-0331) — or, for an
|
|
3148
|
+
* operation of several edits, from the last of the recalculations its edits were done with.
|
|
3149
|
+
*/
|
|
3150
|
+
export declare class WorkbookChange {
|
|
3151
|
+
#private;
|
|
3152
|
+
/** @internal */
|
|
3153
|
+
constructor(changes: readonly {
|
|
3154
|
+
readonly sheet: Sheet;
|
|
3155
|
+
readonly change: SheetChange;
|
|
3156
|
+
}[], changesSheets: boolean);
|
|
3157
|
+
/** Whether the change added, deleted, renamed, moved or copied a Sheet, so that the Sheets and their tabs may differ (ADR-0331). */
|
|
3158
|
+
readonly changesSheets: boolean;
|
|
3159
|
+
/** The Sheets the change reached, in the Workbook's order: the one it was made on, and every other whose Values or formats it changed. */
|
|
3160
|
+
get sheets(): Sheet[];
|
|
3161
|
+
/** What the change did on `sheet`; a change that changed nothing for a Sheet it did not reach. */
|
|
3162
|
+
for(sheet: Sheet): SheetChange;
|
|
3163
|
+
}
|
|
3164
|
+
|
|
3165
|
+
/**
|
|
3166
|
+
* The serialisable form of a Workbook (CONTEXT.md, ADR-0331): its Sheets in order, the Sheet shown, its culture and its
|
|
3167
|
+
* Linked Tables' declarations, and for each Sheet what a Sheet Document records of it — never a Value: opening one
|
|
3168
|
+
* computes every Value again. The Consumer persists it; ExSheet never does.
|
|
3169
|
+
*
|
|
3170
|
+
* The document is a format with a version, beside the Sheet Document's. A reader meeting a version it does not know
|
|
3171
|
+
* refuses the document rather than guess at it, and so does a reader meeting anything it does not understand
|
|
3172
|
+
* (ADR-0048). This engine writes version 1, whose Sheets are recorded as a Sheet Document of the current version
|
|
3173
|
+
* records a Sheet. `fromJson` also reads a Sheet Document of every version `SheetDocument.fromJson` reads, as a
|
|
3174
|
+
* Workbook of that one Sheet.
|
|
3175
|
+
*/
|
|
3176
|
+
export declare class WorkbookDocument {
|
|
3177
|
+
/** The version this engine writes. */
|
|
3178
|
+
static readonly currentVersion = 1;
|
|
3179
|
+
/** The oldest version this engine reads. */
|
|
3180
|
+
static readonly oldestReadableVersion = 1;
|
|
3181
|
+
/** The name of the Workbook's declared culture, such as `en-US`; empty for the invariant culture, as .NET names it. */
|
|
3182
|
+
readonly culture: string;
|
|
3183
|
+
/** The name of the Sheet shown, one of `sheets`. */
|
|
3184
|
+
readonly shown: string;
|
|
3185
|
+
/** The Linked Tables declared on the Workbook, in the order they were declared: names, columns and keys only (ADR-0049). */
|
|
3186
|
+
readonly linkedTables: readonly SheetDocumentTable[];
|
|
3187
|
+
/** The Sheets, in the order their tabs stand, each under the Workbook's culture and declaring no Linked Table of its own. */
|
|
3188
|
+
readonly sheets: readonly SheetDocument[];
|
|
3189
|
+
/** @internal */
|
|
3190
|
+
constructor(culture: string, shown: string, linkedTables: readonly SheetDocumentTable[], sheets: readonly SheetDocument[]);
|
|
3191
|
+
/**
|
|
3192
|
+
* A Workbook Document built from its Sheets, as a reader of another format builds one (ADR-0330 §3): `sheets` in the
|
|
3193
|
+
* order their tabs stand, the one named `shown` shown, under `culture`, declaring no Linked Table. Throws a
|
|
3194
|
+
* RangeError when there is no Sheet, two share a name, a Sheet records another culture or declares a Linked Table,
|
|
3195
|
+
* or no Sheet is named `shown`. Nothing is guessed.
|
|
3196
|
+
*/
|
|
3197
|
+
static of(culture: Culture, shown: string, sheets: Iterable<SheetDocument>): WorkbookDocument;
|
|
3198
|
+
/** The format version the document is written in: `currentVersion`, whatever it was read from. */
|
|
3199
|
+
get version(): number;
|
|
3200
|
+
/** Writes the document as JSON, as the C# engine writes it. */
|
|
3201
|
+
toJson(): string;
|
|
3202
|
+
/**
|
|
3203
|
+
* Reads a document written by `toJson`, or by the C# engine, or a Sheet Document of any version
|
|
3204
|
+
* `SheetDocument.fromJson` reads, as a Workbook of that one Sheet, shown, with its Linked Tables declared on the
|
|
3205
|
+
* Workbook (ADR-0331). Throws a SheetDocumentError when the version is not one this engine reads, the document holds
|
|
3206
|
+
* anything its version does not define, it holds no Sheet or two of one name, or the Sheet it shows is not one of
|
|
3207
|
+
* them. Nothing is guessed.
|
|
3208
|
+
*/
|
|
3209
|
+
static fromJson(text: string): WorkbookDocument;
|
|
3210
|
+
}
|
|
3211
|
+
|
|
3212
|
+
/**
|
|
3213
|
+
* One operation a Workbook has done on one of its Sheets, or on several (`doAll`), as one step of ExSheet's one undo
|
|
3214
|
+
* stack (ADR-0048, ADR-0331): undoing it restores what it changed exactly; redoing it does it again.
|
|
3215
|
+
*/
|
|
3216
|
+
export declare class WorkbookStep {
|
|
3217
|
+
#private;
|
|
3218
|
+
/** The ranges the operation changed on `sheet`: what an undo or a redo of it selects, as Excel's do (ADR-0331 §3). None for an operation on the Sheets. */
|
|
3219
|
+
readonly ranges: readonly CellRange[];
|
|
3220
|
+
/** The Sheet the operation was done on: for a Sheet added or copied, the new Sheet. */
|
|
3221
|
+
readonly sheet: Sheet;
|
|
3222
|
+
/** What doing the operation changed. */
|
|
3223
|
+
readonly change: WorkbookChange;
|
|
3224
|
+
/** @internal */
|
|
3225
|
+
constructor(sheet: Sheet, change: WorkbookChange, undo: () => WorkbookChange, redo: () => WorkbookChange, ranges: readonly CellRange[]);
|
|
3226
|
+
/** Whether the step is currently undone. */
|
|
3227
|
+
get isUndone(): boolean;
|
|
3228
|
+
/** Undoes the operation, and says what that changed. Throws when the step is already undone. */
|
|
3229
|
+
undo(): WorkbookChange;
|
|
3230
|
+
/** Does the operation again after `undo`, and says what that changed. Throws when the step is not undone. */
|
|
3231
|
+
redo(): WorkbookChange;
|
|
3232
|
+
}
|
|
3233
|
+
|
|
3234
|
+
/** A Cell Format as JSON: its Number Format's code, its alignment, its whole Font, its Fill and its four Borders. */
|
|
3235
|
+
export declare function writeCellFormat(format: CellFormat): string;
|
|
3236
|
+
|
|
3237
|
+
/**
|
|
3238
|
+
* A Linked Table's snapshot as JSON, rows of Values, a blank as `null` and a refusal as one, as `readLinkedRows` and
|
|
3239
|
+
* .NET's `SheetWire.ReadRows` read it.
|
|
3240
|
+
*/
|
|
3241
|
+
export declare function writeLinkedRows(rows: Iterable<readonly (Value | undefined)[]>): string;
|
|
3242
|
+
|
|
3243
|
+
/**
|
|
3244
|
+
* A refused snapshot as JSON (ADR-0049): the table, its key's columns, the key as its first and its second row hold
|
|
3245
|
+
* it, the two rows, and what the table's going back to waiting changed, so that .NET raises the refusal as the C#
|
|
3246
|
+
* Sheet raises it.
|
|
3247
|
+
*/
|
|
3248
|
+
export declare function writeRepeatedKey(error: RepeatedKeyError): string;
|
|
3249
|
+
|
|
3250
|
+
export { }
|