@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,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sheet bounds used when expanding whole-row / whole-column references.
|
|
3
|
+
*
|
|
4
|
+
* @hidden
|
|
5
|
+
*/
|
|
6
|
+
export interface SheetBounds {
|
|
7
|
+
rowCount?: number;
|
|
8
|
+
colCount?: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Returns the 0-based column index for Excel column letters (for example `"A"` → `0`).
|
|
12
|
+
*
|
|
13
|
+
* @hidden
|
|
14
|
+
* @param {string} text - Specifies the text.
|
|
15
|
+
* @returns {number} - Column index (0-based).
|
|
16
|
+
*/
|
|
17
|
+
export declare function getColIndex(text: string): number;
|
|
18
|
+
/**
|
|
19
|
+
* Returns Excel column letters for a 1-based column index (for example `1` → `"A"`).
|
|
20
|
+
*
|
|
21
|
+
* @hidden
|
|
22
|
+
* @param {number} colIndex - 1-based column index.
|
|
23
|
+
* @returns {string} - Column header text.
|
|
24
|
+
*/
|
|
25
|
+
export declare function getColumnHeaderText(colIndex: number): string;
|
|
26
|
+
/**
|
|
27
|
+
* Parses a cell address into 0-based `[rowIndex, colIndex]`.
|
|
28
|
+
*
|
|
29
|
+
* @hidden
|
|
30
|
+
* @param {string} address - Specifies the address.
|
|
31
|
+
* @returns {number[]} - [rowIndex, colIndex] (0-based).
|
|
32
|
+
*/
|
|
33
|
+
export declare function getCellIndexes(address: string): number[];
|
|
34
|
+
/**
|
|
35
|
+
* Builds an `A1`-style cell address from 0-based row and column indexes.
|
|
36
|
+
*
|
|
37
|
+
* @hidden
|
|
38
|
+
* @param {number} sRow - Row index (0-based).
|
|
39
|
+
* @param {number} sCol - Column index (0-based).
|
|
40
|
+
* @returns {string} - Cell address.
|
|
41
|
+
*/
|
|
42
|
+
export declare function getCellAddress(sRow: number, sCol: number): string;
|
|
43
|
+
/**
|
|
44
|
+
* Builds an `A1:B2`-style range address from range indexes.
|
|
45
|
+
*
|
|
46
|
+
* @hidden
|
|
47
|
+
* @param {number[]} range - Range indexes.
|
|
48
|
+
* @returns {string} - Range address.
|
|
49
|
+
*/
|
|
50
|
+
export declare function getRangeAddress(range: number[]): string;
|
|
51
|
+
/**
|
|
52
|
+
* Parses a range string into `[startRow, startCol, endRow, endCol]` (0-based).
|
|
53
|
+
*
|
|
54
|
+
* @hidden
|
|
55
|
+
* @param {string} range - Range string (optional sheet prefix allowed).
|
|
56
|
+
* @param {SheetBounds} [sheetBounds] - Optional sheet bounds for whole-row/column expansion.
|
|
57
|
+
* @returns {number[]} - Range indexes [startRow, startCol, endRow, endCol].
|
|
58
|
+
*/
|
|
59
|
+
export declare function getRangeIndexes(range: string, sheetBounds?: SheetBounds): number[];
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { isNullOrUndefined } from '@syncfusion/ej2-base';
|
|
2
|
+
/**
|
|
3
|
+
* Returns the 0-based column index for Excel column letters (for example `"A"` → `0`).
|
|
4
|
+
*
|
|
5
|
+
* @hidden
|
|
6
|
+
* @param {string} text - Specifies the text.
|
|
7
|
+
* @returns {number} - Column index (0-based).
|
|
8
|
+
*/
|
|
9
|
+
export function getColIndex(text) {
|
|
10
|
+
var colIdx = 0;
|
|
11
|
+
text = text.split('').reverse().join('');
|
|
12
|
+
for (var i = text.length - 1; i >= 0; i--) {
|
|
13
|
+
colIdx += (text[i].charCodeAt(0) - 64) * (Math.pow(26, i));
|
|
14
|
+
}
|
|
15
|
+
return colIdx - 1;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Returns Excel column letters for a 1-based column index (for example `1` → `"A"`).
|
|
19
|
+
*
|
|
20
|
+
* @hidden
|
|
21
|
+
* @param {number} colIndex - 1-based column index.
|
|
22
|
+
* @returns {string} - Column header text.
|
|
23
|
+
*/
|
|
24
|
+
export function getColumnHeaderText(colIndex) {
|
|
25
|
+
var alphabet = 'Z';
|
|
26
|
+
if (colIndex / 26 > 1) {
|
|
27
|
+
return getColumnHeaderText((colIndex % 26 === 0) ? (colIndex / 26 - 1) : Math.floor(colIndex / 26))
|
|
28
|
+
+ String.fromCharCode((colIndex % 26) === 0 ? alphabet.charCodeAt(0) : 64 + (colIndex % 26));
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
return String.fromCharCode(64 + (colIndex));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Parses a cell address into 0-based `[rowIndex, colIndex]`.
|
|
36
|
+
*
|
|
37
|
+
* @hidden
|
|
38
|
+
* @param {string} address - Specifies the address.
|
|
39
|
+
* @returns {number[]} - [rowIndex, colIndex] (0-based).
|
|
40
|
+
*/
|
|
41
|
+
export function getCellIndexes(address) {
|
|
42
|
+
return [parseInt(address.match(/\d+/)[0], 10) - 1, getColIndex(address.match(/[A-Z]+/i)[0].toUpperCase())];
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Builds an `A1`-style cell address from 0-based row and column indexes.
|
|
46
|
+
*
|
|
47
|
+
* @hidden
|
|
48
|
+
* @param {number} sRow - Row index (0-based).
|
|
49
|
+
* @param {number} sCol - Column index (0-based).
|
|
50
|
+
* @returns {string} - Cell address.
|
|
51
|
+
*/
|
|
52
|
+
export function getCellAddress(sRow, sCol) {
|
|
53
|
+
return getColumnHeaderText(sCol + 1) + (sRow + 1);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Builds an `A1:B2`-style range address from range indexes.
|
|
57
|
+
*
|
|
58
|
+
* @hidden
|
|
59
|
+
* @param {number[]} range - Range indexes.
|
|
60
|
+
* @returns {string} - Range address.
|
|
61
|
+
*/
|
|
62
|
+
export function getRangeAddress(range) {
|
|
63
|
+
return getCellAddress(range[0], range[1]) + ':' + (!isNullOrUndefined(range[2]) ?
|
|
64
|
+
getCellAddress(range[2], range[3]) : getCellAddress(range[0], range[1]));
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Parses a range string into `[startRow, startCol, endRow, endCol]` (0-based).
|
|
68
|
+
*
|
|
69
|
+
* @hidden
|
|
70
|
+
* @param {string} range - Range string (optional sheet prefix allowed).
|
|
71
|
+
* @param {SheetBounds} [sheetBounds] - Optional sheet bounds for whole-row/column expansion.
|
|
72
|
+
* @returns {number[]} - Range indexes [startRow, startCol, endRow, endCol].
|
|
73
|
+
*/
|
|
74
|
+
export function getRangeIndexes(range, sheetBounds) {
|
|
75
|
+
var cellindexes;
|
|
76
|
+
var indexes = [];
|
|
77
|
+
if (range) {
|
|
78
|
+
range = range.lastIndexOf('!') > -1 ? range.substring(range.lastIndexOf('!') + 1) : range;
|
|
79
|
+
range = range.indexOf(':') === -1 ? range + ':' + range : range;
|
|
80
|
+
var containsAlphabetsAndDigits = new RegExp(/^(?=.*[a-zA-Z])(?=.*\d)/g);
|
|
81
|
+
if (!containsAlphabetsAndDigits.test(range)) {
|
|
82
|
+
var refArr = range.split(':');
|
|
83
|
+
var rowCount = sheetBounds && sheetBounds.rowCount ? sheetBounds.rowCount - 1 : 1;
|
|
84
|
+
var colHeader = sheetBounds && sheetBounds.colCount ?
|
|
85
|
+
getColumnHeaderText(sheetBounds.colCount) : 'A';
|
|
86
|
+
range = isNullOrUndefined(range.match(/[0-9]/)) ? (refArr[0] + '1:' + refArr[1] + rowCount) :
|
|
87
|
+
('A' + refArr[0] + ':' + colHeader + refArr[1]);
|
|
88
|
+
}
|
|
89
|
+
range.split(':').forEach(function (address) {
|
|
90
|
+
cellindexes = getCellIndexes(address);
|
|
91
|
+
indexes.push(cellindexes[0]);
|
|
92
|
+
indexes.push(cellindexes[1]);
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
return indexes;
|
|
96
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check whether the value is character or not.
|
|
3
|
+
*
|
|
4
|
+
* @hidden
|
|
5
|
+
* @param {string} value - Specify the value to check.
|
|
6
|
+
* @returns {boolean} - Returns boolean value.
|
|
7
|
+
*/
|
|
8
|
+
export declare function isChar(value: string): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Resolve column index from cell text (1-based Excel style).
|
|
11
|
+
*
|
|
12
|
+
* @hidden
|
|
13
|
+
* @param {string} cell - Cell text.
|
|
14
|
+
* @returns {number} - Column index.
|
|
15
|
+
*/
|
|
16
|
+
export declare function columnIndex(cell: string): number;
|
|
17
|
+
/**
|
|
18
|
+
* Check whether the value is a valid single cell reference.
|
|
19
|
+
*
|
|
20
|
+
* @hidden
|
|
21
|
+
* @param {string} value - Specify the value to check.
|
|
22
|
+
* @returns {boolean} - Returns boolean value.
|
|
23
|
+
*/
|
|
24
|
+
export declare function isValidCellReference(value: string): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Check whether the value is cell reference or not.
|
|
27
|
+
*
|
|
28
|
+
* @hidden
|
|
29
|
+
* @param {string} value - Specify the value to check.
|
|
30
|
+
* @returns {boolean} - Returns boolean value.
|
|
31
|
+
*/
|
|
32
|
+
export declare function isCellReference(value: string): boolean;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check whether the value is character or not.
|
|
3
|
+
*
|
|
4
|
+
* @hidden
|
|
5
|
+
* @param {string} value - Specify the value to check.
|
|
6
|
+
* @returns {boolean} - Returns boolean value.
|
|
7
|
+
*/
|
|
8
|
+
export function isChar(value) {
|
|
9
|
+
if ((value.charCodeAt(0) >= 65 && value.charCodeAt(0) <= 90) || (value.charCodeAt(0) >= 97 && value.charCodeAt(0) <= 122)) {
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Resolve column index from cell text (1-based Excel style).
|
|
16
|
+
*
|
|
17
|
+
* @hidden
|
|
18
|
+
* @param {string} cell - Cell text.
|
|
19
|
+
* @returns {number} - Column index.
|
|
20
|
+
*/
|
|
21
|
+
export function columnIndex(cell) {
|
|
22
|
+
var j = 0;
|
|
23
|
+
var k = 0;
|
|
24
|
+
cell = cell.toUpperCase();
|
|
25
|
+
if (j < cell.length && cell[j] === '!') {
|
|
26
|
+
j++;
|
|
27
|
+
while (j < cell.length && cell[j] !== '!') {
|
|
28
|
+
j++;
|
|
29
|
+
}
|
|
30
|
+
j++;
|
|
31
|
+
}
|
|
32
|
+
while (j < cell.length && isChar(cell[j])) {
|
|
33
|
+
var charCode = cell[j].charCodeAt(0);
|
|
34
|
+
k = k * 26 + charCode - 64;
|
|
35
|
+
j++;
|
|
36
|
+
}
|
|
37
|
+
if (k === 0) {
|
|
38
|
+
return -1;
|
|
39
|
+
}
|
|
40
|
+
return k;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Check whether the value is a valid single cell reference.
|
|
44
|
+
*
|
|
45
|
+
* @hidden
|
|
46
|
+
* @param {string} value - Specify the value to check.
|
|
47
|
+
* @returns {boolean} - Returns boolean value.
|
|
48
|
+
*/
|
|
49
|
+
export function isValidCellReference(value) {
|
|
50
|
+
var text = value;
|
|
51
|
+
var endNum = 0;
|
|
52
|
+
var textLength = text.length;
|
|
53
|
+
for (var i = 0; i < textLength; i++) {
|
|
54
|
+
if (isChar(text[i])) {
|
|
55
|
+
endNum++;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
var cellText = text.substring(0, endNum);
|
|
59
|
+
var cellTextLength = cellText.length;
|
|
60
|
+
if (cellTextLength !== textLength) {
|
|
61
|
+
if (cellTextLength < 4) {
|
|
62
|
+
if (textLength !== 1 && (isNaN(parseInt(text, 10)))) {
|
|
63
|
+
var cellColIndex = columnIndex(cellText);
|
|
64
|
+
// XFD is the last column, 16384 - Maximum number of columns in excel.
|
|
65
|
+
if (cellColIndex < 1 || cellColIndex > 16384) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
var rowText = text.substring(endNum, textLength);
|
|
69
|
+
if (rowText.length > 0) {
|
|
70
|
+
var isNumeric = true;
|
|
71
|
+
for (var j = 0; j < rowText.length; j++) {
|
|
72
|
+
var charCode = rowText.charCodeAt(j);
|
|
73
|
+
if (charCode < 48 || charCode > 57) {
|
|
74
|
+
isNumeric = false;
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
if (isNumeric) {
|
|
79
|
+
var cellNumber = parseFloat(rowText);
|
|
80
|
+
if (cellNumber > 0 && cellNumber < 1048577) { // 1048576 - Maximum number of rows in excel.
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Check whether the value is cell reference or not.
|
|
92
|
+
*
|
|
93
|
+
* @hidden
|
|
94
|
+
* @param {string} value - Specify the value to check.
|
|
95
|
+
* @returns {boolean} - Returns boolean value.
|
|
96
|
+
*/
|
|
97
|
+
export function isCellReference(value) {
|
|
98
|
+
var range = value;
|
|
99
|
+
range = range.split('$').join('');
|
|
100
|
+
if (range.indexOf(':') > -1) {
|
|
101
|
+
var rangeSplit = range.split(':');
|
|
102
|
+
if (isValidCellReference(rangeSplit[0]) && isValidCellReference(rangeSplit[1])) {
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
else if (range.indexOf(':') < 0) {
|
|
107
|
+
if (isValidCellReference(range)) {
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Calculate } from '../base';
|
|
2
|
+
/**
|
|
3
|
+
* Shared Calculate helper module used by spreadsheet integrations.
|
|
4
|
+
*
|
|
5
|
+
* @hidden
|
|
6
|
+
*/
|
|
7
|
+
export declare class CalculateCommon {
|
|
8
|
+
private parent;
|
|
9
|
+
/**
|
|
10
|
+
* @param {Object} parent - Owning Calculate engine.
|
|
11
|
+
*/
|
|
12
|
+
constructor(parent: Calculate);
|
|
13
|
+
/**
|
|
14
|
+
* For internal use only - Get the module name.
|
|
15
|
+
*
|
|
16
|
+
* @private
|
|
17
|
+
* @returns {string} - Get the module name.
|
|
18
|
+
*/
|
|
19
|
+
protected getModuleName(): string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* To check whether the object is undefined.
|
|
23
|
+
*
|
|
24
|
+
* @hidden
|
|
25
|
+
* @param {Object} value - To check the object is undefined
|
|
26
|
+
* @returns {boolean} - Returns boolean value.
|
|
27
|
+
* @private
|
|
28
|
+
*/
|
|
29
|
+
export declare function isUndefined(value: Object): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* @hidden
|
|
32
|
+
* @param {string} value - specify the value
|
|
33
|
+
* @returns {string} - get Skeleton Value.
|
|
34
|
+
*/
|
|
35
|
+
export declare function getSkeletonVal(value: string): string;
|
|
36
|
+
/**
|
|
37
|
+
* To check whether the formula contains external file link.
|
|
38
|
+
*
|
|
39
|
+
* @hidden
|
|
40
|
+
* @param {string} formula - To check the string contains external file link.
|
|
41
|
+
* @returns {boolean} - Returns boolean value.
|
|
42
|
+
* @private
|
|
43
|
+
*/
|
|
44
|
+
export declare function isExternalFileLink(formula: string): boolean;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { ExcelFileFormats } from './enum';
|
|
2
|
+
/**
|
|
3
|
+
* Shared Calculate helper module used by spreadsheet integrations.
|
|
4
|
+
*
|
|
5
|
+
* @hidden
|
|
6
|
+
*/
|
|
7
|
+
var CalculateCommon = /** @class */ (function () {
|
|
8
|
+
/**
|
|
9
|
+
* @param {Object} parent - Owning Calculate engine.
|
|
10
|
+
*/
|
|
11
|
+
function CalculateCommon(parent) {
|
|
12
|
+
this.parent = parent;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* For internal use only - Get the module name.
|
|
16
|
+
*
|
|
17
|
+
* @private
|
|
18
|
+
* @returns {string} - Get the module name.
|
|
19
|
+
*/
|
|
20
|
+
CalculateCommon.prototype.getModuleName = function () {
|
|
21
|
+
return 'calc-common';
|
|
22
|
+
};
|
|
23
|
+
return CalculateCommon;
|
|
24
|
+
}());
|
|
25
|
+
export { CalculateCommon };
|
|
26
|
+
/**
|
|
27
|
+
* To check whether the object is undefined.
|
|
28
|
+
*
|
|
29
|
+
* @hidden
|
|
30
|
+
* @param {Object} value - To check the object is undefined
|
|
31
|
+
* @returns {boolean} - Returns boolean value.
|
|
32
|
+
* @private
|
|
33
|
+
*/
|
|
34
|
+
export function isUndefined(value) {
|
|
35
|
+
return ('undefined' === typeof value);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* @hidden
|
|
39
|
+
* @param {string} value - specify the value
|
|
40
|
+
* @returns {string} - get Skeleton Value.
|
|
41
|
+
*/
|
|
42
|
+
export function getSkeletonVal(value) {
|
|
43
|
+
switch (value) {
|
|
44
|
+
case 'dd-MMM-yyyy':
|
|
45
|
+
case 'dd MMM yyyy':
|
|
46
|
+
value = 'medium';
|
|
47
|
+
break;
|
|
48
|
+
case 'MMM yyyy':
|
|
49
|
+
value = 'yMMM';
|
|
50
|
+
break;
|
|
51
|
+
case 'MM/dd/yyyy':
|
|
52
|
+
case 'dd/MM/yyyy':
|
|
53
|
+
case 'dd/MM/yy':
|
|
54
|
+
value = 'short';
|
|
55
|
+
break;
|
|
56
|
+
case 'dddd MMMM dd yyyy': //long
|
|
57
|
+
case 'dd MMMM yyyy':
|
|
58
|
+
value = 'long';
|
|
59
|
+
break;
|
|
60
|
+
case 'd MMMM yyyy':
|
|
61
|
+
value = 'yMMMd';
|
|
62
|
+
break;
|
|
63
|
+
case 'yyyy':
|
|
64
|
+
value = 'y';
|
|
65
|
+
break;
|
|
66
|
+
case 'h:mm':
|
|
67
|
+
value = 'Hm';
|
|
68
|
+
break;
|
|
69
|
+
case 'h:mm tt':
|
|
70
|
+
value = 'hm';
|
|
71
|
+
break;
|
|
72
|
+
case 'h':
|
|
73
|
+
value = 'H';
|
|
74
|
+
break;
|
|
75
|
+
case 'h tt':
|
|
76
|
+
value = 'h';
|
|
77
|
+
break;
|
|
78
|
+
case 'h:mm:ss tt':
|
|
79
|
+
value = 'hms';
|
|
80
|
+
break;
|
|
81
|
+
case 'h:mm:ss':
|
|
82
|
+
value = 'Hms';
|
|
83
|
+
break;
|
|
84
|
+
case 'd':
|
|
85
|
+
value = 'd';
|
|
86
|
+
break;
|
|
87
|
+
case 'd dddd':
|
|
88
|
+
value = 'Ed';
|
|
89
|
+
break;
|
|
90
|
+
case 'M':
|
|
91
|
+
value = 'M';
|
|
92
|
+
break;
|
|
93
|
+
case 'Md':
|
|
94
|
+
value = 'Md';
|
|
95
|
+
break;
|
|
96
|
+
case 'MMM':
|
|
97
|
+
value = 'MMM';
|
|
98
|
+
break;
|
|
99
|
+
case 'ddd MMM d':
|
|
100
|
+
value = 'MMMEd';
|
|
101
|
+
break;
|
|
102
|
+
case 'MMM d':
|
|
103
|
+
value = 'MMMd';
|
|
104
|
+
break;
|
|
105
|
+
case 'M/yyyy':
|
|
106
|
+
value = 'yM';
|
|
107
|
+
break;
|
|
108
|
+
case 'ddd':
|
|
109
|
+
value = 'E';
|
|
110
|
+
break;
|
|
111
|
+
default:
|
|
112
|
+
value = '';
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
return value;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* To check whether the formula contains external file link.
|
|
119
|
+
*
|
|
120
|
+
* @hidden
|
|
121
|
+
* @param {string} formula - To check the string contains external file link.
|
|
122
|
+
* @returns {boolean} - Returns boolean value.
|
|
123
|
+
* @private
|
|
124
|
+
*/
|
|
125
|
+
export function isExternalFileLink(formula) {
|
|
126
|
+
var isExternalFile = false;
|
|
127
|
+
for (var format in ExcelFileFormats) {
|
|
128
|
+
if (formula.indexOf('.' + format + ']') > -1) {
|
|
129
|
+
isExternalFile = true;
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return isExternalFile;
|
|
134
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Indexes into {@link Calculate.getErrorStrings} for Excel-compatible error tokens.
|
|
3
|
+
*
|
|
4
|
+
* @hidden
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* const na = engine.getErrorStrings()[CommonErrors.NA]; // '#N/A'
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
export declare enum CommonErrors {
|
|
12
|
+
/** `#N/A` */
|
|
13
|
+
NA = 0,
|
|
14
|
+
/** `#VALUE!` */
|
|
15
|
+
Value = 1,
|
|
16
|
+
/** `#REF!` */
|
|
17
|
+
Ref = 2,
|
|
18
|
+
/** `#DIV/0!` */
|
|
19
|
+
DivZero = 3,
|
|
20
|
+
/** `#NUM!` */
|
|
21
|
+
Num = 4,
|
|
22
|
+
/** `#NAME?` */
|
|
23
|
+
Name = 5,
|
|
24
|
+
/** `#NULL!` */
|
|
25
|
+
Null = 6,
|
|
26
|
+
/** `#CALC!` */
|
|
27
|
+
Calc = 7
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Indexes into {@link Calculate.formulaErrorStrings} for parser/engine failure messages.
|
|
31
|
+
*
|
|
32
|
+
* @hidden
|
|
33
|
+
*/
|
|
34
|
+
export declare enum FormulasErrorsStrings {
|
|
35
|
+
OperatorsCannotStartWithExpression = 0,
|
|
36
|
+
ReservedWordAND = 1,
|
|
37
|
+
ReservedWordXOR = 2,
|
|
38
|
+
ReservedWordIf = 3,
|
|
39
|
+
NumberContains2DecimalPoints = 4,
|
|
40
|
+
ReservedWordElse = 5,
|
|
41
|
+
ReservedWordNOT = 6,
|
|
42
|
+
InvalidCharInNumber = 7,
|
|
43
|
+
InvalidCharactersFollowingWithOperator = 6,
|
|
44
|
+
MismatchedParentheses = 8,
|
|
45
|
+
UnknownFormulaName = 9,
|
|
46
|
+
RequiresASingleArgument = 10,
|
|
47
|
+
Requires3Args = 11,
|
|
48
|
+
InvalidMathArgument = 12,
|
|
49
|
+
Requires2Args = 13,
|
|
50
|
+
BadIndex = 14,
|
|
51
|
+
TooComplex = 15,
|
|
52
|
+
CircularReference = 16,
|
|
53
|
+
MissingFormula = 17,
|
|
54
|
+
ImproperFormula = 18,
|
|
55
|
+
InvalidExpression = 19,
|
|
56
|
+
CellEmpty = 20,
|
|
57
|
+
BadFormula = 21,
|
|
58
|
+
EmptyExpression = 22,
|
|
59
|
+
VirtualModeRequired = 23,
|
|
60
|
+
MismatchedTics = 24,
|
|
61
|
+
WrongNumberArguments = 25,
|
|
62
|
+
InvalidArguments = 26,
|
|
63
|
+
IterationsDoNotConverge = 27,
|
|
64
|
+
CalculationOverflow = 29,
|
|
65
|
+
AlreadyRegistered = 28,
|
|
66
|
+
MissingSheet = 30,
|
|
67
|
+
CannotParse = 31,
|
|
68
|
+
ExpressionCannotEndWithAnOperator = 32,
|
|
69
|
+
Spill = 33,
|
|
70
|
+
Div = 34
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Excel file format extensions recognized by Calculate helpers.
|
|
74
|
+
*
|
|
75
|
+
* @hidden
|
|
76
|
+
*/
|
|
77
|
+
export declare enum ExcelFileFormats {
|
|
78
|
+
xlsx = "xlsx",
|
|
79
|
+
xlsm = "xlsm",
|
|
80
|
+
xlsb = "xlsb",
|
|
81
|
+
xltx = "xltx",
|
|
82
|
+
xltm = "xltm",
|
|
83
|
+
xls = "xls",
|
|
84
|
+
xml = "xml",
|
|
85
|
+
xlam = "xlam",
|
|
86
|
+
xla = "xla",
|
|
87
|
+
xlw = "xlw",
|
|
88
|
+
xlr = "xlr",
|
|
89
|
+
prn = "prn",
|
|
90
|
+
txt = "txt",
|
|
91
|
+
csv = "csv",
|
|
92
|
+
dif = "dif",
|
|
93
|
+
slk = "slk"
|
|
94
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Indexes into {@link Calculate.getErrorStrings} for Excel-compatible error tokens.
|
|
3
|
+
*
|
|
4
|
+
* @hidden
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* const na = engine.getErrorStrings()[CommonErrors.NA]; // '#N/A'
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
export var CommonErrors;
|
|
12
|
+
(function (CommonErrors) {
|
|
13
|
+
/** `#N/A` */
|
|
14
|
+
CommonErrors[CommonErrors["NA"] = 0] = "NA";
|
|
15
|
+
/** `#VALUE!` */
|
|
16
|
+
CommonErrors[CommonErrors["Value"] = 1] = "Value";
|
|
17
|
+
/** `#REF!` */
|
|
18
|
+
CommonErrors[CommonErrors["Ref"] = 2] = "Ref";
|
|
19
|
+
/** `#DIV/0!` */
|
|
20
|
+
CommonErrors[CommonErrors["DivZero"] = 3] = "DivZero";
|
|
21
|
+
/** `#NUM!` */
|
|
22
|
+
CommonErrors[CommonErrors["Num"] = 4] = "Num";
|
|
23
|
+
/** `#NAME?` */
|
|
24
|
+
CommonErrors[CommonErrors["Name"] = 5] = "Name";
|
|
25
|
+
/** `#NULL!` */
|
|
26
|
+
CommonErrors[CommonErrors["Null"] = 6] = "Null";
|
|
27
|
+
/** `#CALC!` */
|
|
28
|
+
CommonErrors[CommonErrors["Calc"] = 7] = "Calc";
|
|
29
|
+
})(CommonErrors || (CommonErrors = {}));
|
|
30
|
+
/**
|
|
31
|
+
* Indexes into {@link Calculate.formulaErrorStrings} for parser/engine failure messages.
|
|
32
|
+
*
|
|
33
|
+
* @hidden
|
|
34
|
+
*/
|
|
35
|
+
export var FormulasErrorsStrings;
|
|
36
|
+
(function (FormulasErrorsStrings) {
|
|
37
|
+
FormulasErrorsStrings[FormulasErrorsStrings["OperatorsCannotStartWithExpression"] = 0] = "OperatorsCannotStartWithExpression";
|
|
38
|
+
FormulasErrorsStrings[FormulasErrorsStrings["ReservedWordAND"] = 1] = "ReservedWordAND";
|
|
39
|
+
FormulasErrorsStrings[FormulasErrorsStrings["ReservedWordXOR"] = 2] = "ReservedWordXOR";
|
|
40
|
+
FormulasErrorsStrings[FormulasErrorsStrings["ReservedWordIf"] = 3] = "ReservedWordIf";
|
|
41
|
+
FormulasErrorsStrings[FormulasErrorsStrings["NumberContains2DecimalPoints"] = 4] = "NumberContains2DecimalPoints";
|
|
42
|
+
FormulasErrorsStrings[FormulasErrorsStrings["ReservedWordElse"] = 5] = "ReservedWordElse";
|
|
43
|
+
FormulasErrorsStrings[FormulasErrorsStrings["ReservedWordNOT"] = 6] = "ReservedWordNOT";
|
|
44
|
+
FormulasErrorsStrings[FormulasErrorsStrings["InvalidCharInNumber"] = 7] = "InvalidCharInNumber";
|
|
45
|
+
FormulasErrorsStrings[FormulasErrorsStrings["InvalidCharactersFollowingWithOperator"] = 6] = "InvalidCharactersFollowingWithOperator";
|
|
46
|
+
FormulasErrorsStrings[FormulasErrorsStrings["MismatchedParentheses"] = 8] = "MismatchedParentheses";
|
|
47
|
+
FormulasErrorsStrings[FormulasErrorsStrings["UnknownFormulaName"] = 9] = "UnknownFormulaName";
|
|
48
|
+
FormulasErrorsStrings[FormulasErrorsStrings["RequiresASingleArgument"] = 10] = "RequiresASingleArgument";
|
|
49
|
+
FormulasErrorsStrings[FormulasErrorsStrings["Requires3Args"] = 11] = "Requires3Args";
|
|
50
|
+
FormulasErrorsStrings[FormulasErrorsStrings["InvalidMathArgument"] = 12] = "InvalidMathArgument";
|
|
51
|
+
FormulasErrorsStrings[FormulasErrorsStrings["Requires2Args"] = 13] = "Requires2Args";
|
|
52
|
+
FormulasErrorsStrings[FormulasErrorsStrings["BadIndex"] = 14] = "BadIndex";
|
|
53
|
+
FormulasErrorsStrings[FormulasErrorsStrings["TooComplex"] = 15] = "TooComplex";
|
|
54
|
+
FormulasErrorsStrings[FormulasErrorsStrings["CircularReference"] = 16] = "CircularReference";
|
|
55
|
+
FormulasErrorsStrings[FormulasErrorsStrings["MissingFormula"] = 17] = "MissingFormula";
|
|
56
|
+
FormulasErrorsStrings[FormulasErrorsStrings["ImproperFormula"] = 18] = "ImproperFormula";
|
|
57
|
+
FormulasErrorsStrings[FormulasErrorsStrings["InvalidExpression"] = 19] = "InvalidExpression";
|
|
58
|
+
FormulasErrorsStrings[FormulasErrorsStrings["CellEmpty"] = 20] = "CellEmpty";
|
|
59
|
+
FormulasErrorsStrings[FormulasErrorsStrings["BadFormula"] = 21] = "BadFormula";
|
|
60
|
+
FormulasErrorsStrings[FormulasErrorsStrings["EmptyExpression"] = 22] = "EmptyExpression";
|
|
61
|
+
FormulasErrorsStrings[FormulasErrorsStrings["VirtualModeRequired"] = 23] = "VirtualModeRequired";
|
|
62
|
+
FormulasErrorsStrings[FormulasErrorsStrings["MismatchedTics"] = 24] = "MismatchedTics";
|
|
63
|
+
FormulasErrorsStrings[FormulasErrorsStrings["WrongNumberArguments"] = 25] = "WrongNumberArguments";
|
|
64
|
+
FormulasErrorsStrings[FormulasErrorsStrings["InvalidArguments"] = 26] = "InvalidArguments";
|
|
65
|
+
FormulasErrorsStrings[FormulasErrorsStrings["IterationsDoNotConverge"] = 27] = "IterationsDoNotConverge";
|
|
66
|
+
FormulasErrorsStrings[FormulasErrorsStrings["CalculationOverflow"] = 29] = "CalculationOverflow";
|
|
67
|
+
FormulasErrorsStrings[FormulasErrorsStrings["AlreadyRegistered"] = 28] = "AlreadyRegistered";
|
|
68
|
+
FormulasErrorsStrings[FormulasErrorsStrings["MissingSheet"] = 30] = "MissingSheet";
|
|
69
|
+
FormulasErrorsStrings[FormulasErrorsStrings["CannotParse"] = 31] = "CannotParse";
|
|
70
|
+
FormulasErrorsStrings[FormulasErrorsStrings["ExpressionCannotEndWithAnOperator"] = 32] = "ExpressionCannotEndWithAnOperator";
|
|
71
|
+
FormulasErrorsStrings[FormulasErrorsStrings["Spill"] = 33] = "Spill";
|
|
72
|
+
FormulasErrorsStrings[FormulasErrorsStrings["Div"] = 34] = "Div";
|
|
73
|
+
})(FormulasErrorsStrings || (FormulasErrorsStrings = {}));
|
|
74
|
+
/**
|
|
75
|
+
* Excel file format extensions recognized by Calculate helpers.
|
|
76
|
+
*
|
|
77
|
+
* @hidden
|
|
78
|
+
*/
|
|
79
|
+
export var ExcelFileFormats;
|
|
80
|
+
(function (ExcelFileFormats) {
|
|
81
|
+
ExcelFileFormats["xlsx"] = "xlsx";
|
|
82
|
+
ExcelFileFormats["xlsm"] = "xlsm";
|
|
83
|
+
ExcelFileFormats["xlsb"] = "xlsb";
|
|
84
|
+
ExcelFileFormats["xltx"] = "xltx";
|
|
85
|
+
ExcelFileFormats["xltm"] = "xltm";
|
|
86
|
+
ExcelFileFormats["xls"] = "xls";
|
|
87
|
+
ExcelFileFormats["xml"] = "xml";
|
|
88
|
+
ExcelFileFormats["xlam"] = "xlam";
|
|
89
|
+
ExcelFileFormats["xla"] = "xla";
|
|
90
|
+
ExcelFileFormats["xlw"] = "xlw";
|
|
91
|
+
ExcelFileFormats["xlr"] = "xlr";
|
|
92
|
+
ExcelFileFormats["prn"] = "prn";
|
|
93
|
+
ExcelFileFormats["txt"] = "txt";
|
|
94
|
+
ExcelFileFormats["csv"] = "csv";
|
|
95
|
+
ExcelFileFormats["dif"] = "dif";
|
|
96
|
+
ExcelFileFormats["slk"] = "slk";
|
|
97
|
+
})(ExcelFileFormats || (ExcelFileFormats = {}));
|