@lexaxai/spreadsheet-engine 0.0.0-stage → 0.1.0-dryrun.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/index.d.ts +2282 -0
- package/index.js +865 -0
- package/lexax.darwin-arm64.node +0 -0
- package/package.json +24 -4
- package/types/calc.d.ts +260 -0
- package/types/chart.d.ts +479 -0
- package/types/chart_ex.d.ts +379 -0
- package/types/chart_format.d.ts +440 -0
- package/types/chart_series.d.ts +336 -0
- package/types/drawings.d.ts +383 -0
- package/types/files.d.ts +367 -0
- package/types/formats.d.ts +380 -0
- package/types/page.d.ts +352 -0
- package/types/render.d.ts +137 -0
- package/types/sheet.d.ts +432 -0
- package/types/styles.d.ts +383 -0
- package/types/tables.d.ts +420 -0
- package/types/validation.d.ts +151 -0
- package/types/values.d.ts +280 -0
- package/README.md +0 -3
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lexaxai/spreadsheet-engine",
|
|
3
|
-
"version": "0.0.0
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0-dryrun.0",
|
|
4
|
+
"description": "Read, edit, calculate, render and write Excel workbooks: the Lexax engine for Node.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"main": "index.js",
|
|
7
|
+
"types": "index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"index.js",
|
|
10
|
+
"index.d.ts",
|
|
11
|
+
"types",
|
|
12
|
+
"lexax.darwin-arm64.node"
|
|
13
|
+
],
|
|
14
|
+
"engines": {
|
|
15
|
+
"node": ">=22"
|
|
16
|
+
},
|
|
17
|
+
"os": [
|
|
18
|
+
"darwin"
|
|
19
|
+
],
|
|
20
|
+
"cpu": [
|
|
21
|
+
"arm64"
|
|
22
|
+
],
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"access": "public"
|
|
25
|
+
}
|
|
26
|
+
}
|
package/types/calc.d.ts
ADDED
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
// Calculation: a workbook's formulas worked out and the report of it, an
|
|
2
|
+
// expression worked out, the check against Excel's saved results, Goal
|
|
3
|
+
// Seek and a sheet's scenarios.
|
|
4
|
+
|
|
5
|
+
import type { CellErrorValue, CellValue } from './values';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The options of a calculation (`Workbook.calculate`, a save's `calculate`, Goal Seek, a scenario shown):
|
|
9
|
+
* the moment NOW and TODAY give, what RAND draws, and whether cycles iterate.
|
|
10
|
+
*/
|
|
11
|
+
export interface CalculateOptions {
|
|
12
|
+
/** The moment NOW and TODAY give; the system's clock when left out. */
|
|
13
|
+
now?: Date;
|
|
14
|
+
/** The number every RAND gives, in [0, 1); a sequence no other run draws when left out. */
|
|
15
|
+
random?: number;
|
|
16
|
+
/** The start of a sequence RAND draws, the same sequence for the same seed, where `random` is not given. */
|
|
17
|
+
seed?: number;
|
|
18
|
+
/** Whether cycles are worked out round and round, though the workbook does not ask for it. */
|
|
19
|
+
iterate?: boolean;
|
|
20
|
+
/** Whether only what the edited cells reach is worked out, every other formula keeping its result. */
|
|
21
|
+
incremental?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* The cells edited, each as `[sheet, address]`, for an incremental calculation; the cells set since the
|
|
24
|
+
* last calculation when left out.
|
|
25
|
+
*/
|
|
26
|
+
edited?: [string, string][];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* A formula in a report, by its sheet and address.
|
|
31
|
+
*/
|
|
32
|
+
export type CalculatedCell = [string, string];
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The report of a calculation: the formulas it worked out, those whose results it kept, and those it
|
|
36
|
+
* could not work out.
|
|
37
|
+
*/
|
|
38
|
+
export interface CalculationReport {
|
|
39
|
+
/** How many formulas were worked out. */
|
|
40
|
+
calculated: number;
|
|
41
|
+
/** Each formula whose result changed, as `[sheet, address]`. */
|
|
42
|
+
changed: CalculatedCell[];
|
|
43
|
+
/** Each changed formula's result before, as its cell kept it, in the order of `changed`. */
|
|
44
|
+
previous: CellValue[];
|
|
45
|
+
/** Each formula the engine cannot work out, its result kept, with the reason. */
|
|
46
|
+
unsupported: {sheet: string; address: string; reason: string}[];
|
|
47
|
+
/** Each formula in a cycle, its result kept unless iteration is on. */
|
|
48
|
+
circular: CalculatedCell[];
|
|
49
|
+
/** Each formula reading a cycle's result, worked out from the result the cycle kept. */
|
|
50
|
+
behindCycles: CalculatedCell[];
|
|
51
|
+
/** Each formula whose result was kept. */
|
|
52
|
+
kept: CalculatedCell[];
|
|
53
|
+
/** Each formula worked out to an error (a data table's block apart), in the order of the sheets. */
|
|
54
|
+
errors: {sheet: string; address: string; error: string}[];
|
|
55
|
+
/** Each data table worked out: its block, its input cells, how many results and how many are errors. */
|
|
56
|
+
dataTables: {sheet: string; ref: string; rowInput?: string; columnInput?: string; cells: number; errors: number}[];
|
|
57
|
+
/** Each result still stale after an edit: one kept, and each formula reading one. */
|
|
58
|
+
stale: CalculatedCell[];
|
|
59
|
+
/** An incremental calculation's count: the formulas worked out and those that kept their results. */
|
|
60
|
+
incremental?: {worked: number; kept: number};
|
|
61
|
+
/** Where an incremental calculation became a whole one, a dynamic array spilling over a new range. */
|
|
62
|
+
whole?: true;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Where `Workbook.evaluate` works an expression out: its sheet and cell, and whether the formulas it reads
|
|
67
|
+
* are worked out first.
|
|
68
|
+
*/
|
|
69
|
+
export interface EvaluateOptions {
|
|
70
|
+
/** The sheet its references without a sheet are on; the first sheet when left out. */
|
|
71
|
+
sheet?: string;
|
|
72
|
+
/** The cell it is worked out at, which ROW() and relative references read from; A1 when left out. */
|
|
73
|
+
cell?: string;
|
|
74
|
+
/** `false` works each formula it reads out first, in place of the result its cell keeps. */
|
|
75
|
+
kept?: boolean;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* One value an expression gives: a number, text, a logical value, an error, or nothing.
|
|
80
|
+
*/
|
|
81
|
+
export type EvaluatedValue = number | string | boolean | CellErrorValue | null;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* What `Workbook.evaluate` gives: one value, or a range's or an array's values by rows.
|
|
85
|
+
*/
|
|
86
|
+
export type Evaluated = EvaluatedValue | {rows: EvaluatedValue[][]};
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* A formula whose result is not the one Excel saved, as `TrustReport.disagreed` lists it.
|
|
90
|
+
*/
|
|
91
|
+
export interface TrustDisagreement {
|
|
92
|
+
/** The formula's sheet. */
|
|
93
|
+
sheet: string;
|
|
94
|
+
/** The formula's cell. */
|
|
95
|
+
address: string;
|
|
96
|
+
/** The formula's text. */
|
|
97
|
+
formula: string;
|
|
98
|
+
/** The result Excel saved, as text. */
|
|
99
|
+
excel: string;
|
|
100
|
+
/** The engine's result, as text. */
|
|
101
|
+
ours: string;
|
|
102
|
+
/** The functions the formula calls. */
|
|
103
|
+
functions: string[];
|
|
104
|
+
/** The kinds of value the formula reads. */
|
|
105
|
+
reads: string[];
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* The report of `Workbook.trust`: how far the results a file keeps agree with the engine's, each formula
|
|
110
|
+
* worked out again from the results the file keeps.
|
|
111
|
+
*/
|
|
112
|
+
export interface TrustReport {
|
|
113
|
+
/** `excel`, or `library` where the file's results are the library's own: then nothing is checked. */
|
|
114
|
+
source: 'excel' | 'library';
|
|
115
|
+
/** The program that saved the file, as its application properties name it. */
|
|
116
|
+
savedBy?: string;
|
|
117
|
+
/** Why nothing is checked, where the results are the library's own. */
|
|
118
|
+
reason?: string;
|
|
119
|
+
/** How many formulas the report covers. */
|
|
120
|
+
formulas: number;
|
|
121
|
+
/** How many formulas were worked out again and compared. */
|
|
122
|
+
checked: number;
|
|
123
|
+
/** How many of those agree with Excel's result to 15 significant digits. */
|
|
124
|
+
agreed: number;
|
|
125
|
+
/** Of those agreeing, how many differ only in the 15th digit. */
|
|
126
|
+
lastDigit: number;
|
|
127
|
+
/** Each formula whose result is not Excel's. */
|
|
128
|
+
disagreed: TrustDisagreement[];
|
|
129
|
+
/** The formulas left out: volatile, in a cycle, keeping no result, in a data table, or not worked out. */
|
|
130
|
+
skipped: {volatile: number; circular: number; noResult: number; dataTable: number; unsupported: number};
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* The options of `Workbook.goalSeek`: a calculation's, and whether the workbook is calculated after the
|
|
135
|
+
* value is set.
|
|
136
|
+
*/
|
|
137
|
+
export interface GoalSeekOptions extends CalculateOptions {
|
|
138
|
+
/** `false` leaves the workbook uncalculated after the value is set. */
|
|
139
|
+
calculate?: boolean;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Goal Seek, as Excel's dialog box puts it: the cell with the formula, the value it is to give, and the
|
|
144
|
+
* cell changed.
|
|
145
|
+
*/
|
|
146
|
+
export interface GoalSeekSpec {
|
|
147
|
+
/** The cell holding the formula, `Sheet!B5`, or `B5` on the first sheet. */
|
|
148
|
+
set: string;
|
|
149
|
+
/** The value the formula is to give. */
|
|
150
|
+
to: number;
|
|
151
|
+
/** The cell whose value is changed, holding a value, not a formula. */
|
|
152
|
+
changing: string;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* What `Workbook.goalSeek` found: whether a value gives the goal, the value, and what the formula gives
|
|
157
|
+
* with it.
|
|
158
|
+
*/
|
|
159
|
+
export interface GoalSeekResult {
|
|
160
|
+
/** Whether a value gives the goal within the workbook's maximum change. */
|
|
161
|
+
found: boolean;
|
|
162
|
+
/** The value found and set in the changing cell; or the nearest the goal, not set. */
|
|
163
|
+
value: number;
|
|
164
|
+
/** What the formula gives with the value. */
|
|
165
|
+
result?: number;
|
|
166
|
+
/** How many times the formula was worked out. */
|
|
167
|
+
evaluations: number;
|
|
168
|
+
/** The calculation after the value was set. */
|
|
169
|
+
calculation?: CalculationReport;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* A scenario of a worksheet, as `Worksheet.scenarios` lists it: its changing cells and the values they
|
|
174
|
+
* take.
|
|
175
|
+
*/
|
|
176
|
+
export interface Scenario {
|
|
177
|
+
/** The scenario's name. */
|
|
178
|
+
name?: string;
|
|
179
|
+
/** Each changing cell with its value. */
|
|
180
|
+
cells: {[address: string]: number | string};
|
|
181
|
+
/** Excel's Prevent changes. */
|
|
182
|
+
locked: boolean;
|
|
183
|
+
/** Whether the scenario is hidden in Excel's Scenario Manager. */
|
|
184
|
+
hidden: boolean;
|
|
185
|
+
/** Who made the scenario. */
|
|
186
|
+
user?: string;
|
|
187
|
+
/** The scenario's comment. */
|
|
188
|
+
comment?: string;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* The options of `Worksheet.addScenario`: the scenario's name, its changing cells and their values, its
|
|
193
|
+
* comment and user.
|
|
194
|
+
*/
|
|
195
|
+
export interface ScenarioSpec {
|
|
196
|
+
/** The scenario's name, 1 to 255 characters, unique on the worksheet. */
|
|
197
|
+
name: string;
|
|
198
|
+
/** 1 to 32 cells of the sheet, each with its value; a date is kept as its serial. */
|
|
199
|
+
cells: {[address: string]: number | string | Date};
|
|
200
|
+
/** A comment on the scenario. */
|
|
201
|
+
comment?: string;
|
|
202
|
+
/** Who made the scenario. */
|
|
203
|
+
user?: string;
|
|
204
|
+
/** Prevent changes, as the Add Scenario dialog box has it; true when left out. */
|
|
205
|
+
locked?: boolean;
|
|
206
|
+
/** Whether the scenario is hidden; false when left out. */
|
|
207
|
+
hidden?: boolean;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* The options of `Worksheet.showScenario`: a calculation's, and whether the workbook is calculated after
|
|
212
|
+
* the scenario's values are set.
|
|
213
|
+
*/
|
|
214
|
+
export interface ShowScenarioOptions extends CalculateOptions {
|
|
215
|
+
/** `false` leaves the workbook uncalculated after the values are set. */
|
|
216
|
+
calculate?: boolean;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* A scenario shown: the scenario, and the calculation after its values were set.
|
|
221
|
+
*/
|
|
222
|
+
export interface ShownScenario {
|
|
223
|
+
/** The scenario shown. */
|
|
224
|
+
scenario: Scenario;
|
|
225
|
+
/** The calculation after its values were set, unless the options said `calculate: false`. */
|
|
226
|
+
calculation?: CalculationReport;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* The value of a cell in a scenario summary: a number, text, a logical value, an error, or nothing.
|
|
231
|
+
*/
|
|
232
|
+
export type ScenarioValue = number | string | boolean | CellErrorValue | null;
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* The values of the changing cells and the results of the result cells, as the workbook stands or under
|
|
236
|
+
* one scenario.
|
|
237
|
+
*/
|
|
238
|
+
export interface ScenarioCase {
|
|
239
|
+
/** The scenario's name; none for the workbook as it stands. */
|
|
240
|
+
name?: string;
|
|
241
|
+
/** Each changing cell's value. */
|
|
242
|
+
values: {[address: string]: ScenarioValue};
|
|
243
|
+
/** Each result cell's result. */
|
|
244
|
+
results: {[address: string]: ScenarioValue};
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* What `Worksheet.scenarioSummary` gives: the changing cells, the result cells, the workbook as it stands,
|
|
249
|
+
* and each scenario.
|
|
250
|
+
*/
|
|
251
|
+
export interface ScenarioSummary {
|
|
252
|
+
/** Every scenario's changing cells. */
|
|
253
|
+
changing: string[];
|
|
254
|
+
/** The result cells, each cell of the ranges given. */
|
|
255
|
+
results: string[];
|
|
256
|
+
/** The values and results as the workbook stands. */
|
|
257
|
+
current: ScenarioCase;
|
|
258
|
+
/** Each scenario's values and the results under it. */
|
|
259
|
+
scenarios: ScenarioCase[];
|
|
260
|
+
}
|