@syncfusion/ej2-calculate 35.1.37
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/.eslintrc.json +263 -0
- package/README.md +132 -0
- package/base.d.ts +4 -0
- package/base.js +4 -0
- package/common.d.ts +4 -0
- package/common.js +4 -0
- package/dist/ej2-calculate.umd.min.js +11 -0
- package/dist/ej2-calculate.umd.min.js.map +1 -0
- package/dist/es6/ej2-calculate.es2015.js +24801 -0
- package/dist/es6/ej2-calculate.es2015.js.map +1 -0
- package/dist/es6/ej2-calculate.es5.js +27229 -0
- package/dist/es6/ej2-calculate.es5.js.map +1 -0
- package/dist/global/ej2-calculate.min.js +11 -0
- package/dist/global/ej2-calculate.min.js.map +1 -0
- package/dist/global/index.d.ts +14 -0
- package/formulas.d.ts +4 -0
- package/formulas.js +4 -0
- package/index.d.ts +4 -0
- package/index.js +4 -0
- package/license +10 -0
- package/package.json +30 -0
- package/src/base/calculate-model.d.ts +4 -0
- package/src/base/calculate-model.js +0 -0
- package/src/base/calculate.d.ts +1105 -0
- package/src/base/calculate.js +4720 -0
- package/src/base/index.d.ts +8 -0
- package/src/base/index.js +7 -0
- package/src/base/parser.d.ts +208 -0
- package/src/base/parser.js +1512 -0
- package/src/common/address.d.ts +59 -0
- package/src/common/address.js +96 -0
- package/src/common/cell-ref.d.ts +32 -0
- package/src/common/cell-ref.js +112 -0
- package/src/common/common.d.ts +44 -0
- package/src/common/common.js +134 -0
- package/src/common/enum.d.ts +94 -0
- package/src/common/enum.js +97 -0
- package/src/common/index.d.ts +9 -0
- package/src/common/index.js +8 -0
- package/src/common/interface.d.ts +122 -0
- package/src/common/interface.js +0 -0
- package/src/common/l10n.d.ts +24 -0
- package/src/common/l10n.js +54 -0
- package/src/common/number-date.d.ts +26 -0
- package/src/common/number-date.js +38 -0
- package/src/common/sheet-info.d.ts +10 -0
- package/src/common/sheet-info.js +17 -0
- package/src/common/sort.d.ts +17 -0
- package/src/common/sort.js +44 -0
- package/src/formulas/array.d.ts +47 -0
- package/src/formulas/array.js +718 -0
- package/src/formulas/basic.d.ts +47 -0
- package/src/formulas/basic.js +181 -0
- package/src/formulas/complex-numbers.d.ts +207 -0
- package/src/formulas/complex-numbers.js +549 -0
- package/src/formulas/database.d.ts +152 -0
- package/src/formulas/database.js +579 -0
- package/src/formulas/date-time-extra.d.ts +97 -0
- package/src/formulas/date-time-extra.js +415 -0
- package/src/formulas/date-time-intl.d.ts +57 -0
- package/src/formulas/date-time-intl.js +309 -0
- package/src/formulas/date-time.d.ts +164 -0
- package/src/formulas/date-time.js +1021 -0
- package/src/formulas/engineering-base.d.ts +150 -0
- package/src/formulas/engineering-base.js +404 -0
- package/src/formulas/engineering-bessel.d.ts +65 -0
- package/src/formulas/engineering-bessel.js +167 -0
- package/src/formulas/engineering-convert.d.ts +35 -0
- package/src/formulas/engineering-convert.js +120 -0
- package/src/formulas/engineering-misc.d.ts +64 -0
- package/src/formulas/engineering-misc.js +168 -0
- package/src/formulas/financial-amortization-ecma.d.ts +87 -0
- package/src/formulas/financial-amortization-ecma.js +288 -0
- package/src/formulas/financial-annuity.d.ts +104 -0
- package/src/formulas/financial-annuity.js +419 -0
- package/src/formulas/financial-bond-helpers.d.ts +106 -0
- package/src/formulas/financial-bond-helpers.js +190 -0
- package/src/formulas/financial-cashflow.d.ts +47 -0
- package/src/formulas/financial-cashflow.js +203 -0
- package/src/formulas/financial-coupons.d.ts +227 -0
- package/src/formulas/financial-coupons.js +810 -0
- package/src/formulas/financial-depreciation.d.ts +64 -0
- package/src/formulas/financial-depreciation.js +247 -0
- package/src/formulas/financial-rates.d.ts +54 -0
- package/src/formulas/financial-rates.js +140 -0
- package/src/formulas/financial-securities.d.ts +126 -0
- package/src/formulas/financial-securities.js +488 -0
- package/src/formulas/formula-math-helpers.d.ts +212 -0
- package/src/formulas/formula-math-helpers.js +599 -0
- package/src/formulas/formula-module-base.d.ts +54 -0
- package/src/formulas/formula-module-base.js +125 -0
- package/src/formulas/formula-owner.d.ts +17 -0
- package/src/formulas/formula-owner.js +0 -0
- package/src/formulas/index.d.ts +68 -0
- package/src/formulas/index.js +67 -0
- package/src/formulas/information-advanced.d.ts +44 -0
- package/src/formulas/information-advanced.js +157 -0
- package/src/formulas/information-ecma.d.ts +33 -0
- package/src/formulas/information-ecma.js +88 -0
- package/src/formulas/information-extra.d.ts +146 -0
- package/src/formulas/information-extra.js +351 -0
- package/src/formulas/information.d.ts +34 -0
- package/src/formulas/information.js +78 -0
- package/src/formulas/logical-extra.d.ts +75 -0
- package/src/formulas/logical-extra.js +217 -0
- package/src/formulas/logical.d.ts +83 -0
- package/src/formulas/logical.js +296 -0
- package/src/formulas/lookup-array.d.ts +98 -0
- package/src/formulas/lookup-array.js +364 -0
- package/src/formulas/lookup-ref-extra.d.ts +64 -0
- package/src/formulas/lookup-ref-extra.js +180 -0
- package/src/formulas/lookup-ref.d.ts +84 -0
- package/src/formulas/lookup-ref.js +263 -0
- package/src/formulas/lookup.d.ts +114 -0
- package/src/formulas/lookup.js +881 -0
- package/src/formulas/math-aggregate.d.ts +74 -0
- package/src/formulas/math-aggregate.js +376 -0
- package/src/formulas/math-ceiling-ecma.d.ts +42 -0
- package/src/formulas/math-ceiling-ecma.js +123 -0
- package/src/formulas/math-combinatorics.d.ts +75 -0
- package/src/formulas/math-combinatorics.js +290 -0
- package/src/formulas/math-misc.d.ts +164 -0
- package/src/formulas/math-misc.js +889 -0
- package/src/formulas/math-number.d.ts +76 -0
- package/src/formulas/math-number.js +261 -0
- package/src/formulas/math-rounding.d.ts +115 -0
- package/src/formulas/math-rounding.js +728 -0
- package/src/formulas/math-trig-hyperbolic.d.ts +55 -0
- package/src/formulas/math-trig-hyperbolic.js +113 -0
- package/src/formulas/math-trig.d.ts +165 -0
- package/src/formulas/math-trig.js +334 -0
- package/src/formulas/matrix-base.d.ts +13 -0
- package/src/formulas/matrix-base.js +169 -0
- package/src/formulas/matrix.d.ts +64 -0
- package/src/formulas/matrix.js +161 -0
- package/src/formulas/regression-ecma.d.ts +66 -0
- package/src/formulas/regression-ecma.js +234 -0
- package/src/formulas/statistical-advanced.d.ts +125 -0
- package/src/formulas/statistical-advanced.js +756 -0
- package/src/formulas/statistical-correlation.d.ts +75 -0
- package/src/formulas/statistical-correlation.js +198 -0
- package/src/formulas/statistical-dispersion.d.ts +108 -0
- package/src/formulas/statistical-dispersion.js +337 -0
- package/src/formulas/statistical-distribution-extended.d.ts +176 -0
- package/src/formulas/statistical-distribution-extended.js +668 -0
- package/src/formulas/statistical-distribution.d.ts +104 -0
- package/src/formulas/statistical-distribution.js +368 -0
- package/src/formulas/statistical-ecma.d.ts +95 -0
- package/src/formulas/statistical-ecma.js +392 -0
- package/src/formulas/statistical-extended.d.ts +136 -0
- package/src/formulas/statistical-extended.js +340 -0
- package/src/formulas/statistical-ifs.d.ts +46 -0
- package/src/formulas/statistical-ifs.js +180 -0
- package/src/formulas/statistical-moments.d.ts +84 -0
- package/src/formulas/statistical-moments.js +269 -0
- package/src/formulas/statistical-percentile.d.ts +56 -0
- package/src/formulas/statistical-percentile.js +195 -0
- package/src/formulas/statistical-sample-base.d.ts +14 -0
- package/src/formulas/statistical-sample-base.js +124 -0
- package/src/formulas/statistical.d.ts +135 -0
- package/src/formulas/statistical.js +542 -0
- package/src/formulas/text-advanced.d.ts +64 -0
- package/src/formulas/text-advanced.js +222 -0
- package/src/formulas/text-ecma.d.ts +54 -0
- package/src/formulas/text-ecma.js +106 -0
- package/src/formulas/text-extra.d.ts +216 -0
- package/src/formulas/text-extra.js +657 -0
- package/src/formulas/text.d.ts +125 -0
- package/src/formulas/text.js +628 -0
- package/src/global.js +1 -0
- package/src/index.d.ts +14 -0
- package/src/index.js +14 -0
- package/tslint.json +111 -0
|
@@ -0,0 +1,1105 @@
|
|
|
1
|
+
import { INotifyPropertyChanged, EmitType, Base } from '@syncfusion/ej2-base';
|
|
2
|
+
import { CalculateModel } from './calculate-model';
|
|
3
|
+
import { IFormulaCollection, FailureEventArgs, StoredCellInfo, ICalculateHost, CalculateSheetInfo, CalculateDateParseResult } from '../common/interface';
|
|
4
|
+
import { Parser } from './parser';
|
|
5
|
+
/**
|
|
6
|
+
* Excel-compatible formula calculation engine.
|
|
7
|
+
*
|
|
8
|
+
* Register sheets, named ranges, and cell values, then evaluate formulas with
|
|
9
|
+
* {@link Calculate.computeFormula} or refresh dependent cells after edits.
|
|
10
|
+
*
|
|
11
|
+
* Built-in library functions are registered by {@link BasicFormulas} (math, text,
|
|
12
|
+
* logical, lookup, financial, statistical, engineering, and ECMA-376 extensions).
|
|
13
|
+
*
|
|
14
|
+
* @remarks
|
|
15
|
+
* Integrate with a workbook by passing an {@link ICalculateHost} to the constructor,
|
|
16
|
+
* or use standalone key/value storage via {@link Calculate.setKeyValue}.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* import { Calculate } from '@syncfusion/ej2-calculate';
|
|
21
|
+
*
|
|
22
|
+
* const engine = new Calculate();
|
|
23
|
+
* engine.setKeyValue('A1', '10');
|
|
24
|
+
* engine.setKeyValue('A2', '20');
|
|
25
|
+
* const sum = engine.computeFormula('=SUM(A1:A2)'); // '30'
|
|
26
|
+
* engine.destroy();
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare class Calculate extends Base<HTMLElement> implements INotifyPropertyChanged {
|
|
30
|
+
private lFormulas;
|
|
31
|
+
/**
|
|
32
|
+
* Registered library formula collection (name → handler metadata).
|
|
33
|
+
*
|
|
34
|
+
* Prefer {@link getLibraryFormulas} for read access. The setter accepts a single
|
|
35
|
+
* formula registration payload used during built-in and custom registration.
|
|
36
|
+
*
|
|
37
|
+
* @hidden
|
|
38
|
+
* @returns {any} - Registered library formula collection.
|
|
39
|
+
*/
|
|
40
|
+
libraryFormulas: any;
|
|
41
|
+
/** @hidden */
|
|
42
|
+
storedData: Map<string, FormulaInfo>;
|
|
43
|
+
/** @hidden */
|
|
44
|
+
actCell: string;
|
|
45
|
+
private keyToRowsMap;
|
|
46
|
+
private rowsToKeyMap;
|
|
47
|
+
/** @hidden */
|
|
48
|
+
rightBracket: string;
|
|
49
|
+
/** @hidden */
|
|
50
|
+
leftBracket: string;
|
|
51
|
+
/** @hidden */
|
|
52
|
+
sheetToken: string;
|
|
53
|
+
/**
|
|
54
|
+
* Active cell reference currently being evaluated (may include a sheet token).
|
|
55
|
+
*
|
|
56
|
+
* @hidden
|
|
57
|
+
*/
|
|
58
|
+
cell: string;
|
|
59
|
+
private cellPrefix;
|
|
60
|
+
private treatEmptyStringAsZero;
|
|
61
|
+
/** @hidden */
|
|
62
|
+
parentObject: Object | Calculate;
|
|
63
|
+
/** @hidden */
|
|
64
|
+
tic: string;
|
|
65
|
+
/** @hidden */
|
|
66
|
+
singleTic: string;
|
|
67
|
+
/** @hidden */
|
|
68
|
+
trueValue: string;
|
|
69
|
+
/** @hidden */
|
|
70
|
+
falseValue: string;
|
|
71
|
+
private parseDecimalSeparator;
|
|
72
|
+
/** @hidden */
|
|
73
|
+
spreadSheetUsedRange: number[];
|
|
74
|
+
/** @hidden */
|
|
75
|
+
arithMarker: string;
|
|
76
|
+
/** @hidden */
|
|
77
|
+
arithMarker2: string;
|
|
78
|
+
private dependentCells;
|
|
79
|
+
private dependentFormulaCells;
|
|
80
|
+
/**
|
|
81
|
+
* Minimum numeric bound used by library formulas that clamp results.
|
|
82
|
+
*
|
|
83
|
+
* @hidden
|
|
84
|
+
*/
|
|
85
|
+
minValue: number;
|
|
86
|
+
/**
|
|
87
|
+
* Maximum numeric bound used by library formulas that clamp results.
|
|
88
|
+
*
|
|
89
|
+
* @hidden
|
|
90
|
+
*/
|
|
91
|
+
maxValue: number;
|
|
92
|
+
/**
|
|
93
|
+
* Formula category labels used by Insert Function UI integrations.
|
|
94
|
+
* The `'All'` entry is localized via Syncfusion {@link L10n} (key `CategoryAll`).
|
|
95
|
+
*
|
|
96
|
+
* @hidden
|
|
97
|
+
*/
|
|
98
|
+
categoryCollection: string[];
|
|
99
|
+
/**
|
|
100
|
+
* Nesting depth counter used while walking formula dependencies.
|
|
101
|
+
*
|
|
102
|
+
* @hidden
|
|
103
|
+
*/
|
|
104
|
+
dependencyLevel: number;
|
|
105
|
+
/**
|
|
106
|
+
* Syncfusion L10n instance for localizable calculate prose (not Excel tokens).
|
|
107
|
+
*
|
|
108
|
+
* @hidden
|
|
109
|
+
*/
|
|
110
|
+
private l10n;
|
|
111
|
+
/** @hidden */
|
|
112
|
+
randomValues: Map<string, string>;
|
|
113
|
+
/** @hidden */
|
|
114
|
+
isRandomVal: boolean;
|
|
115
|
+
/** @hidden */
|
|
116
|
+
randCollection: string[];
|
|
117
|
+
/** @hidden */
|
|
118
|
+
dependencyCollection: string[];
|
|
119
|
+
/** @hidden */
|
|
120
|
+
uniqueRange: string[];
|
|
121
|
+
private uniqueCells;
|
|
122
|
+
/** @hidden */
|
|
123
|
+
sortRange: string[];
|
|
124
|
+
private sortCells;
|
|
125
|
+
/**
|
|
126
|
+
* Parser and engine failure messages indexed by {@link FormulasErrorsStrings}.
|
|
127
|
+
*
|
|
128
|
+
* Prose entries are localized via {@link L10n} / {@link setLocale}. Excel error
|
|
129
|
+
* tokens in this array (`#NAME?`, `#CIRCULARREF!`, `#SPILL!`, `#DIV/0!`) stay
|
|
130
|
+
* English for workbook compatibility.
|
|
131
|
+
*
|
|
132
|
+
* @hidden
|
|
133
|
+
*/
|
|
134
|
+
formulaErrorStrings: string[];
|
|
135
|
+
private errorStrings;
|
|
136
|
+
/** @hidden */
|
|
137
|
+
grid: Object | Calculate;
|
|
138
|
+
/** @hidden */
|
|
139
|
+
parser: Parser;
|
|
140
|
+
private parseArgumentSeparator;
|
|
141
|
+
private dateTime1900;
|
|
142
|
+
private isParseDecimalSeparatorChanged;
|
|
143
|
+
private isArgumentSeparatorChanged;
|
|
144
|
+
private sheetFamilyID;
|
|
145
|
+
private defaultFamilyItem;
|
|
146
|
+
private sheetFamiliesList;
|
|
147
|
+
private modelToSheetID;
|
|
148
|
+
/** @hidden */
|
|
149
|
+
tokenCount: number;
|
|
150
|
+
private sortedSheetNames;
|
|
151
|
+
private tempSheetPlaceHolder;
|
|
152
|
+
/** @hidden */
|
|
153
|
+
namedRanges: Map<string, string>;
|
|
154
|
+
private formulaInfoTable;
|
|
155
|
+
private millisecondsOfaDay;
|
|
156
|
+
private parseDateTimeSeparator;
|
|
157
|
+
/** Keys currently being evaluated via {@link getKeyValue} (guards row-map recursion). */
|
|
158
|
+
private evaluatingKeys;
|
|
159
|
+
/**
|
|
160
|
+
* Fired when formula parsing or evaluation fails.
|
|
161
|
+
*
|
|
162
|
+
* @event onFailure
|
|
163
|
+
*/
|
|
164
|
+
onFailure: EmitType<FailureEventArgs>;
|
|
165
|
+
/**
|
|
166
|
+
* Creates a Calculate engine and registers built-in formulas.
|
|
167
|
+
*
|
|
168
|
+
* @param {Object} parent - Optional host implementing {@link ICalculateHost} (for example a workbook),
|
|
169
|
+
* or omit for a standalone engine that stores values with {@link setKeyValue}.
|
|
170
|
+
*/
|
|
171
|
+
constructor(parent?: Object | ICalculateHost);
|
|
172
|
+
/**
|
|
173
|
+
* Applies culture-specific prose for parser/engine messages and category labels.
|
|
174
|
+
*
|
|
175
|
+
* Excel error tokens (`#VALUE!`, …), `TRUE`/`FALSE`, and English function names
|
|
176
|
+
* are not localized.
|
|
177
|
+
*
|
|
178
|
+
* @hidden
|
|
179
|
+
* @param {string} locale - Culture id (for example `"fr-FR"`). Defaults to host `locale` or `"en-US"`.
|
|
180
|
+
* @returns {void}
|
|
181
|
+
*/
|
|
182
|
+
setLocale(locale?: string): void;
|
|
183
|
+
/**
|
|
184
|
+
* Rebuilds {@link formulaErrorStrings} and {@link categoryCollection} from L10n.
|
|
185
|
+
*
|
|
186
|
+
* @hidden
|
|
187
|
+
* @returns {void}
|
|
188
|
+
*/
|
|
189
|
+
private refreshLocalizedStrings;
|
|
190
|
+
/**
|
|
191
|
+
* Returns sheet metadata from the calculate host when available.
|
|
192
|
+
*
|
|
193
|
+
* @returns {Object} - Sheet info entries from {@link ICalculateHost.getSheetInfo}, or an empty array.
|
|
194
|
+
* @hidden
|
|
195
|
+
*/
|
|
196
|
+
getHostSheetInfo(): CalculateSheetInfo[];
|
|
197
|
+
/**
|
|
198
|
+
* Parses a date/time string via the host when {@link ICalculateHost.parseDate} is implemented.
|
|
199
|
+
*
|
|
200
|
+
* @param {string | number | boolean | Object} value - Date or time text to parse.
|
|
201
|
+
* @returns {Object} - Host parse result, or an empty object when no host parser is available.
|
|
202
|
+
* @hidden
|
|
203
|
+
*/
|
|
204
|
+
hostParseDate(value: string): CalculateDateParseResult;
|
|
205
|
+
/**
|
|
206
|
+
* Gets the culture-aware separator used to split formula arguments (typically `,` or `;`).
|
|
207
|
+
*
|
|
208
|
+
* @hidden
|
|
209
|
+
* @returns {string} - Argument separator string.
|
|
210
|
+
*/
|
|
211
|
+
getParseArgumentSeparator(): string;
|
|
212
|
+
/**
|
|
213
|
+
* Sets the separator used to split formula arguments.
|
|
214
|
+
*
|
|
215
|
+
* @param {string | number | boolean | Object} value - Argument separator for the current culture (for example `,` or `;`).
|
|
216
|
+
* @returns {void}
|
|
217
|
+
*/
|
|
218
|
+
setParseArgumentSeparator(value: string): void;
|
|
219
|
+
/**
|
|
220
|
+
* Gets the date/time component separator used when parsing date literals.
|
|
221
|
+
*
|
|
222
|
+
* @hidden
|
|
223
|
+
* @returns {Date | Object} - Date/time separator string (default `/`).
|
|
224
|
+
*/
|
|
225
|
+
getParseDateTimeSeparator(): string;
|
|
226
|
+
/**
|
|
227
|
+
* Controls whether empty string cell values are treated as numeric zero in calculations.
|
|
228
|
+
*
|
|
229
|
+
* @param {string | number | boolean | Object} value - When `true`, empty strings coerce to `0`.
|
|
230
|
+
* @returns {void}
|
|
231
|
+
*/
|
|
232
|
+
setTreatEmptyStringAsZero(value: boolean): void;
|
|
233
|
+
/**
|
|
234
|
+
* Returns whether empty string values are treated as numeric zero.
|
|
235
|
+
*
|
|
236
|
+
* @hidden
|
|
237
|
+
* @returns {string | number} - `true` when empty strings coerce to `0`.
|
|
238
|
+
*/
|
|
239
|
+
getTreatEmptyStringAsZero(): boolean;
|
|
240
|
+
/**
|
|
241
|
+
* Sets the date/time component separator used when parsing date literals.
|
|
242
|
+
*
|
|
243
|
+
* @hidden
|
|
244
|
+
* @param {string | number | boolean | Object} value - Separator character or string (for example `/` or `-`).
|
|
245
|
+
* @returns {void}
|
|
246
|
+
*/
|
|
247
|
+
setParseDateTimeSeparator(value: string): void;
|
|
248
|
+
/**
|
|
249
|
+
* Syncfusion property-change hook (no-op for Calculate; required by {@link INotifyPropertyChanged}).
|
|
250
|
+
*
|
|
251
|
+
* @param {Object} newProp - Updated model properties.
|
|
252
|
+
* @param {Object} oldProp - Previous model properties.
|
|
253
|
+
* @returns {void}
|
|
254
|
+
*/
|
|
255
|
+
onPropertyChanged(newProp: CalculateModel, oldProp: CalculateModel): void;
|
|
256
|
+
/**
|
|
257
|
+
* Gets the module name of the Calculate engine.
|
|
258
|
+
*
|
|
259
|
+
* @returns {string} - Returns "calculate" as the component module name.
|
|
260
|
+
*/
|
|
261
|
+
getModuleName(): string;
|
|
262
|
+
/**
|
|
263
|
+
* Returns the leading character that marks a formula expression (always `=`).
|
|
264
|
+
*
|
|
265
|
+
* @returns {string} - Formula prefix character.
|
|
266
|
+
* @hidden
|
|
267
|
+
*/
|
|
268
|
+
getFormulaCharacter(): string;
|
|
269
|
+
/**
|
|
270
|
+
* Returns whether the first character of `text` is an uppercase A–Z letter.
|
|
271
|
+
*
|
|
272
|
+
* @param {string} text - Text to inspect.
|
|
273
|
+
* @returns {string} - `true` when the first character is uppercase ASCII A-Z.
|
|
274
|
+
* @hidden
|
|
275
|
+
*/
|
|
276
|
+
isUpperChar(text: string): boolean;
|
|
277
|
+
private resetKeys;
|
|
278
|
+
/**
|
|
279
|
+
* Records a dependency from the active formula cell to `cellRef` and detects circular references.
|
|
280
|
+
*
|
|
281
|
+
* @param {string} cellRef - Dependent cell reference (may include a sheet token).
|
|
282
|
+
* @throws When a circular reference is detected.
|
|
283
|
+
* @hidden
|
|
284
|
+
* @returns {void}
|
|
285
|
+
*/
|
|
286
|
+
updateDependentCell(cellRef: string): void;
|
|
287
|
+
/**
|
|
288
|
+
* Returns the map of cell references to cells that depend on them.
|
|
289
|
+
*
|
|
290
|
+
* @returns {Object} - Dependency map keyed by referenced cell.
|
|
291
|
+
* @hidden
|
|
292
|
+
*/
|
|
293
|
+
getDependentCells(): Map<string, string[]>;
|
|
294
|
+
/**
|
|
295
|
+
* Returns the map of formula cells to the references they depend on.
|
|
296
|
+
*
|
|
297
|
+
* @returns {Object} - Nested map of formula cell → referenced cells.
|
|
298
|
+
* @hidden
|
|
299
|
+
*/
|
|
300
|
+
getDependentFormulaCells(): Map<string, Map<string, string>>;
|
|
301
|
+
/**
|
|
302
|
+
* Returns the map of registered library formula names to their handlers and metadata.
|
|
303
|
+
*
|
|
304
|
+
* @hidden
|
|
305
|
+
* @returns {Object} - Map keyed by uppercase Excel function name (for example `"SUM"`, `"XLOOKUP"`).
|
|
306
|
+
*/
|
|
307
|
+
getLibraryFormulas(): Map<string, IFormulaCollection>;
|
|
308
|
+
/**
|
|
309
|
+
* Returns the handler function for a registered library formula.
|
|
310
|
+
*
|
|
311
|
+
* @hidden
|
|
312
|
+
* @param {string} libFormula - Excel function name (case-insensitive), for example `"SUM"`.
|
|
313
|
+
* @returns {Function | null} - Bound `Compute*` handler, or `null` when the name is not registered.
|
|
314
|
+
*
|
|
315
|
+
* @example
|
|
316
|
+
* ```ts
|
|
317
|
+
* const sum = engine.getFunction('SUM');
|
|
318
|
+
* ```
|
|
319
|
+
*/
|
|
320
|
+
getFunction(libFormula: string): Function;
|
|
321
|
+
/**
|
|
322
|
+
* Converts an Excel serial date value to a JavaScript `Date`.
|
|
323
|
+
*
|
|
324
|
+
* @param {string | number} val - Excel serial number as a string.
|
|
325
|
+
* @returns {Date | Object} - Corresponding `Date` (accounts for the Excel 1900 leap-year quirk).
|
|
326
|
+
* @hidden
|
|
327
|
+
*/
|
|
328
|
+
intToDate(val: string): Date;
|
|
329
|
+
/**
|
|
330
|
+
* Returns the formula info table for the active sheet family (or the standalone engine table).
|
|
331
|
+
*
|
|
332
|
+
* @hidden
|
|
333
|
+
* @returns {Object} - Map of cell token → {@link FormulaInfo}.
|
|
334
|
+
*/
|
|
335
|
+
getFormulaInfoTable(): Map<string, FormulaInfo>;
|
|
336
|
+
/**
|
|
337
|
+
* Gets the decimal separator used when parsing numeric literals.
|
|
338
|
+
*
|
|
339
|
+
* @hidden
|
|
340
|
+
* @returns {string} - Decimal separator string (default `.`).
|
|
341
|
+
*/
|
|
342
|
+
getParseDecimalSeparator(): string;
|
|
343
|
+
/**
|
|
344
|
+
* Sets the decimal separator used when parsing numeric literals.
|
|
345
|
+
*
|
|
346
|
+
* @param {string | number | boolean | Object} value - Decimal separator for the current culture (for example `.` or `,`).
|
|
347
|
+
* @returns {void}
|
|
348
|
+
*/
|
|
349
|
+
setParseDecimalSeparator(value: string): void;
|
|
350
|
+
/**
|
|
351
|
+
* Extracts the sheet token prefix from a cell reference when present.
|
|
352
|
+
*
|
|
353
|
+
* @param {string} cellRef - Cell or range reference that may begin with a sheet token.
|
|
354
|
+
* @returns {string} - Sheet token substring including delimiters, or an empty string.
|
|
355
|
+
* @hidden
|
|
356
|
+
*/
|
|
357
|
+
getSheetToken(cellRef: string): string;
|
|
358
|
+
/**
|
|
359
|
+
* Resolves the sheet family id for a grid/parent object.
|
|
360
|
+
*
|
|
361
|
+
* @param {Object} grd - Grid or parent object registered with the engine.
|
|
362
|
+
* @returns {string | number} - Sheet id, or `-1` when not registered.
|
|
363
|
+
* @hidden
|
|
364
|
+
*/
|
|
365
|
+
getSheetID(grd: Object): number;
|
|
366
|
+
/**
|
|
367
|
+
* Parses a numeric string using the configured decimal separator.
|
|
368
|
+
*
|
|
369
|
+
* @hidden
|
|
370
|
+
* @param {string | number | boolean | Object} value - Numeric text or number.
|
|
371
|
+
* @returns {number} - Parsed number, or `NaN` when parsing fails.
|
|
372
|
+
*/
|
|
373
|
+
parseFloat(value: string | number): number;
|
|
374
|
+
/**
|
|
375
|
+
* Returns the 1-based row index from a cell reference string.
|
|
376
|
+
*
|
|
377
|
+
* @hidden
|
|
378
|
+
* @param {string} cell - Cell reference (optional sheet token allowed).
|
|
379
|
+
* @returns {number} - Row number, or `-1` when invalid.
|
|
380
|
+
*/
|
|
381
|
+
rowIndex(cell: string): number;
|
|
382
|
+
/**
|
|
383
|
+
* Returns the 1-based column index from a cell reference string.
|
|
384
|
+
*
|
|
385
|
+
* @param {string} cell - Cell reference (optional sheet token allowed).
|
|
386
|
+
* @returns {number} - Column number, or `-1` when invalid.
|
|
387
|
+
* @hidden
|
|
388
|
+
*/
|
|
389
|
+
colIndex(cell: string): number;
|
|
390
|
+
/**
|
|
391
|
+
* Returns the Excel-compatible error tokens used by the engine (`#N/A`, `#VALUE!`, …).
|
|
392
|
+
*
|
|
393
|
+
* @returns {string[]} - Error string list indexed by {@link CommonErrors}.
|
|
394
|
+
* @hidden
|
|
395
|
+
*/
|
|
396
|
+
getErrorStrings(): string[];
|
|
397
|
+
/**
|
|
398
|
+
* Returns a substring with Excel-style optional length (defaults to remainder of `text`).
|
|
399
|
+
*
|
|
400
|
+
* @param {string} text - Source string.
|
|
401
|
+
* @param {number} startIndex - Zero-based start index.
|
|
402
|
+
* @param {number} length - Optional length; when omitted, returns through the end of `text`.
|
|
403
|
+
* @returns {string} - Substring.
|
|
404
|
+
* @hidden
|
|
405
|
+
*/
|
|
406
|
+
substring(text: string, startIndex: number, length?: number): string;
|
|
407
|
+
/**
|
|
408
|
+
* Returns whether `c` is an alphabetic character (A–Z or a–z).
|
|
409
|
+
*
|
|
410
|
+
* @param {number} c - Single character or string whose first character is tested.
|
|
411
|
+
* @returns {string | number} - `true` when alphabetic.
|
|
412
|
+
* @hidden
|
|
413
|
+
*/
|
|
414
|
+
isChar(c: string): boolean;
|
|
415
|
+
/**
|
|
416
|
+
* Returns the {@link CalcSheetFamilyItem} for a model/grid, creating family storage as needed.
|
|
417
|
+
*
|
|
418
|
+
* @param {Object} model - Parent grid or sheet model.
|
|
419
|
+
* @param {string | number | Object} calcId - Optional explicit family id.
|
|
420
|
+
* @returns {string | number} - Sheet family item for the model.
|
|
421
|
+
* @hidden
|
|
422
|
+
*/
|
|
423
|
+
getSheetFamilyItem(model: Object, calcId?: number): CalcSheetFamilyItem;
|
|
424
|
+
/**
|
|
425
|
+
* Stores a standalone key/value (or formula) for evaluation without a workbook host.
|
|
426
|
+
*
|
|
427
|
+
* When `value` starts with `=`, it is treated as a formula and evaluated by {@link getKeyValue}.
|
|
428
|
+
*
|
|
429
|
+
* @param {string} key - Cell-like key (for example `"A1"`).
|
|
430
|
+
* @param {string | number | boolean | Object} value - Literal value or formula text.
|
|
431
|
+
*
|
|
432
|
+
* @example
|
|
433
|
+
* ```ts
|
|
434
|
+
* engine.setKeyValue('A1', '10');
|
|
435
|
+
* engine.setKeyValue('B1', '=A1*2');
|
|
436
|
+
* ```
|
|
437
|
+
* @returns {void}
|
|
438
|
+
*/
|
|
439
|
+
setKeyValue(key: string, value: string | number): void;
|
|
440
|
+
/**
|
|
441
|
+
* Clears dependency graph entries for a formula cell.
|
|
442
|
+
*
|
|
443
|
+
* @param {string} cell - Formula cell token whose dependencies should be removed.
|
|
444
|
+
* @hidden
|
|
445
|
+
* @returns {void}
|
|
446
|
+
*/
|
|
447
|
+
clearFormulaDependentCells(cell: string): void;
|
|
448
|
+
/**
|
|
449
|
+
* Clears all stored key-value pairs from memory in standalone mode.
|
|
450
|
+
*
|
|
451
|
+
* @returns {void}
|
|
452
|
+
*/
|
|
453
|
+
clearKeys(): void;
|
|
454
|
+
private arrayRemove;
|
|
455
|
+
/**
|
|
456
|
+
* Returns the stored or computed value for a standalone key registered with {@link setKeyValue}.
|
|
457
|
+
*
|
|
458
|
+
* @param {string} key - Cell-like key (case-insensitive).
|
|
459
|
+
* @returns {string} - Computed formula result or stored literal; empty string when missing.
|
|
460
|
+
*
|
|
461
|
+
* @example
|
|
462
|
+
* ```ts
|
|
463
|
+
* engine.setKeyValue('A1', '=1+2');
|
|
464
|
+
* engine.getKeyValue('A1'); // '3'
|
|
465
|
+
* ```
|
|
466
|
+
*/
|
|
467
|
+
getKeyValue(key: string): string | number;
|
|
468
|
+
/**
|
|
469
|
+
* Returns the named range map (name → range address).
|
|
470
|
+
*
|
|
471
|
+
* @hidden
|
|
472
|
+
* @returns {Object} - Mutable map of named ranges.
|
|
473
|
+
*/
|
|
474
|
+
getNamedRanges(): Map<string, string>;
|
|
475
|
+
/**
|
|
476
|
+
* Adds or replaces a named range.
|
|
477
|
+
*
|
|
478
|
+
* @param {string} name - Range name (optionally `Sheet!Name` scoped).
|
|
479
|
+
* @param {string} range - Address or formula text associated with the name.
|
|
480
|
+
* @returns {string} - `true` when the name was registered; `false` when sheet scope could not be resolved.
|
|
481
|
+
*/
|
|
482
|
+
addNamedRange(name: string, range: string): boolean;
|
|
483
|
+
/**
|
|
484
|
+
* Rewrites named-range keys after a sheet rename.
|
|
485
|
+
*
|
|
486
|
+
* @param {string} pName - Previous sheet name segment.
|
|
487
|
+
* @param {string} name - New sheet name segment.
|
|
488
|
+
* @hidden
|
|
489
|
+
* @returns {void}
|
|
490
|
+
*/
|
|
491
|
+
updateNamedRange(pName: string, name: string): void;
|
|
492
|
+
/**
|
|
493
|
+
* Removes a named range by name.
|
|
494
|
+
*
|
|
495
|
+
* @param {string} name - Named range to remove (case-insensitive).
|
|
496
|
+
* @returns {string} - `true` when the name existed and was removed.
|
|
497
|
+
*/
|
|
498
|
+
removeNamedRange(name: string): boolean;
|
|
499
|
+
/**
|
|
500
|
+
* Converts a 1-based column number to Excel column letters (`1` → `"A"`, `27` → `"AA"`).
|
|
501
|
+
*
|
|
502
|
+
* @param {number} col - 1-based column index.
|
|
503
|
+
* @returns {string | number} - Column letters.
|
|
504
|
+
* @hidden
|
|
505
|
+
*/
|
|
506
|
+
convertAlpha(col: number): string;
|
|
507
|
+
/**
|
|
508
|
+
* Expands a cell or range reference into an array of individual cell addresses.
|
|
509
|
+
*
|
|
510
|
+
* @param {string} cellRange - Single cell or `A1:B2`-style range (sheet token allowed).
|
|
511
|
+
* @returns {string} - Cell address array, or the original string when not expandable.
|
|
512
|
+
* @hidden
|
|
513
|
+
*/
|
|
514
|
+
getCellCollection(cellRange: string): string[] | string;
|
|
515
|
+
/**
|
|
516
|
+
* Parses (when needed) and evaluates a formula expression.
|
|
517
|
+
*
|
|
518
|
+
* @hidden
|
|
519
|
+
* @param {string} formulaText - Formula text (with or without leading `=`) or a pre-parsed token string.
|
|
520
|
+
* @param {boolean} isFromComputeExpression - Internal flag when invoked from {@link computeExpression}.
|
|
521
|
+
* @returns {string} - Computed value, or an Excel error token string on failure.
|
|
522
|
+
*
|
|
523
|
+
* @example
|
|
524
|
+
* ```ts
|
|
525
|
+
* engine.computeFormula('=SUM(1,2,3)'); // '6'
|
|
526
|
+
* ```
|
|
527
|
+
*/
|
|
528
|
+
computeFormula(formulaText: string, isFromComputeExpression?: boolean): string | number;
|
|
529
|
+
private calculateFormula;
|
|
530
|
+
/**
|
|
531
|
+
* Shared implementation for SUMIF / AVERAGEIF range evaluation.
|
|
532
|
+
*
|
|
533
|
+
* @param {string} range - Argument tokens for the conditional aggregate.
|
|
534
|
+
* @param {boolean} isAvgIf - When `true`, computes AVERAGEIF semantics; otherwise SUMIF.
|
|
535
|
+
* @returns {string} - Partial aggregate values or an error string.
|
|
536
|
+
* @hidden
|
|
537
|
+
*/
|
|
538
|
+
computeSumIfAndAvgIf(range: string[], isAvgIf: boolean): number[] | string;
|
|
539
|
+
/**
|
|
540
|
+
* Shared LOOKUP evaluation helper used by library formula handlers.
|
|
541
|
+
*
|
|
542
|
+
* @param {string} range - LOOKUP argument tokens.
|
|
543
|
+
* @returns {string} - Matched value or an error token.
|
|
544
|
+
* @hidden
|
|
545
|
+
*/
|
|
546
|
+
computeLookup(range: string[]): string;
|
|
547
|
+
/**
|
|
548
|
+
* Shared VLOOKUP / HLOOKUP evaluation helper.
|
|
549
|
+
*
|
|
550
|
+
* @param {string} range - Lookup argument tokens.
|
|
551
|
+
* @param {boolean} isVlookup - When `true` (default), uses VLOOKUP orientation; otherwise HLOOKUP.
|
|
552
|
+
* @returns {string} - Matched value or an error token.
|
|
553
|
+
* @hidden
|
|
554
|
+
*/
|
|
555
|
+
computeVHLookup(range: string[], isVlookup?: boolean): string;
|
|
556
|
+
private findClosestMatch;
|
|
557
|
+
private compareStrings;
|
|
558
|
+
/**
|
|
559
|
+
* Applies Excel-style wildcard matching (`*`, `?`, `~`) between criteria and a cell value.
|
|
560
|
+
*
|
|
561
|
+
* @param {string | number | Object} lookVal - Criteria pattern.
|
|
562
|
+
* @param {string} cellValue - Candidate cell text.
|
|
563
|
+
* @returns {string | number} - Match marker or original values used by lookup/criteria helpers.
|
|
564
|
+
* @hidden
|
|
565
|
+
*/
|
|
566
|
+
findWildCardValue(lookVal: string, cellValue: string): string;
|
|
567
|
+
/**
|
|
568
|
+
* Evaluates criteria against a criteria range and aggregates matching sum-range values.
|
|
569
|
+
*
|
|
570
|
+
* @param {string} criteriaRange - Criteria cells.
|
|
571
|
+
* @param {string} sumRange - Values to aggregate for matches.
|
|
572
|
+
* @param {string} criteria - Criteria expression.
|
|
573
|
+
* @returns {string | number} - Aggregate result details used by SUMIF-family formulas.
|
|
574
|
+
* @hidden
|
|
575
|
+
*/
|
|
576
|
+
getComputeSumIfValue(criteriaRange: string[] | string, sumRange: string[] | string, criteria: string, checkCriteria: number, op: string, isAsterisk: boolean, isQuestionMark: boolean): number[];
|
|
577
|
+
private getValueFromRange;
|
|
578
|
+
/**
|
|
579
|
+
* Evaluates AND / OR / NOT over argument tokens.
|
|
580
|
+
*
|
|
581
|
+
* @param {string[]} args - Logical argument tokens.
|
|
582
|
+
* @param {string} op - Operation name (`"and"`, `"or"`, or `"not"`).
|
|
583
|
+
* @returns {string} - `"TRUE"`, `"FALSE"`, or an error token.
|
|
584
|
+
* @hidden
|
|
585
|
+
*/
|
|
586
|
+
computeAndOrNot(args: string[], op: string): string;
|
|
587
|
+
/**
|
|
588
|
+
* @hidden
|
|
589
|
+
* @param {string} text - specify the text
|
|
590
|
+
* @returns {string} - to strip out the tic from the formula arguments.
|
|
591
|
+
*/
|
|
592
|
+
/**
|
|
593
|
+
* Strips surrounding formula string quotes (`"...`) when present.
|
|
594
|
+
*
|
|
595
|
+
* @param {string} text - Possibly quoted text.
|
|
596
|
+
* @returns {string} - Unquoted text.
|
|
597
|
+
* @hidden
|
|
598
|
+
*/
|
|
599
|
+
removeTics(text: string): string;
|
|
600
|
+
/**
|
|
601
|
+
* Returns the top-left cell address from a range string.
|
|
602
|
+
*
|
|
603
|
+
* @param {string} range - Range such as `A1:B2`.
|
|
604
|
+
* @returns {string | number} - Starting cell address.
|
|
605
|
+
* @hidden
|
|
606
|
+
*/
|
|
607
|
+
getCellFrom(range: string): string;
|
|
608
|
+
private computeValue;
|
|
609
|
+
private getValArithmetic;
|
|
610
|
+
/**
|
|
611
|
+
* Applies a comparison operator to values on the evaluation stack.
|
|
612
|
+
*
|
|
613
|
+
* @param {string | number | Object} stack - Value stack.
|
|
614
|
+
* @param {string | number | Object} operator - Comparison / logical operator token.
|
|
615
|
+
* @param {string | number | Object} emptyStack - Optional alternate stack for empty handling.
|
|
616
|
+
* @returns {string} - `"TRUE"`, `"FALSE"`, or an error token.
|
|
617
|
+
* @hidden
|
|
618
|
+
*/
|
|
619
|
+
processLogical(stack: string[], operator: string, emptyStack?: string[]): string;
|
|
620
|
+
/**
|
|
621
|
+
* Stores and expands cells for multi-criteria IFS formulas.
|
|
622
|
+
*
|
|
623
|
+
* @param {string} sCell - Stored cell info payload.
|
|
624
|
+
* @returns {string | number} - Expanded stored cell list.
|
|
625
|
+
* @hidden
|
|
626
|
+
*/
|
|
627
|
+
computeStoreCells(sCell: StoredCellInfo): string[];
|
|
628
|
+
/**
|
|
629
|
+
* Shared SUMIFS / AVERAGEIFS evaluation entry point.
|
|
630
|
+
*
|
|
631
|
+
* @param {string} range - Argument tokens for the IFS aggregate.
|
|
632
|
+
* @param {boolean} isCountIfs - COUNTIFS marker when applicable.
|
|
633
|
+
* @param {string} isAvgIfs - AVERAGEIFS marker when applicable.
|
|
634
|
+
* @returns {string} - Aggregate result or error token.
|
|
635
|
+
* @hidden
|
|
636
|
+
*/
|
|
637
|
+
computeIfsFormulas(range: string[], isCountIfs?: string, isAvgIfs?: string): string | number;
|
|
638
|
+
/**
|
|
639
|
+
* Shared COUNTIFS evaluation entry point.
|
|
640
|
+
*
|
|
641
|
+
* @param {string} range - COUNTIFS argument tokens.
|
|
642
|
+
* @returns {string} - Count result or error token.
|
|
643
|
+
* @hidden
|
|
644
|
+
*/
|
|
645
|
+
computeCountIfsFormulas(range: string[]): string | number;
|
|
646
|
+
private getOperatorAndCriteria;
|
|
647
|
+
private processNestedFormula;
|
|
648
|
+
/**
|
|
649
|
+
* Returns whether `value` is `NaN` after numeric coercion.
|
|
650
|
+
*
|
|
651
|
+
* @hidden
|
|
652
|
+
* @param {string | number | boolean | Object} value - Value to test.
|
|
653
|
+
* @returns {number} - `true` when not a number.
|
|
654
|
+
*/
|
|
655
|
+
isNaN(value: string | number): boolean;
|
|
656
|
+
/**
|
|
657
|
+
* Returns whether `val` is numeric (including numeric strings).
|
|
658
|
+
*
|
|
659
|
+
* @hidden
|
|
660
|
+
* @param {string | number} val - Value to test.
|
|
661
|
+
* @returns {number} - `true` when numeric.
|
|
662
|
+
*/
|
|
663
|
+
isNumber(val: string | number): boolean;
|
|
664
|
+
/**
|
|
665
|
+
* Converts an OLE Automation (Excel) serial date to a JavaScript `Date`.
|
|
666
|
+
*
|
|
667
|
+
* @hidden
|
|
668
|
+
* @param {string | number | Object} doubleNumber - Excel serial date/time.
|
|
669
|
+
* @returns {Date | Object} - JavaScript `Date`.
|
|
670
|
+
*/
|
|
671
|
+
fromOADate(doubleNumber: number): Date;
|
|
672
|
+
/**
|
|
673
|
+
* Builds an Excel serial date from year, month, and day components.
|
|
674
|
+
*
|
|
675
|
+
* @hidden
|
|
676
|
+
* @param {number} year - Full year.
|
|
677
|
+
* @param {number} month - Month number (1–12; Excel-style overflow allowed).
|
|
678
|
+
* @param {number} day - Day of month (Excel-style overflow allowed).
|
|
679
|
+
* @returns {number} - Excel serial date number.
|
|
680
|
+
*/
|
|
681
|
+
getSerialDateFromDate(year: number, month: number, day: number): number;
|
|
682
|
+
/**
|
|
683
|
+
* Converts a serial time fraction (or time string) to a `Date`.
|
|
684
|
+
*
|
|
685
|
+
* @param {string | number | boolean | Object} value - Time serial or text.
|
|
686
|
+
* @returns {Date | Object} - `Date` representing the time of day.
|
|
687
|
+
* @hidden
|
|
688
|
+
*/
|
|
689
|
+
intToTime(value: string | number): Date;
|
|
690
|
+
/**
|
|
691
|
+
* Converts a JavaScript `Date` to an Excel OLE Automation serial number.
|
|
692
|
+
*
|
|
693
|
+
* @hidden
|
|
694
|
+
* @param {string | number | Object} dateTime - Date/time to convert.
|
|
695
|
+
* @param {boolean} isTime - When `true`, includes the time fraction.
|
|
696
|
+
* @param {boolean} isTimeOnly - When `true`, treats the value as time without a date component.
|
|
697
|
+
* @returns {number} - Excel serial number.
|
|
698
|
+
*/
|
|
699
|
+
toOADate(dateTime: Date, isTime?: boolean, isTimeOnly?: boolean): number;
|
|
700
|
+
/**
|
|
701
|
+
* Normalizes a date string for calculation.
|
|
702
|
+
*
|
|
703
|
+
* @param {number | string} date - Date text.
|
|
704
|
+
* @returns {string} - Normalized date string.
|
|
705
|
+
* @hidden
|
|
706
|
+
*/
|
|
707
|
+
calculateDate(date: string): string;
|
|
708
|
+
/**
|
|
709
|
+
* Returns whether `s` is `null`, `undefined`, or an empty string.
|
|
710
|
+
*
|
|
711
|
+
* @hidden
|
|
712
|
+
* @param {number | string} s - Text to test.
|
|
713
|
+
* @returns {string | number} - `true` when empty.
|
|
714
|
+
*/
|
|
715
|
+
isTextEmpty(s: string): boolean;
|
|
716
|
+
/**
|
|
717
|
+
* Returns whether `text` consists only of digit characters `0`–`9`.
|
|
718
|
+
*
|
|
719
|
+
* @hidden
|
|
720
|
+
* @param {string} text - Text to test.
|
|
721
|
+
* @returns {string | number} - `true` when all characters are digits.
|
|
722
|
+
*/
|
|
723
|
+
isDigit(text: string): boolean;
|
|
724
|
+
/**
|
|
725
|
+
* Evaluates a single AND condition token to `"TRUE"` / `"FALSE"`.
|
|
726
|
+
*
|
|
727
|
+
* @param {boolean | string | number} condition - Condition expression or cell token.
|
|
728
|
+
* @returns {string} - Logical result string.
|
|
729
|
+
* @hidden
|
|
730
|
+
*/
|
|
731
|
+
getANDComputedValue(condition: string): string;
|
|
732
|
+
private findLastIndexOfq;
|
|
733
|
+
/**
|
|
734
|
+
* Resolves a formula argument token to its computed display/value string.
|
|
735
|
+
*
|
|
736
|
+
* Handles cell references, nested formulas, literals, and named ranges.
|
|
737
|
+
*
|
|
738
|
+
* @hidden
|
|
739
|
+
* @param {string | number} val - Argument token from the parser.
|
|
740
|
+
* @param {boolean} isUnique - UNIQUE formula context.
|
|
741
|
+
* @param {boolean} isIfError - IFERROR/IFNA context.
|
|
742
|
+
* @param {boolean} isSubtotal - SUBTOTAL context.
|
|
743
|
+
* @param {boolean} isIFFormula - IF formula context.
|
|
744
|
+
* @returns {string} - Resolved value string.
|
|
745
|
+
*/
|
|
746
|
+
getValueFromArg(val: string, isUnique?: boolean, isIfError?: boolean, isSubtotal?: boolean, isIFFormula?: boolean): string;
|
|
747
|
+
/**
|
|
748
|
+
* Attempts to interpret `date` as a JavaScript `Date`.
|
|
749
|
+
*
|
|
750
|
+
* @hidden
|
|
751
|
+
* @param {number | string} date - Date instance, serial, or valid text.
|
|
752
|
+
* @returns {Date | Object} - `Date` when recognized; otherwise a false result used by callers.
|
|
753
|
+
*/
|
|
754
|
+
isDate(date: any): Date;
|
|
755
|
+
/**
|
|
756
|
+
* Parses a date-like value into a `Date` or intermediate representation.
|
|
757
|
+
*
|
|
758
|
+
* @param {number | string} date - Value to parse.
|
|
759
|
+
* @returns {string | number} - Parsed date information.
|
|
760
|
+
* @hidden
|
|
761
|
+
*/
|
|
762
|
+
parseDate(date: any): any;
|
|
763
|
+
/**
|
|
764
|
+
* Validates and parses a date string using engine/host date rules.
|
|
765
|
+
*
|
|
766
|
+
* @param {number | string} date - Date text.
|
|
767
|
+
* @param {string | number | Object} pvtParse - Private parse mode.
|
|
768
|
+
* @param {string | number | Object} fromIsDate - When called from {@link isDate}.
|
|
769
|
+
* @returns {Date | Object} - Parsed `Date` when valid.
|
|
770
|
+
* @hidden
|
|
771
|
+
*/
|
|
772
|
+
checkDateFormat(date: string, pvtParse?: boolean, fromIsDate?: boolean): Date;
|
|
773
|
+
/**
|
|
774
|
+
* Returns whether `args` looks like a valid cell or range reference.
|
|
775
|
+
*
|
|
776
|
+
* @hidden
|
|
777
|
+
* @param {string[]} args - Text to test.
|
|
778
|
+
* @returns {string} - `true` when the text is a cell/range reference.
|
|
779
|
+
*/
|
|
780
|
+
isCellReference(args: string): boolean;
|
|
781
|
+
/**
|
|
782
|
+
* Rewrites sheet names in formula text to internal sheet tokens.
|
|
783
|
+
*
|
|
784
|
+
* @param {string} text - Formula text containing sheet names.
|
|
785
|
+
* @returns {string} - Text with sheet tokens substituted.
|
|
786
|
+
* @hidden
|
|
787
|
+
*/
|
|
788
|
+
setTokensForSheets(text: string): string;
|
|
789
|
+
private getParentObjectCellValue;
|
|
790
|
+
/**
|
|
791
|
+
* Returns a function that reads a cell value for the active grid context.
|
|
792
|
+
*
|
|
793
|
+
* @param {Object} grid - Grid / parent object providing cell values.
|
|
794
|
+
* @param {string} actCell - Active cell reference for dependency tracking.
|
|
795
|
+
* @param {string | number | Object} sheetId - Sheet id for the grid.
|
|
796
|
+
* @param {string} updateDependentCell - When `true`, records dependents while reading.
|
|
797
|
+
* @param {string | number | Object} refresh - Whether to refresh computed values while reading.
|
|
798
|
+
* @param {boolean} isUnique - UNIQUE formula context.
|
|
799
|
+
* @param {boolean} isSubtotal - SUBTOTAL formula context.
|
|
800
|
+
* @returns {string} - Cell value getter `(row, col, curCell) => string`.
|
|
801
|
+
* @hidden
|
|
802
|
+
*/
|
|
803
|
+
getCellValueFn(grid: Object, actCell: string, sheetId: number, updateDependentCell?: boolean, refresh?: boolean, isUnique?: boolean, isSubtotal?: boolean): (row: number, col: number, curCell: string) => string;
|
|
804
|
+
private isValidCell;
|
|
805
|
+
/**
|
|
806
|
+
* Returns the numeric sheet id for a registered grid object.
|
|
807
|
+
*
|
|
808
|
+
* @param {Object} grd - Grid / parent object.
|
|
809
|
+
* @returns {string | number} - Sheet id.
|
|
810
|
+
* @hidden
|
|
811
|
+
*/
|
|
812
|
+
getSheetId(grd: Object): number;
|
|
813
|
+
/**
|
|
814
|
+
* Getting the formula result.
|
|
815
|
+
*
|
|
816
|
+
* @param {Object} grid - Specifies the parent object.
|
|
817
|
+
* @param {number} row - Row index of the parent object or key.
|
|
818
|
+
* @param {number} col - Column index of the parent object.
|
|
819
|
+
* @returns {string} - Getting the formula result.
|
|
820
|
+
*/
|
|
821
|
+
/**
|
|
822
|
+
* Reads a cell value from a grid at 1-based row/column indexes.
|
|
823
|
+
*
|
|
824
|
+
* @param {Object} grid - Grid / parent object.
|
|
825
|
+
* @param {number} row - 1-based row index.
|
|
826
|
+
* @param {number} col - 1-based column index.
|
|
827
|
+
* @returns {string} - Cell value as a string.
|
|
828
|
+
*/
|
|
829
|
+
getValueRowCol(grid: Object, row: number, col: number): string;
|
|
830
|
+
/**
|
|
831
|
+
* Registers a custom formula in the library.
|
|
832
|
+
*
|
|
833
|
+
* @param {string} formulaName - Excel-facing function name to register.
|
|
834
|
+
* @param {string} functionName - Handler function, or a global function name string.
|
|
835
|
+
* @param {string | number | Object} formulaDescription - Description shown in Insert Function UI.
|
|
836
|
+
* @param {string} category - Category label for Insert Function UI.
|
|
837
|
+
*
|
|
838
|
+
* @example
|
|
839
|
+
* ```ts
|
|
840
|
+
* engine.defineFunction('DOUBLE', (x) => Number(x) * 2, 'Doubles a number', 'Custom');
|
|
841
|
+
* ```
|
|
842
|
+
* @returns {void}
|
|
843
|
+
*/
|
|
844
|
+
defineFunction(formulaName: string, functionName: string | Function, formulaDescription: string, category: string): void;
|
|
845
|
+
/**
|
|
846
|
+
* Notifies the engine that a cell value or formula changed and optionally recalculates dependents.
|
|
847
|
+
*
|
|
848
|
+
* @hidden
|
|
849
|
+
* @param {Object} grid - Parent object / sheet reference name.
|
|
850
|
+
* @param {string[]} changeArgs - Changed cell coordinates and formula/value.
|
|
851
|
+
* @param {boolean} isCalculate - When `true`, recalculates the changed formula.
|
|
852
|
+
* @param {string | number | Object} usedRangeCol - Used-range bounds for the sheet.
|
|
853
|
+
* @param {string | number | Object} refresh - Whether to refresh computed values.
|
|
854
|
+
* @param {string} sheetName - Visible sheet name for `actCell` tracking.
|
|
855
|
+
* @param {boolean} isRandomFormula - Whether the change involves volatile random formulas.
|
|
856
|
+
* @param {string} randomFormulaRefreshing - Whether random formulas are being refreshed.
|
|
857
|
+
* @param {boolean} isDelete - Whether the change originates from a delete operation.
|
|
858
|
+
* @param {string} deletedRange - Deleted range indexes when `isDelete` is `true`.
|
|
859
|
+
* @param {string | number | Object} refreshDependentCells - Forces dependent refresh regardless of calculation mode.
|
|
860
|
+
* @param {string | number | Object} action - Optional calculation action label (for example `"calculate"`).
|
|
861
|
+
*/
|
|
862
|
+
valueChanged(grid: string, changeArgs: ValueChangedArgs, isCalculate?: boolean, usedRangeCol?: number[], refresh?: boolean, sheetName?: string, isRandomFormula?: boolean, randomFormulaRefreshing?: boolean, isDelete?: boolean, deletedRange?: number[], refreshDependentCells?: boolean, action?: string): void;
|
|
863
|
+
/**
|
|
864
|
+
* @hidden
|
|
865
|
+
* @param {number} value - specify the value
|
|
866
|
+
* @param {string | number} formulaValue - specify the formula value.
|
|
867
|
+
* @param {number} row - specify the row
|
|
868
|
+
* @param {number} col - specify the col.
|
|
869
|
+
* @returns {void} - to set value row and column.
|
|
870
|
+
*/
|
|
871
|
+
/**
|
|
872
|
+
* Writes a computed value into standalone storage for the given sheet/row/column.
|
|
873
|
+
*
|
|
874
|
+
* @param {string | number | boolean | Object} value - Sheet id used to build the storage key.
|
|
875
|
+
* @param {string | number | Object} formulaValue - Value to store.
|
|
876
|
+
* @param {number} row - 1-based row index.
|
|
877
|
+
* @param {number} col - 1-based column index.
|
|
878
|
+
* @returns {void}
|
|
879
|
+
*/
|
|
880
|
+
setValueRowCol(value: number, formulaValue: string | number, row: number, col: number): void;
|
|
881
|
+
private getSortedSheetNames;
|
|
882
|
+
/**
|
|
883
|
+
* Extracts an error line/label from an exception message when present.
|
|
884
|
+
*
|
|
885
|
+
* @param {string} error - Error object or message.
|
|
886
|
+
* @returns {string} - Error line text, or an empty string.
|
|
887
|
+
* @hidden
|
|
888
|
+
*/
|
|
889
|
+
getErrorLine(error: string): string;
|
|
890
|
+
/**
|
|
891
|
+
* Allocates a new sheet family id for registering grids as sheets.
|
|
892
|
+
*
|
|
893
|
+
* @returns {string | number} - New family id.
|
|
894
|
+
* @hidden
|
|
895
|
+
*/
|
|
896
|
+
createSheetFamilyID(): number;
|
|
897
|
+
/**
|
|
898
|
+
* Shared MIN / MAX evaluation over argument tokens.
|
|
899
|
+
*
|
|
900
|
+
* @param {string[]} args - Numeric argument tokens.
|
|
901
|
+
* @param {string | number | Object} operation - `"min"` or `"max"`.
|
|
902
|
+
* @returns {string} - Aggregate result string or error token.
|
|
903
|
+
* @hidden
|
|
904
|
+
*/
|
|
905
|
+
computeMinMax(args: string[], operation: string): string;
|
|
906
|
+
/**
|
|
907
|
+
* Shared AVERAGE evaluation over argument tokens.
|
|
908
|
+
*
|
|
909
|
+
* @param {string[]} args - Numeric argument tokens.
|
|
910
|
+
* @param {boolean} isSubtotalFormula - When `true`, applies SUBTOTAL visibility rules.
|
|
911
|
+
* @returns {string} - Average as a string, or an error token.
|
|
912
|
+
* @hidden
|
|
913
|
+
*/
|
|
914
|
+
calculateAvg(args: string[], isSubtotalFormula?: boolean): string;
|
|
915
|
+
/**
|
|
916
|
+
* Registers a grid/model as a named sheet within a sheet family.
|
|
917
|
+
*
|
|
918
|
+
* @param {string} refName - Sheet reference name.
|
|
919
|
+
* @param {Object} model - Grid / model object (or id string).
|
|
920
|
+
* @param {string | number | Object} sheetFamilyID - Family id from {@link createSheetFamilyID}.
|
|
921
|
+
* @returns {string} - Sheet token assigned to the model.
|
|
922
|
+
*/
|
|
923
|
+
registerGridAsSheet(refName: string, model: Object | string, sheetFamilyID: number): string;
|
|
924
|
+
/**
|
|
925
|
+
* Unregisters a sheet name (or all sheets) from a sheet family.
|
|
926
|
+
*
|
|
927
|
+
* @param {string} refName - Sheet reference name to remove.
|
|
928
|
+
* @param {Object} model - Grid / model object associated with the sheet.
|
|
929
|
+
* @param {Object} unRegisterAll - When `true`, removes all registered sheets for the model.
|
|
930
|
+
* @returns {void}
|
|
931
|
+
*/
|
|
932
|
+
unregisterGridAsSheet(refName: string, model: string | Object, unRegisterAll?: boolean): void;
|
|
933
|
+
/**
|
|
934
|
+
* Parses and evaluates a formula expression in one call (always re-parses).
|
|
935
|
+
*
|
|
936
|
+
* @param {string} formula - Formula text to evaluate.
|
|
937
|
+
* @param {boolean} isFromComputeExpression - Internal flag passed through to {@link computeFormula}.
|
|
938
|
+
* @returns {string} - Computed value or error token.
|
|
939
|
+
*
|
|
940
|
+
* @example
|
|
941
|
+
* ```ts
|
|
942
|
+
* engine.computeExpression('=AVERAGE(1,2,3)'); // '2'
|
|
943
|
+
* ```
|
|
944
|
+
*/
|
|
945
|
+
computeExpression(formula: string, isFromComputeExpression?: boolean): string | number;
|
|
946
|
+
private isSheetMember;
|
|
947
|
+
/**
|
|
948
|
+
* Releases engine state (stored values, named ranges, dependency graphs, sheet
|
|
949
|
+
* families, volatile tracking, and library formulas).
|
|
950
|
+
*
|
|
951
|
+
* Call when the engine instance is no longer needed.
|
|
952
|
+
*
|
|
953
|
+
* @returns {void}
|
|
954
|
+
*/
|
|
955
|
+
destroy(): void;
|
|
956
|
+
/**
|
|
957
|
+
* Recomputes volatile random formula cells tracked by the engine.
|
|
958
|
+
*
|
|
959
|
+
* @param {string} cellRef - Cell reference that triggered the refresh (removed from the random set when present).
|
|
960
|
+
* @hidden
|
|
961
|
+
* @returns {void}
|
|
962
|
+
*/
|
|
963
|
+
refreshRandValues(cellRef: string): void;
|
|
964
|
+
/**
|
|
965
|
+
* Recalculates cells that depend on `cellRef` according to calculation mode and options.
|
|
966
|
+
*
|
|
967
|
+
* @hidden
|
|
968
|
+
* @param {string} cellRef - Changed cell reference.
|
|
969
|
+
* @param {string} uniqueCell - Optional UNIQUE spill context cell to skip.
|
|
970
|
+
* @param {string} dependentCell - Accumulator of already-refreshed dependents (used for recursion).
|
|
971
|
+
* @param {boolean} isRandomFormula - Whether refresh is for volatile random formulas.
|
|
972
|
+
* @param {boolean} isDelete - Whether refresh follows a delete.
|
|
973
|
+
* @param {string} deletedRange - Deleted range indexes.
|
|
974
|
+
* @param {string | number | Object} refreshDependentCells - Forces dependent updates.
|
|
975
|
+
* @param {string | number | Object} action - Optional action label (for example `"calculate"`).
|
|
976
|
+
*/
|
|
977
|
+
refreshDependentCells(cellRef: string, uniqueCell?: string, dependentCell?: string[], isRandomFormula?: boolean, isDelete?: boolean, deletedRange?: number[], refreshDependentCells?: boolean, action?: string): void;
|
|
978
|
+
}
|
|
979
|
+
/**
|
|
980
|
+
* Formula parse/evaluation error raised by the Calculate engine.
|
|
981
|
+
*
|
|
982
|
+
* @hidden
|
|
983
|
+
*/
|
|
984
|
+
export declare class FormulaError {
|
|
985
|
+
/** Human-readable error message. */
|
|
986
|
+
message: string;
|
|
987
|
+
/** When `true`, the parser suggests an auto-corrected formula. */
|
|
988
|
+
formulaCorrection: boolean;
|
|
989
|
+
/**
|
|
990
|
+
* @param {string | number | Object} errorMessage - Error description.
|
|
991
|
+
* @param {string} formulaAutoCorrection - Whether formula auto-correction is available.
|
|
992
|
+
*/
|
|
993
|
+
constructor(errorMessage: string, formulaAutoCorrection?: boolean);
|
|
994
|
+
}
|
|
995
|
+
/**
|
|
996
|
+
* Cached formula text, parsed form, and computed value for a cell.
|
|
997
|
+
*
|
|
998
|
+
* @hidden
|
|
999
|
+
*/
|
|
1000
|
+
export declare class FormulaInfo {
|
|
1001
|
+
/** Calculation generation id for cache invalidation. */
|
|
1002
|
+
calcID: number;
|
|
1003
|
+
/** Original formula text (including leading `=` when present). */
|
|
1004
|
+
formulaText: string;
|
|
1005
|
+
private formulaValue;
|
|
1006
|
+
private parsedFormula;
|
|
1007
|
+
private calcID1;
|
|
1008
|
+
/**
|
|
1009
|
+
* Returns the stored formula text for this cell.
|
|
1010
|
+
*
|
|
1011
|
+
* @returns {string} - Formula text, or `undefined` when unset.
|
|
1012
|
+
*/
|
|
1013
|
+
getFormulaText(): string;
|
|
1014
|
+
/**
|
|
1015
|
+
* Sets the formula text for this cell.
|
|
1016
|
+
*
|
|
1017
|
+
* @param {string | number | boolean | Object} value - Formula text (typically including leading `=`).
|
|
1018
|
+
* @returns {void}
|
|
1019
|
+
*/
|
|
1020
|
+
setFormulaText(value: string): void;
|
|
1021
|
+
/**
|
|
1022
|
+
* Returns the last computed value for this cell.
|
|
1023
|
+
*
|
|
1024
|
+
* @returns {string} - Computed value or error token.
|
|
1025
|
+
*/
|
|
1026
|
+
getFormulaValue(): string | number;
|
|
1027
|
+
/**
|
|
1028
|
+
* Sets the computed value for this cell.
|
|
1029
|
+
*
|
|
1030
|
+
* @param {string | number | boolean | Object} value - Computed result.
|
|
1031
|
+
* @returns {void}
|
|
1032
|
+
*/
|
|
1033
|
+
setFormulaValue(value: string | number): void;
|
|
1034
|
+
/**
|
|
1035
|
+
* Returns the parser token string for this cell's formula.
|
|
1036
|
+
*
|
|
1037
|
+
* @returns {string | number} - Parsed formula tokens.
|
|
1038
|
+
*/
|
|
1039
|
+
getParsedFormula(): string;
|
|
1040
|
+
/**
|
|
1041
|
+
* Sets the parser token string for this cell's formula.
|
|
1042
|
+
*
|
|
1043
|
+
* @param {string | number | boolean | Object} value - Parsed formula tokens from {@link Parser.parseFormula}.
|
|
1044
|
+
* @returns {void}
|
|
1045
|
+
*/
|
|
1046
|
+
setParsedFormula(value: string): void;
|
|
1047
|
+
}
|
|
1048
|
+
/**
|
|
1049
|
+
* Per-family sheet registration and dependency tables used when multiple grids share an engine.
|
|
1050
|
+
*
|
|
1051
|
+
* @hidden
|
|
1052
|
+
*/
|
|
1053
|
+
export declare class CalcSheetFamilyItem {
|
|
1054
|
+
/** Whether this family participates in multi-sheet evaluation. */
|
|
1055
|
+
isSheetMember: boolean;
|
|
1056
|
+
/** Maps parent grid objects to their sheet tokens. */
|
|
1057
|
+
parentObjectToToken: Map<Object, string>;
|
|
1058
|
+
/** Formula dependency map scoped to this sheet family. */
|
|
1059
|
+
sheetDependentFormulaCells: Map<string, Map<string, string>>;
|
|
1060
|
+
/** Maps sheet names to parent grid objects. */
|
|
1061
|
+
sheetNameToParentObject: Map<string, Object>;
|
|
1062
|
+
/** Maps sheet names to sheet tokens. */
|
|
1063
|
+
sheetNameToToken: Map<string, string>;
|
|
1064
|
+
/** Maps sheet tokens to parent grid objects. */
|
|
1065
|
+
tokenToParentObject: Map<string, Object>;
|
|
1066
|
+
/** Formula info table scoped to this sheet family. */
|
|
1067
|
+
sheetFormulaInfotable: Map<string, FormulaInfo>;
|
|
1068
|
+
}
|
|
1069
|
+
/**
|
|
1070
|
+
* Converts a 1-based column index to Excel column letters.
|
|
1071
|
+
*
|
|
1072
|
+
* @param {number} col - 1-based column index.
|
|
1073
|
+
* @returns {string | number} - Column letters (for example `1` → `"A"`).
|
|
1074
|
+
* @hidden
|
|
1075
|
+
*/
|
|
1076
|
+
export declare function getAlphalabel(col: number): string;
|
|
1077
|
+
/**
|
|
1078
|
+
* Arguments describing a cell value/formula change for {@link Calculate.valueChanged}.
|
|
1079
|
+
*
|
|
1080
|
+
* @hidden
|
|
1081
|
+
*/
|
|
1082
|
+
export declare class ValueChangedArgs {
|
|
1083
|
+
/** 1-based row index of the changed cell. */
|
|
1084
|
+
row: number;
|
|
1085
|
+
/** 1-based column index of the changed cell. */
|
|
1086
|
+
col: number;
|
|
1087
|
+
/** New formula text or literal value. */
|
|
1088
|
+
value: number | string;
|
|
1089
|
+
/** Returns the 1-based row index. */
|
|
1090
|
+
getRowIndex: Function;
|
|
1091
|
+
/** Updates the 1-based row index. */
|
|
1092
|
+
setRowIndex: Function;
|
|
1093
|
+
/** Returns the 1-based column index. */
|
|
1094
|
+
getColIndex: Function;
|
|
1095
|
+
/** Updates the 1-based column index. */
|
|
1096
|
+
setColIndex: Function;
|
|
1097
|
+
/** Returns the formula/value associated with this change. */
|
|
1098
|
+
getFormulaValue: Function;
|
|
1099
|
+
/**
|
|
1100
|
+
* @param {number} row - 1-based row index.
|
|
1101
|
+
* @param {number} col - 1-based column index.
|
|
1102
|
+
* @param {string | number | boolean | Object} value - Formula text or literal value.
|
|
1103
|
+
*/
|
|
1104
|
+
constructor(row: number, col: number, value: number | string);
|
|
1105
|
+
}
|