@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,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Arguments for the {@link Calculate.onFailure} event when parsing or evaluation fails.
|
|
3
|
+
*/
|
|
4
|
+
export interface FailureEventArgs {
|
|
5
|
+
/** Error message describing the failure. */
|
|
6
|
+
message: string;
|
|
7
|
+
/** Underlying exception object or message. */
|
|
8
|
+
exception: Object;
|
|
9
|
+
/** Whether the formula can be force-calculated despite the failure. */
|
|
10
|
+
isForceCalculable: boolean;
|
|
11
|
+
/** When set by a listener, requests force calculation. */
|
|
12
|
+
computeForceCalculate?: boolean;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Metadata and handler for a registered library formula.
|
|
16
|
+
*/
|
|
17
|
+
export interface IFormulaCollection {
|
|
18
|
+
/** Bound `Compute*` handler invoked by the engine. */
|
|
19
|
+
handler: Function;
|
|
20
|
+
/** When `true`, the formula was registered via {@link Calculate.defineFunction}. */
|
|
21
|
+
isCustom?: boolean;
|
|
22
|
+
/** Category label for Insert Function UI. */
|
|
23
|
+
category?: string;
|
|
24
|
+
/** Short description of the formula. */
|
|
25
|
+
description?: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Working state for multi-criteria IFS formula evaluation.
|
|
29
|
+
*
|
|
30
|
+
* @hidden
|
|
31
|
+
*/
|
|
32
|
+
export interface StoredCellInfo {
|
|
33
|
+
cellValue: string | string[];
|
|
34
|
+
cellRange: string[];
|
|
35
|
+
criteria: string[];
|
|
36
|
+
argArray: string[];
|
|
37
|
+
isCriteria: string;
|
|
38
|
+
storedCells: string[];
|
|
39
|
+
isCountIfS: string;
|
|
40
|
+
countVal?: number;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Catalog entry used when registering built-in formulas with {@link BasicFormulas}.
|
|
44
|
+
*
|
|
45
|
+
* @hidden
|
|
46
|
+
*/
|
|
47
|
+
export interface IBasicFormula {
|
|
48
|
+
/** Excel function name (for example `"SUM"`). */
|
|
49
|
+
formulaName: string;
|
|
50
|
+
/** Category label (for example `"Math & Trig"`). */
|
|
51
|
+
category?: string;
|
|
52
|
+
/** Short description shown in formula UI. */
|
|
53
|
+
description?: string;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Sheet metadata exposed by a calculate host (workbook / xlsx adapter).
|
|
57
|
+
*
|
|
58
|
+
*/
|
|
59
|
+
export interface CalculateSheetInfo {
|
|
60
|
+
/** Visible sheet name shown to users. */
|
|
61
|
+
visibleName: string;
|
|
62
|
+
/** Internal sheet token/name used in formulas. */
|
|
63
|
+
sheet: string;
|
|
64
|
+
/** Zero-based sheet index in the host workbook. */
|
|
65
|
+
index: number;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Result of host-provided date / time parsing.
|
|
69
|
+
*
|
|
70
|
+
* @hidden
|
|
71
|
+
*/
|
|
72
|
+
export interface CalculateDateParseResult {
|
|
73
|
+
/** Parsed JavaScript date when available. */
|
|
74
|
+
dateObj?: Date;
|
|
75
|
+
/** Whether the value was recognized as a date. */
|
|
76
|
+
isDate?: boolean;
|
|
77
|
+
/** Whether the value was recognized as a time. */
|
|
78
|
+
isTime?: boolean;
|
|
79
|
+
/** Optional normalized value string. */
|
|
80
|
+
value?: string;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Host contract for integrating Calculate with a workbook or xlsx model.
|
|
84
|
+
*
|
|
85
|
+
* Spreadsheet Workbook implements this; other libraries can provide their own adapter.
|
|
86
|
+
*/
|
|
87
|
+
export interface ICalculateHost {
|
|
88
|
+
/**
|
|
89
|
+
* Reads a cell value at 1-based row/column for a sheet family.
|
|
90
|
+
*
|
|
91
|
+
* @param {string | number | Object} sheetFamilyID - Sheet family identifier.
|
|
92
|
+
* @param {number} row - 1-based row index.
|
|
93
|
+
* @param {number} col - 1-based column index.
|
|
94
|
+
* @param {string | number | Object} rest - Host-specific extra arguments.
|
|
95
|
+
*/
|
|
96
|
+
getValueRowCol?(sheetFamilyID: number, row: number, col: number, ...rest: unknown[]): string | number;
|
|
97
|
+
/**
|
|
98
|
+
* Writes a cell value at 1-based row/column for a sheet family.
|
|
99
|
+
*
|
|
100
|
+
* @param {string | number | Object} sheetFamilyID - Sheet family identifier.
|
|
101
|
+
* @param {string | number | boolean | Object} value - Value to store.
|
|
102
|
+
* @param {number} row - 1-based row index.
|
|
103
|
+
* @param {number} col - 1-based column index.
|
|
104
|
+
* @param {string} formula - Optional formula text associated with the value.
|
|
105
|
+
* @param {string | number | Object} rest - Host-specific extra arguments.
|
|
106
|
+
*/
|
|
107
|
+
setValueRowCol?(sheetFamilyID: number, value: string | number, row: number, col: number, formula?: string, ...rest: unknown[]): void;
|
|
108
|
+
/** Returns sheet metadata for name/token resolution. */
|
|
109
|
+
getSheetInfo?(): CalculateSheetInfo[];
|
|
110
|
+
/**
|
|
111
|
+
* Parses locale-aware date/time text.
|
|
112
|
+
*
|
|
113
|
+
* @param {string | number | boolean | Object} value - Date or time string.
|
|
114
|
+
*/
|
|
115
|
+
parseDate?(value: string): CalculateDateParseResult;
|
|
116
|
+
/** Host module name (for example `"workbook"`). */
|
|
117
|
+
getModuleName?(): string;
|
|
118
|
+
/** Culture/locale id used for parsing and formatting. */
|
|
119
|
+
locale?: string;
|
|
120
|
+
/** Calculation mode such as `"Automatic"` or `"Manual"`. */
|
|
121
|
+
calculationMode?: string;
|
|
122
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Localization defaults for `@syncfusion/ej2-calculate`.
|
|
3
|
+
*
|
|
4
|
+
* ## What is localized
|
|
5
|
+
* Human-readable parser / engine failure prose (wrong argument counts, mismatched
|
|
6
|
+
* parentheses, and similar messages shown via {@link FailureEventArgs} or returned
|
|
7
|
+
* from evaluation).
|
|
8
|
+
*
|
|
9
|
+
* ## What is intentionally NOT localized
|
|
10
|
+
* Excel-compatible literals required for formula language and file interchange:
|
|
11
|
+
* - Error tokens: `#N/A`, `#VALUE!`, `#REF!`, `#DIV/0!`, `#NUM!`, `#NAME?`, `#NULL!`,
|
|
12
|
+
* `#CALC!`, `#SPILL!`, `#CIRCULARREF!`
|
|
13
|
+
* - Logical literals: `TRUE` / `FALSE`
|
|
14
|
+
* - English function names (`SUM`, `IF`, …)
|
|
15
|
+
*
|
|
16
|
+
* Culture-sensitive **separators** (argument, decimal, date) are configured via
|
|
17
|
+
* {@link Calculate} getters/setters and host `locale`, not via these string keys.
|
|
18
|
+
*
|
|
19
|
+
* Load overrides with Syncfusion `L10n.load({ 'fr-FR': { calculate: { ... } } })`.
|
|
20
|
+
*/
|
|
21
|
+
/** Default English locale bag for control name `calculate`. */
|
|
22
|
+
export declare const calculateDefaultLocale: {
|
|
23
|
+
[key: string]: string;
|
|
24
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Localization defaults for `@syncfusion/ej2-calculate`.
|
|
3
|
+
*
|
|
4
|
+
* ## What is localized
|
|
5
|
+
* Human-readable parser / engine failure prose (wrong argument counts, mismatched
|
|
6
|
+
* parentheses, and similar messages shown via {@link FailureEventArgs} or returned
|
|
7
|
+
* from evaluation).
|
|
8
|
+
*
|
|
9
|
+
* ## What is intentionally NOT localized
|
|
10
|
+
* Excel-compatible literals required for formula language and file interchange:
|
|
11
|
+
* - Error tokens: `#N/A`, `#VALUE!`, `#REF!`, `#DIV/0!`, `#NUM!`, `#NAME?`, `#NULL!`,
|
|
12
|
+
* `#CALC!`, `#SPILL!`, `#CIRCULARREF!`
|
|
13
|
+
* - Logical literals: `TRUE` / `FALSE`
|
|
14
|
+
* - English function names (`SUM`, `IF`, …)
|
|
15
|
+
*
|
|
16
|
+
* Culture-sensitive **separators** (argument, decimal, date) are configured via
|
|
17
|
+
* {@link Calculate} getters/setters and host `locale`, not via these string keys.
|
|
18
|
+
*
|
|
19
|
+
* Load overrides with Syncfusion `L10n.load({ 'fr-FR': { calculate: { ... } } })`.
|
|
20
|
+
*/
|
|
21
|
+
/** Default English locale bag for control name `calculate`. */
|
|
22
|
+
export var calculateDefaultLocale = {
|
|
23
|
+
OperatorsCannotStartWithExpression: 'binary operators cannot start an expression',
|
|
24
|
+
CannotParse: 'cannot parse',
|
|
25
|
+
BadLibrary: 'bad library',
|
|
26
|
+
InvalidCharInFrontOf: 'invalid char in front of',
|
|
27
|
+
NumberContains2DecimalPoints: 'number contains 2 decimal points',
|
|
28
|
+
ExpressionCannotEndWithAnOperator: 'expression cannot end with an operator',
|
|
29
|
+
InvalidCharactersFollowingWithOperator: 'invalid characters following an operator',
|
|
30
|
+
InvalidCharInNumber: 'invalid character in number',
|
|
31
|
+
MismatchedParentheses: 'mismatched parentheses',
|
|
32
|
+
UnknownFormulaName: 'unknown formula name',
|
|
33
|
+
RequiresASingleArgument: 'requires a single argument',
|
|
34
|
+
Requires3Args: 'requires 3 arguments',
|
|
35
|
+
InvalidMathArgument: 'invalid Math argument',
|
|
36
|
+
Requires2Args: 'requires 2 arguments',
|
|
37
|
+
TooComplex: 'too complex',
|
|
38
|
+
MissingFormula: 'missing formula',
|
|
39
|
+
ImproperFormula: 'improper formula',
|
|
40
|
+
InvalidExpression: 'invalid expression',
|
|
41
|
+
CellEmpty: 'cell empty',
|
|
42
|
+
BadFormula: 'bad formula',
|
|
43
|
+
EmptyExpression: 'empty expression',
|
|
44
|
+
MismatchedTics: 'mismatched string quotes',
|
|
45
|
+
WrongNumberArguments: 'wrong number of arguments',
|
|
46
|
+
InvalidArguments: 'invalid arguments',
|
|
47
|
+
IterationsDoNotConverge: 'iterations do not converge',
|
|
48
|
+
AlreadyRegistered: 'Control is already registered',
|
|
49
|
+
CalculationOverflow: 'Calculation overflow',
|
|
50
|
+
MissingSheet: 'Missing sheet',
|
|
51
|
+
CannotParseUnderscore: 'cannot_parse',
|
|
52
|
+
ExpressionCannotEndWithAnOperatorUnderscore: 'expression_cannot_end_with_an_operator',
|
|
53
|
+
CategoryAll: 'All'
|
|
54
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns whether `date` is a valid JavaScript `Date` instance.
|
|
3
|
+
*
|
|
4
|
+
* @hidden
|
|
5
|
+
* @param {number | string} date - Value to test.
|
|
6
|
+
* @returns {Date | Object} - `true` when `date` is a valid `Date`.
|
|
7
|
+
*/
|
|
8
|
+
export declare function isDateTime(date: any): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Returns whether `val` is numeric (number or numeric string).
|
|
11
|
+
*
|
|
12
|
+
* @hidden
|
|
13
|
+
* @param {string | number} val - Value to test.
|
|
14
|
+
* @returns {number} - `true` when numeric.
|
|
15
|
+
*/
|
|
16
|
+
export declare function isNumber(val: string | number): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Convert a Date (or date-like value) to an Excel serial number.
|
|
19
|
+
*
|
|
20
|
+
* @hidden
|
|
21
|
+
* @param {any} val - Specifies the value.
|
|
22
|
+
* @param {boolean} isTime - Include time fraction.
|
|
23
|
+
* @param {boolean} isTimeOnly - Value is time without date.
|
|
24
|
+
* @returns {number} - Excel serial number.
|
|
25
|
+
*/
|
|
26
|
+
export declare function dateToInt(val: any, isTime?: boolean, isTimeOnly?: boolean): number;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
/**
|
|
3
|
+
* Returns whether `date` is a valid JavaScript `Date` instance.
|
|
4
|
+
*
|
|
5
|
+
* @hidden
|
|
6
|
+
* @param {number | string} date - Value to test.
|
|
7
|
+
* @returns {Date | Object} - `true` when `date` is a valid `Date`.
|
|
8
|
+
*/
|
|
9
|
+
export function isDateTime(date) {
|
|
10
|
+
return Object.prototype.toString.call(date) === '[object Date]' && !isNaN(date.valueOf());
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Returns whether `val` is numeric (number or numeric string).
|
|
14
|
+
*
|
|
15
|
+
* @hidden
|
|
16
|
+
* @param {string | number} val - Value to test.
|
|
17
|
+
* @returns {number} - `true` when numeric.
|
|
18
|
+
*/
|
|
19
|
+
export function isNumber(val) {
|
|
20
|
+
return val - parseFloat(val) >= 0;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Convert a Date (or date-like value) to an Excel serial number.
|
|
24
|
+
*
|
|
25
|
+
* @hidden
|
|
26
|
+
* @param {any} val - Specifies the value.
|
|
27
|
+
* @param {boolean} isTime - Include time fraction.
|
|
28
|
+
* @param {boolean} isTimeOnly - Value is time without date.
|
|
29
|
+
* @returns {number} - Excel serial number.
|
|
30
|
+
*/
|
|
31
|
+
export function dateToInt(val, isTime, isTimeOnly) {
|
|
32
|
+
var startDate = new Date('01/01/1900');
|
|
33
|
+
var date = isDateTime(val) ? val : new Date(val);
|
|
34
|
+
var startDateUTC = Date.UTC(startDate.getFullYear(), startDate.getMonth(), startDate.getDate(), startDate.getHours(), startDate.getMinutes(), startDate.getSeconds(), startDate.getMilliseconds());
|
|
35
|
+
var dateUTC = Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
|
|
36
|
+
var diffDays = ((dateUTC - startDateUTC) / (1000 * 3600 * 24));
|
|
37
|
+
return (isTime ? diffDays : parseInt(diffDays.toString(), 10)) + (isTimeOnly ? 0 : (diffDays > 60 ? 2 : 1));
|
|
38
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CalculateSheetInfo } from './interface';
|
|
2
|
+
/**
|
|
3
|
+
* Find sheet index by internal sheet token name (e.g. 'Sheet1').
|
|
4
|
+
*
|
|
5
|
+
* @hidden
|
|
6
|
+
* @param {string} name - Sheet token name.
|
|
7
|
+
* @param {CalculateSheetInfo[]} info - Host sheet info list.
|
|
8
|
+
* @returns {number} - Sheet index, or -1 when not found.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getSheetIndexByName(name: string, info: CalculateSheetInfo[]): number;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Find sheet index by internal sheet token name (e.g. 'Sheet1').
|
|
3
|
+
*
|
|
4
|
+
* @hidden
|
|
5
|
+
* @param {string} name - Sheet token name.
|
|
6
|
+
* @param {CalculateSheetInfo[]} info - Host sheet info list.
|
|
7
|
+
* @returns {number} - Sheet index, or -1 when not found.
|
|
8
|
+
*/
|
|
9
|
+
export function getSheetIndexByName(name, info) {
|
|
10
|
+
var len = info.length;
|
|
11
|
+
for (var i = 0; i < len; i++) {
|
|
12
|
+
if (info[i].sheet.toUpperCase() === name.toUpperCase()) {
|
|
13
|
+
return info[i].index;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return -1;
|
|
17
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ascending / descending comparer compatible with former DataUtil.fnSort usage.
|
|
3
|
+
*
|
|
4
|
+
* @hidden
|
|
5
|
+
* @param {string} order - 'Ascending' or 'Descending' (empty defaults to ascending numeric compare).
|
|
6
|
+
* @returns {Function} - Comparer (a, b) => number.
|
|
7
|
+
*/
|
|
8
|
+
export declare function createSortComparer(order?: string): (a: Object, b: Object) => number;
|
|
9
|
+
/**
|
|
10
|
+
* Sort a collection with an optional order string.
|
|
11
|
+
*
|
|
12
|
+
* @template T
|
|
13
|
+
* @param {T[]} collection - Items to sort.
|
|
14
|
+
* @param {string} order - 'Ascending' or 'Descending'.
|
|
15
|
+
* @returns {T[]} - Sorted shallow copy.
|
|
16
|
+
*/
|
|
17
|
+
export declare function sortCollection<T>(collection: T[], order?: string): T[];
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ascending / descending comparer compatible with former DataUtil.fnSort usage.
|
|
3
|
+
*
|
|
4
|
+
* @hidden
|
|
5
|
+
* @param {string} order - 'Ascending' or 'Descending' (empty defaults to ascending numeric compare).
|
|
6
|
+
* @returns {Function} - Comparer (a, b) => number.
|
|
7
|
+
*/
|
|
8
|
+
export function createSortComparer(order) {
|
|
9
|
+
var descending = order === 'Descending';
|
|
10
|
+
return function (a, b) {
|
|
11
|
+
if (a === b) {
|
|
12
|
+
return 0;
|
|
13
|
+
}
|
|
14
|
+
if (a === null || a === undefined) {
|
|
15
|
+
return 1;
|
|
16
|
+
}
|
|
17
|
+
if (b === null || b === undefined) {
|
|
18
|
+
return -1;
|
|
19
|
+
}
|
|
20
|
+
var result = 0;
|
|
21
|
+
if (typeof a === 'string') {
|
|
22
|
+
result = a.localeCompare(b);
|
|
23
|
+
}
|
|
24
|
+
else if (a > b) {
|
|
25
|
+
result = 1;
|
|
26
|
+
}
|
|
27
|
+
else if (a < b) {
|
|
28
|
+
result = -1;
|
|
29
|
+
}
|
|
30
|
+
return descending ? -result : result;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Sort a collection with an optional order string.
|
|
35
|
+
*
|
|
36
|
+
* @template T
|
|
37
|
+
* @param {T[]} collection - Items to sort.
|
|
38
|
+
* @param {string} order - 'Ascending' or 'Descending'.
|
|
39
|
+
* @returns {T[]} - Sorted shallow copy.
|
|
40
|
+
*/
|
|
41
|
+
export function sortCollection(collection, order) {
|
|
42
|
+
var comparer = createSortComparer(order);
|
|
43
|
+
return collection.slice().sort(comparer);
|
|
44
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { IBasicFormula } from '../common/index';
|
|
2
|
+
import { FormulaOwner } from './formula-owner';
|
|
3
|
+
import { FormulaModuleBase } from './formula-module-base';
|
|
4
|
+
/**
|
|
5
|
+
* Array formula helpers for dynamic spill-style range operations.
|
|
6
|
+
*
|
|
7
|
+
* Registered functions: UNIQUE, SORT.
|
|
8
|
+
*
|
|
9
|
+
* @hidden
|
|
10
|
+
*/
|
|
11
|
+
export declare class ArrayFormulas extends FormulaModuleBase {
|
|
12
|
+
/** Formula definitions registered with {@link BasicFormulas}. */
|
|
13
|
+
formulas: IBasicFormula[];
|
|
14
|
+
/**
|
|
15
|
+
* @hidden
|
|
16
|
+
* @param {FormulaOwner} owner - Formula registration owner ({@link BasicFormulas}).
|
|
17
|
+
*/
|
|
18
|
+
constructor(owner: FormulaOwner);
|
|
19
|
+
/**
|
|
20
|
+
* Returns a unique values from a range or array.
|
|
21
|
+
*
|
|
22
|
+
* Excel: `UNIQUE(...)`.
|
|
23
|
+
*
|
|
24
|
+
* @hidden
|
|
25
|
+
* @param {string[]} args - Formula argument tokens from the Calculate engine.
|
|
26
|
+
* @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```ts
|
|
30
|
+
* engine.computeFormula('=UNIQUE(1)');
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
ComputeUNIQUE(...args: string[]): number | string | number[] | string[];
|
|
34
|
+
private setValueRefresh;
|
|
35
|
+
private checkSpill;
|
|
36
|
+
clearDependency(value: string): void;
|
|
37
|
+
/**
|
|
38
|
+
* Sorts a range of an array.
|
|
39
|
+
*
|
|
40
|
+
* Excel: `SORT(...)`.
|
|
41
|
+
*
|
|
42
|
+
* @hidden
|
|
43
|
+
* @param {string[]} args - Formula argument tokens from the Calculate engine.
|
|
44
|
+
* @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
|
|
45
|
+
*/
|
|
46
|
+
ComputeSORT(...args: string[]): number | string;
|
|
47
|
+
}
|