@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.
Files changed (173) hide show
  1. package/.eslintrc.json +263 -0
  2. package/README.md +132 -0
  3. package/base.d.ts +4 -0
  4. package/base.js +4 -0
  5. package/common.d.ts +4 -0
  6. package/common.js +4 -0
  7. package/dist/ej2-calculate.umd.min.js +11 -0
  8. package/dist/ej2-calculate.umd.min.js.map +1 -0
  9. package/dist/es6/ej2-calculate.es2015.js +24801 -0
  10. package/dist/es6/ej2-calculate.es2015.js.map +1 -0
  11. package/dist/es6/ej2-calculate.es5.js +27229 -0
  12. package/dist/es6/ej2-calculate.es5.js.map +1 -0
  13. package/dist/global/ej2-calculate.min.js +11 -0
  14. package/dist/global/ej2-calculate.min.js.map +1 -0
  15. package/dist/global/index.d.ts +14 -0
  16. package/formulas.d.ts +4 -0
  17. package/formulas.js +4 -0
  18. package/index.d.ts +4 -0
  19. package/index.js +4 -0
  20. package/license +10 -0
  21. package/package.json +30 -0
  22. package/src/base/calculate-model.d.ts +4 -0
  23. package/src/base/calculate-model.js +0 -0
  24. package/src/base/calculate.d.ts +1105 -0
  25. package/src/base/calculate.js +4720 -0
  26. package/src/base/index.d.ts +8 -0
  27. package/src/base/index.js +7 -0
  28. package/src/base/parser.d.ts +208 -0
  29. package/src/base/parser.js +1512 -0
  30. package/src/common/address.d.ts +59 -0
  31. package/src/common/address.js +96 -0
  32. package/src/common/cell-ref.d.ts +32 -0
  33. package/src/common/cell-ref.js +112 -0
  34. package/src/common/common.d.ts +44 -0
  35. package/src/common/common.js +134 -0
  36. package/src/common/enum.d.ts +94 -0
  37. package/src/common/enum.js +97 -0
  38. package/src/common/index.d.ts +9 -0
  39. package/src/common/index.js +8 -0
  40. package/src/common/interface.d.ts +122 -0
  41. package/src/common/interface.js +0 -0
  42. package/src/common/l10n.d.ts +24 -0
  43. package/src/common/l10n.js +54 -0
  44. package/src/common/number-date.d.ts +26 -0
  45. package/src/common/number-date.js +38 -0
  46. package/src/common/sheet-info.d.ts +10 -0
  47. package/src/common/sheet-info.js +17 -0
  48. package/src/common/sort.d.ts +17 -0
  49. package/src/common/sort.js +44 -0
  50. package/src/formulas/array.d.ts +47 -0
  51. package/src/formulas/array.js +718 -0
  52. package/src/formulas/basic.d.ts +47 -0
  53. package/src/formulas/basic.js +181 -0
  54. package/src/formulas/complex-numbers.d.ts +207 -0
  55. package/src/formulas/complex-numbers.js +549 -0
  56. package/src/formulas/database.d.ts +152 -0
  57. package/src/formulas/database.js +579 -0
  58. package/src/formulas/date-time-extra.d.ts +97 -0
  59. package/src/formulas/date-time-extra.js +415 -0
  60. package/src/formulas/date-time-intl.d.ts +57 -0
  61. package/src/formulas/date-time-intl.js +309 -0
  62. package/src/formulas/date-time.d.ts +164 -0
  63. package/src/formulas/date-time.js +1021 -0
  64. package/src/formulas/engineering-base.d.ts +150 -0
  65. package/src/formulas/engineering-base.js +404 -0
  66. package/src/formulas/engineering-bessel.d.ts +65 -0
  67. package/src/formulas/engineering-bessel.js +167 -0
  68. package/src/formulas/engineering-convert.d.ts +35 -0
  69. package/src/formulas/engineering-convert.js +120 -0
  70. package/src/formulas/engineering-misc.d.ts +64 -0
  71. package/src/formulas/engineering-misc.js +168 -0
  72. package/src/formulas/financial-amortization-ecma.d.ts +87 -0
  73. package/src/formulas/financial-amortization-ecma.js +288 -0
  74. package/src/formulas/financial-annuity.d.ts +104 -0
  75. package/src/formulas/financial-annuity.js +419 -0
  76. package/src/formulas/financial-bond-helpers.d.ts +106 -0
  77. package/src/formulas/financial-bond-helpers.js +190 -0
  78. package/src/formulas/financial-cashflow.d.ts +47 -0
  79. package/src/formulas/financial-cashflow.js +203 -0
  80. package/src/formulas/financial-coupons.d.ts +227 -0
  81. package/src/formulas/financial-coupons.js +810 -0
  82. package/src/formulas/financial-depreciation.d.ts +64 -0
  83. package/src/formulas/financial-depreciation.js +247 -0
  84. package/src/formulas/financial-rates.d.ts +54 -0
  85. package/src/formulas/financial-rates.js +140 -0
  86. package/src/formulas/financial-securities.d.ts +126 -0
  87. package/src/formulas/financial-securities.js +488 -0
  88. package/src/formulas/formula-math-helpers.d.ts +212 -0
  89. package/src/formulas/formula-math-helpers.js +599 -0
  90. package/src/formulas/formula-module-base.d.ts +54 -0
  91. package/src/formulas/formula-module-base.js +125 -0
  92. package/src/formulas/formula-owner.d.ts +17 -0
  93. package/src/formulas/formula-owner.js +0 -0
  94. package/src/formulas/index.d.ts +68 -0
  95. package/src/formulas/index.js +67 -0
  96. package/src/formulas/information-advanced.d.ts +44 -0
  97. package/src/formulas/information-advanced.js +157 -0
  98. package/src/formulas/information-ecma.d.ts +33 -0
  99. package/src/formulas/information-ecma.js +88 -0
  100. package/src/formulas/information-extra.d.ts +146 -0
  101. package/src/formulas/information-extra.js +351 -0
  102. package/src/formulas/information.d.ts +34 -0
  103. package/src/formulas/information.js +78 -0
  104. package/src/formulas/logical-extra.d.ts +75 -0
  105. package/src/formulas/logical-extra.js +217 -0
  106. package/src/formulas/logical.d.ts +83 -0
  107. package/src/formulas/logical.js +296 -0
  108. package/src/formulas/lookup-array.d.ts +98 -0
  109. package/src/formulas/lookup-array.js +364 -0
  110. package/src/formulas/lookup-ref-extra.d.ts +64 -0
  111. package/src/formulas/lookup-ref-extra.js +180 -0
  112. package/src/formulas/lookup-ref.d.ts +84 -0
  113. package/src/formulas/lookup-ref.js +263 -0
  114. package/src/formulas/lookup.d.ts +114 -0
  115. package/src/formulas/lookup.js +881 -0
  116. package/src/formulas/math-aggregate.d.ts +74 -0
  117. package/src/formulas/math-aggregate.js +376 -0
  118. package/src/formulas/math-ceiling-ecma.d.ts +42 -0
  119. package/src/formulas/math-ceiling-ecma.js +123 -0
  120. package/src/formulas/math-combinatorics.d.ts +75 -0
  121. package/src/formulas/math-combinatorics.js +290 -0
  122. package/src/formulas/math-misc.d.ts +164 -0
  123. package/src/formulas/math-misc.js +889 -0
  124. package/src/formulas/math-number.d.ts +76 -0
  125. package/src/formulas/math-number.js +261 -0
  126. package/src/formulas/math-rounding.d.ts +115 -0
  127. package/src/formulas/math-rounding.js +728 -0
  128. package/src/formulas/math-trig-hyperbolic.d.ts +55 -0
  129. package/src/formulas/math-trig-hyperbolic.js +113 -0
  130. package/src/formulas/math-trig.d.ts +165 -0
  131. package/src/formulas/math-trig.js +334 -0
  132. package/src/formulas/matrix-base.d.ts +13 -0
  133. package/src/formulas/matrix-base.js +169 -0
  134. package/src/formulas/matrix.d.ts +64 -0
  135. package/src/formulas/matrix.js +161 -0
  136. package/src/formulas/regression-ecma.d.ts +66 -0
  137. package/src/formulas/regression-ecma.js +234 -0
  138. package/src/formulas/statistical-advanced.d.ts +125 -0
  139. package/src/formulas/statistical-advanced.js +756 -0
  140. package/src/formulas/statistical-correlation.d.ts +75 -0
  141. package/src/formulas/statistical-correlation.js +198 -0
  142. package/src/formulas/statistical-dispersion.d.ts +108 -0
  143. package/src/formulas/statistical-dispersion.js +337 -0
  144. package/src/formulas/statistical-distribution-extended.d.ts +176 -0
  145. package/src/formulas/statistical-distribution-extended.js +668 -0
  146. package/src/formulas/statistical-distribution.d.ts +104 -0
  147. package/src/formulas/statistical-distribution.js +368 -0
  148. package/src/formulas/statistical-ecma.d.ts +95 -0
  149. package/src/formulas/statistical-ecma.js +392 -0
  150. package/src/formulas/statistical-extended.d.ts +136 -0
  151. package/src/formulas/statistical-extended.js +340 -0
  152. package/src/formulas/statistical-ifs.d.ts +46 -0
  153. package/src/formulas/statistical-ifs.js +180 -0
  154. package/src/formulas/statistical-moments.d.ts +84 -0
  155. package/src/formulas/statistical-moments.js +269 -0
  156. package/src/formulas/statistical-percentile.d.ts +56 -0
  157. package/src/formulas/statistical-percentile.js +195 -0
  158. package/src/formulas/statistical-sample-base.d.ts +14 -0
  159. package/src/formulas/statistical-sample-base.js +124 -0
  160. package/src/formulas/statistical.d.ts +135 -0
  161. package/src/formulas/statistical.js +542 -0
  162. package/src/formulas/text-advanced.d.ts +64 -0
  163. package/src/formulas/text-advanced.js +222 -0
  164. package/src/formulas/text-ecma.d.ts +54 -0
  165. package/src/formulas/text-ecma.js +106 -0
  166. package/src/formulas/text-extra.d.ts +216 -0
  167. package/src/formulas/text-extra.js +657 -0
  168. package/src/formulas/text.d.ts +125 -0
  169. package/src/formulas/text.js +628 -0
  170. package/src/global.js +1 -0
  171. package/src/index.d.ts +14 -0
  172. package/src/index.js +14 -0
  173. package/tslint.json +111 -0
@@ -0,0 +1,74 @@
1
+ import { IBasicFormula } from '../common/index';
2
+ import { FormulaOwner } from './formula-owner';
3
+ import { FormulaModuleBase } from './formula-module-base';
4
+ /**
5
+ * Aggregation functions that summarize ranges of numeric values (sums, counts, products, and conditional totals).
6
+ *
7
+ * Registered functions: SUM, SUMIF, SUMIFS, SUMPRODUCT, PRODUCT.
8
+ *
9
+ * @hidden
10
+ */
11
+ export declare class MathAggregateFormulas 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
+ * Sums individual values, cell references or ranges.
21
+ *
22
+ * Excel: `SUM(...)`.
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('=SUM(A1:A3)');
31
+ * ```
32
+ */
33
+ ComputeSUM(...args: string[]): string | number;
34
+ /**
35
+ * It will sum up cells that meet the given criteria.
36
+ *
37
+ * Excel: `SUMIF(...)`.
38
+ *
39
+ * @hidden
40
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
41
+ * @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
42
+ */
43
+ ComputeSUMIF(...args: string[]): string | number;
44
+ /**
45
+ * Sums the cells specified by a given set of conditionsor criteria.
46
+ *
47
+ * Excel: `SUMIFS(...)`.
48
+ *
49
+ * @hidden
50
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
51
+ * @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
52
+ */
53
+ ComputeSUMIFS(...args: string[]): string | number;
54
+ /**
55
+ * Returns sum of the product of given ranges of arrays.
56
+ *
57
+ * Excel: `SUMPRODUCT(...)`.
58
+ *
59
+ * @hidden
60
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
61
+ * @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
62
+ */
63
+ ComputeSUMPRODUCT(...args: string[]): string | number;
64
+ /**
65
+ * Multiplies all the numbers given as arguments and returns the product.
66
+ *
67
+ * Excel: `PRODUCT(...)`.
68
+ *
69
+ * @hidden
70
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
71
+ * @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
72
+ */
73
+ ComputePRODUCT(...args: string[]): string | number;
74
+ }
@@ -0,0 +1,376 @@
1
+ var __extends = (this && this.__extends) || (function () {
2
+ var extendStatics = function (d, b) {
3
+ extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6
+ return extendStatics(d, b);
7
+ };
8
+ return function (d, b) {
9
+ extendStatics(d, b);
10
+ function __() { this.constructor = d; }
11
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12
+ };
13
+ })();
14
+ import { FormulasErrorsStrings, CommonErrors } from '../common/index';
15
+ import { isNullOrUndefined } from '@syncfusion/ej2-base';
16
+ import { isNumber } from '../common/number-date';
17
+ import { FormulaModuleBase } from './formula-module-base';
18
+ /**
19
+ * Aggregation functions that summarize ranges of numeric values (sums, counts, products, and conditional totals).
20
+ *
21
+ * Registered functions: SUM, SUMIF, SUMIFS, SUMPRODUCT, PRODUCT.
22
+ *
23
+ * @hidden
24
+ */
25
+ var MathAggregateFormulas = /** @class */ (function (_super) {
26
+ __extends(MathAggregateFormulas, _super);
27
+ /**
28
+ * @hidden
29
+ * @param {FormulaOwner} owner - Formula registration owner ({@link BasicFormulas}).
30
+ */
31
+ function MathAggregateFormulas(owner) {
32
+ var _this = _super.call(this, owner) || this;
33
+ /** Formula definitions registered with {@link BasicFormulas}. */
34
+ _this.formulas = [
35
+ { formulaName: 'SUM', category: 'Math & Trig', description: 'Sums individual values, cell references or ranges.' },
36
+ { formulaName: 'SUMIF', category: 'Math & Trig', description: 'It will sum up cells that meet the given criteria.' },
37
+ { formulaName: 'SUMIFS', category: 'Math & Trig', description: 'Sums the cells specified by a given set of conditionsor criteria.' },
38
+ { formulaName: 'SUMPRODUCT', category: 'Math & Trig', description: 'Returns sum of the product of given ranges of arrays.' },
39
+ { formulaName: 'PRODUCT', category: 'Math & Trig', description: 'Multiplies all the numbers given as arguments and returns the product.' }
40
+ ];
41
+ return _this;
42
+ }
43
+ /**
44
+ * Sums individual values, cell references or ranges.
45
+ *
46
+ * Excel: `SUM(...)`.
47
+ *
48
+ * @hidden
49
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
50
+ * @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
51
+ *
52
+ * @example
53
+ * ```ts
54
+ * engine.computeFormula('=SUM(A1:A3)');
55
+ * ```
56
+ */
57
+ MathAggregateFormulas.prototype.ComputeSUM = function () {
58
+ var args = [];
59
+ for (var _i = 0; _i < arguments.length; _i++) {
60
+ args[_i] = arguments[_i];
61
+ }
62
+ var isSubtotalFormula = false;
63
+ if (args.length) {
64
+ var lastArgument = args[args.length - 1];
65
+ if (lastArgument === 'isSubtotal') {
66
+ isSubtotalFormula = true;
67
+ args.pop();
68
+ }
69
+ }
70
+ if (isNullOrUndefined(args) || (args.length === 1 && args[0] === '')) {
71
+ return this.parent.formulaErrorStrings[FormulasErrorsStrings.InvalidArguments];
72
+ }
73
+ var sum = 0;
74
+ var val;
75
+ var orgValue;
76
+ var maxDecimalLength = 0;
77
+ if (!isNullOrUndefined(args)) {
78
+ var argArr = args;
79
+ var setMaxDecimalLength = function (val) {
80
+ if (val.toString().indexOf('.') > -1) {
81
+ maxDecimalLength = Math.max(maxDecimalLength, val.split('.')[1].length);
82
+ }
83
+ };
84
+ for (var i = 0; i < argArr.length; i++) {
85
+ var argValue = argArr[i].toString();
86
+ if (argValue.indexOf(':') > -1 && this.parent.isCellReference(argValue)) {
87
+ var cellCollection = this.parent.getCellCollection(argValue.split(this.parent.tic).join(''));
88
+ for (var j = 0; j < cellCollection.length; j++) {
89
+ val = !isSubtotalFormula ? this.parent.getValueFromArg(cellCollection[j]) :
90
+ this.parent.getValueFromArg(cellCollection[j], null, null, true);
91
+ if (isSubtotalFormula && val.includes('SUBTOTAL(')) {
92
+ continue;
93
+ }
94
+ if (this.parent.getErrorStrings().indexOf(val) > -1) {
95
+ return val;
96
+ }
97
+ if (isNullOrUndefined(val[0]) || isNaN(this.parent.parseFloat(val))) {
98
+ continue;
99
+ }
100
+ setMaxDecimalLength(val);
101
+ sum = sum + this.parent.parseFloat(val);
102
+ }
103
+ }
104
+ else {
105
+ if (argArr[i].indexOf(this.parent.tic) > -1) {
106
+ if (isNaN(this.parent.parseFloat(argArr[i].split(this.parent.tic).join(''))) ||
107
+ argArr[i].split(this.parent.tic).join('').trim() === '') {
108
+ return this.parent.getErrorStrings()[CommonErrors.Value];
109
+ }
110
+ }
111
+ if (argArr[i].split(this.parent.tic).join('') === this.parent.trueValue) {
112
+ argArr[i] = '1';
113
+ }
114
+ if (argArr[i].split(this.parent.tic).join('') === this.parent.falseValue) {
115
+ argArr[i] = '0';
116
+ }
117
+ orgValue = !isSubtotalFormula ? this.parent.getValueFromArg(argArr[i].split(this.parent.tic).join('')) :
118
+ this.parent.getValueFromArg(argArr[i].split(this.parent.tic).join(''), null, null, true);
119
+ if (isSubtotalFormula && orgValue.includes('SUBTOTAL(')) {
120
+ continue;
121
+ }
122
+ if (this.parent.getErrorStrings().indexOf(orgValue) > -1) {
123
+ return orgValue;
124
+ }
125
+ if (isNullOrUndefined(orgValue) || isNaN(this.parent.parseFloat(orgValue))) {
126
+ continue;
127
+ }
128
+ if (orgValue.length > 0) {
129
+ setMaxDecimalLength(orgValue);
130
+ sum = sum + this.parent.parseFloat(orgValue + '');
131
+ }
132
+ }
133
+ }
134
+ }
135
+ return sum.toString().indexOf('.') > -1 ? sum.toFixed(maxDecimalLength) : sum;
136
+ };
137
+ /**
138
+ * It will sum up cells that meet the given criteria.
139
+ *
140
+ * Excel: `SUMIF(...)`.
141
+ *
142
+ * @hidden
143
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
144
+ * @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
145
+ */
146
+ MathAggregateFormulas.prototype.ComputeSUMIF = function () {
147
+ var args = [];
148
+ for (var _i = 0; _i < arguments.length; _i++) {
149
+ args[_i] = arguments[_i];
150
+ }
151
+ var argArr = args;
152
+ if (argArr[0].indexOf(':') < 0 && !this.parent.isCellReference(argArr[0]) ||
153
+ (argArr[2] && argArr[2].indexOf(':') < 0 && !this.parent.isCellReference(argArr[2]))) {
154
+ return this.parent.formulaErrorStrings[FormulasErrorsStrings.ImproperFormula];
155
+ }
156
+ if (argArr.length > 3 || argArr.length < 2) {
157
+ return this.parent.formulaErrorStrings[FormulasErrorsStrings.WrongNumberArguments];
158
+ }
159
+ var result = this.parent.computeSumIfAndAvgIf(args, false);
160
+ if (typeof result === 'string' && (this.parent.formulaErrorStrings.indexOf(result)
161
+ || this.parent.getErrorStrings().indexOf(result))) {
162
+ return result;
163
+ }
164
+ return result[0];
165
+ };
166
+ /**
167
+ * Sums the cells specified by a given set of conditionsor criteria.
168
+ *
169
+ * Excel: `SUMIFS(...)`.
170
+ *
171
+ * @hidden
172
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
173
+ * @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
174
+ */
175
+ MathAggregateFormulas.prototype.ComputeSUMIFS = function () {
176
+ var args = [];
177
+ for (var _i = 0; _i < arguments.length; _i++) {
178
+ args[_i] = arguments[_i];
179
+ }
180
+ var sum = this.calculateIFS(args);
181
+ return sum;
182
+ };
183
+ /**
184
+ * Returns sum of the product of given ranges of arrays.
185
+ *
186
+ * Excel: `SUMPRODUCT(...)`.
187
+ *
188
+ * @hidden
189
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
190
+ * @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
191
+ */
192
+ MathAggregateFormulas.prototype.ComputeSUMPRODUCT = function () {
193
+ var args = [];
194
+ for (var _i = 0; _i < arguments.length; _i++) {
195
+ args[_i] = arguments[_i];
196
+ }
197
+ var _a, _b;
198
+ if (isNullOrUndefined(args) || (args.length === 1 && args[0] === '')) {
199
+ return this.parent.formulaErrorStrings[FormulasErrorsStrings.InvalidArguments];
200
+ }
201
+ var sum = 0;
202
+ var count = 0;
203
+ var index;
204
+ var mulValues = null;
205
+ var ranges = args;
206
+ var len = [];
207
+ for (var i = 0; i < ranges.length; i++) {
208
+ var cells = this.parent.getCellCollection(ranges[i]);
209
+ if (cells[0] === '#REF!') {
210
+ return this.parent.getErrorStrings()[CommonErrors.Name];
211
+ }
212
+ len.push(cells.length);
213
+ }
214
+ for (var j = 0; j < len.length; j++) {
215
+ if (len[j] && len[j + 1] && len[j] !== len[j + 1]) {
216
+ return this.parent.getErrorStrings()[CommonErrors.Value];
217
+ }
218
+ }
219
+ for (var k = 0; k < ranges.length; ++k) {
220
+ var range = ranges[k];
221
+ if (!range.startsWith(this.parent.tic) && this.parent.isCellReference(range)) {
222
+ var i = range.indexOf(':');
223
+ var startRow = this.parent.rowIndex(range.substr(0, i));
224
+ var endRow = this.parent.rowIndex(range.substr(i + 1));
225
+ if (!(startRow !== -1 || endRow === -1) === (startRow === -1 || endRow !== -1)) {
226
+ return this.parent.getErrorStrings()[CommonErrors.Name];
227
+ }
228
+ if (startRow > endRow) {
229
+ _a = [endRow, startRow], startRow = _a[0], endRow = _a[1];
230
+ }
231
+ var col1 = this.parent.colIndex(range.substr(0, i));
232
+ var col2 = this.parent.colIndex(range.substr(i + 1));
233
+ if (col1 > col2) {
234
+ _b = [col2, col1], col1 = _b[0], col2 = _b[1];
235
+ }
236
+ if (mulValues === null) {
237
+ count = (endRow - startRow + 1) * (col2 - col1 + 1);
238
+ mulValues = [];
239
+ for (i = 0; i < count; ++i) {
240
+ mulValues[i] = 1; //To create required index.
241
+ }
242
+ }
243
+ i = 0;
244
+ for (var row = startRow; row <= endRow; ++row) {
245
+ for (var col = col1; col <= col2; ++col) {
246
+ var cellRef = this.getSheetReference(range) + this.parent.convertAlpha(col) + (row);
247
+ var result = this.parent.getValueFromArg(cellRef);
248
+ if (this.parent.getErrorStrings().indexOf(result) > -1) {
249
+ return result;
250
+ }
251
+ if (!isNaN(this.parent.parseFloat(result))) {
252
+ //To return #VALUE! error when array dimensions are mismatched.
253
+ if (isNaN(mulValues[i])) {
254
+ return this.parent.getErrorStrings()[CommonErrors.Name];
255
+ }
256
+ mulValues[i] = mulValues[i] * this.parent.parseFloat(result);
257
+ }
258
+ else {
259
+ mulValues[i] = 0;
260
+ }
261
+ i++;
262
+ }
263
+ }
264
+ }
265
+ else {
266
+ var s1 = this.parent.getValueFromArg(range);
267
+ index = s1.indexOf('"');
268
+ if (this.parent.getErrorStrings().indexOf(s1) > -1) {
269
+ return s1;
270
+ }
271
+ else if (index > -1) {
272
+ return 0;
273
+ }
274
+ else {
275
+ return this.parent.getErrorStrings()[CommonErrors.Value];
276
+ }
277
+ }
278
+ }
279
+ for (var i = 0; i < count; ++i) {
280
+ sum += mulValues[i];
281
+ }
282
+ return sum;
283
+ };
284
+ /**
285
+ * Multiplies all the numbers given as arguments and returns the product.
286
+ *
287
+ * Excel: `PRODUCT(...)`.
288
+ *
289
+ * @hidden
290
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
291
+ * @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
292
+ */
293
+ MathAggregateFormulas.prototype.ComputePRODUCT = function () {
294
+ var args = [];
295
+ for (var _i = 0; _i < arguments.length; _i++) {
296
+ args[_i] = arguments[_i];
297
+ }
298
+ var isSubtotalFormula = false;
299
+ if (args.length && args[args.length - 1] === 'isSubtotal') {
300
+ isSubtotalFormula = true;
301
+ args.pop();
302
+ }
303
+ if (isNullOrUndefined(args) || (args.length === 1 && args[0] === '')) {
304
+ return this.parent.formulaErrorStrings[FormulasErrorsStrings.InvalidArguments];
305
+ }
306
+ var product = 1;
307
+ var val;
308
+ var orgValue;
309
+ var argsHit = true;
310
+ var parseVal;
311
+ if (!isNullOrUndefined(args)) {
312
+ var argArr = args;
313
+ for (var i = 0; i < argArr.length; i++) {
314
+ var rangevalue = argArr[i];
315
+ if (rangevalue.indexOf(':') > -1 && this.parent.isCellReference(rangevalue)) {
316
+ var cellCollection = this.parent.getCellCollection(rangevalue);
317
+ for (var j = 0; j < cellCollection.length; j++) {
318
+ val = !isSubtotalFormula ? this.parent.getValueFromArg(cellCollection[j]) :
319
+ this.parent.getValueFromArg(cellCollection[j], null, null, true);
320
+ if (isSubtotalFormula && val.includes('SUBTOTAL(')) {
321
+ continue;
322
+ }
323
+ if (!isNumber(val)) {
324
+ continue;
325
+ }
326
+ if (this.parent.getErrorStrings().indexOf(val) > -1) {
327
+ return val;
328
+ }
329
+ parseVal = this.parent.parseFloat(val);
330
+ if (!isNaN(parseVal)) {
331
+ if (val.length > 0) {
332
+ product = product * parseVal;
333
+ argsHit = false;
334
+ }
335
+ }
336
+ }
337
+ }
338
+ else if (rangevalue.indexOf(':') === -1 && this.parent.isCellReference(rangevalue)) {
339
+ orgValue = !isSubtotalFormula ? this.parent.getValueFromArg(argArr[i]) :
340
+ this.parent.getValueFromArg(argArr[i], null, null, true);
341
+ if (isSubtotalFormula && orgValue.includes('SUBTOTAL(')) {
342
+ continue;
343
+ }
344
+ if (!isNumber(orgValue)) {
345
+ continue;
346
+ }
347
+ if (this.parent.getErrorStrings().indexOf(orgValue) > -1) {
348
+ return orgValue;
349
+ }
350
+ }
351
+ else {
352
+ orgValue = argArr[i];
353
+ var isEmptyStr = orgValue.indexOf(this.parent.tic) > -1 && orgValue.split(this.parent.tic).join('').trim() === '';
354
+ if (isEmptyStr || (argArr[i].indexOf(this.parent.tic) > -1 && isNaN(this.parent.parseFloat(orgValue.split(this.parent.tic).join(''))))) {
355
+ return this.parent.getErrorStrings()[CommonErrors.Value];
356
+ }
357
+ orgValue = this.parent.getValueFromArg(argArr[i].split(this.parent.tic).join(''));
358
+ orgValue = (orgValue === this.parent.trueValue) ? '1' : (orgValue === this.parent.falseValue) ? '0' : orgValue.split(this.parent.tic).join('');
359
+ if (this.parent.getErrorStrings().indexOf(orgValue) > -1) {
360
+ return orgValue;
361
+ }
362
+ }
363
+ parseVal = this.parent.parseFloat(orgValue);
364
+ if (!isNaN(parseVal)) {
365
+ if (orgValue.length > 0) {
366
+ product = product * parseVal;
367
+ argsHit = false;
368
+ }
369
+ }
370
+ }
371
+ }
372
+ return argsHit ? '0' : product.toString();
373
+ };
374
+ return MathAggregateFormulas;
375
+ }(FormulaModuleBase));
376
+ export { MathAggregateFormulas };
@@ -0,0 +1,42 @@
1
+ import { IBasicFormula } from '../common/index';
2
+ import { FormulaOwner } from './formula-owner';
3
+ import { FormulaModuleBase } from './formula-module-base';
4
+ /**
5
+ * ECMA-376 ceiling rounding variants (ISO.CEILING and ECMA.CEILING) with significance-based rounding rules.
6
+ *
7
+ * Registered functions: ISO.CEILING, ECMA.CEILING.
8
+ *
9
+ * @hidden
10
+ */
11
+ export declare class MathCeilingEcmaFormulas 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
+ * Rounds a number up to the nearest integer or multiple of significance.
21
+ *
22
+ * Excel: `ISO.CEILING(...)`.
23
+ *
24
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
25
+ * @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
26
+ *
27
+ * @example
28
+ * ```ts
29
+ * engine.computeFormula('=ISO.CEILING(1)');
30
+ * ```
31
+ */
32
+ ['ComputeISO.CEILING'](...args: string[]): string | number;
33
+ /**
34
+ * Rounds a number up, away from zero, to the nearest multiple of significance.
35
+ *
36
+ * Excel: `ECMA.CEILING(...)`.
37
+ *
38
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
39
+ * @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
40
+ */
41
+ ['ComputeECMA.CEILING'](...args: string[]): string | number;
42
+ }
@@ -0,0 +1,123 @@
1
+ var __extends = (this && this.__extends) || (function () {
2
+ var extendStatics = function (d, b) {
3
+ extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6
+ return extendStatics(d, b);
7
+ };
8
+ return function (d, b) {
9
+ extendStatics(d, b);
10
+ function __() { this.constructor = d; }
11
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12
+ };
13
+ })();
14
+ import { FormulasErrorsStrings, CommonErrors } from '../common/index';
15
+ import { isNullOrUndefined } from '@syncfusion/ej2-base';
16
+ import { FormulaModuleBase } from './formula-module-base';
17
+ /**
18
+ * ECMA-376 ceiling rounding variants (ISO.CEILING and ECMA.CEILING) with significance-based rounding rules.
19
+ *
20
+ * Registered functions: ISO.CEILING, ECMA.CEILING.
21
+ *
22
+ * @hidden
23
+ */
24
+ var MathCeilingEcmaFormulas = /** @class */ (function (_super) {
25
+ __extends(MathCeilingEcmaFormulas, _super);
26
+ /**
27
+ * @hidden
28
+ * @param {FormulaOwner} owner - Formula registration owner ({@link BasicFormulas}).
29
+ */
30
+ function MathCeilingEcmaFormulas(owner) {
31
+ var _this = _super.call(this, owner) || this;
32
+ /** Formula definitions registered with {@link BasicFormulas}. */
33
+ _this.formulas = [
34
+ { formulaName: 'ISO.CEILING', category: 'Math & Trig', description: 'Rounds a number up to the nearest integer or multiple of significance.' },
35
+ { formulaName: 'ECMA.CEILING', category: 'Math & Trig', description: 'Rounds a number up, away from zero, to the nearest multiple of significance.' }
36
+ ];
37
+ return _this;
38
+ }
39
+ /**
40
+ * Rounds a number up to the nearest integer or multiple of significance.
41
+ *
42
+ * Excel: `ISO.CEILING(...)`.
43
+ *
44
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
45
+ * @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
46
+ *
47
+ * @example
48
+ * ```ts
49
+ * engine.computeFormula('=ISO.CEILING(1)');
50
+ * ```
51
+ */
52
+ MathCeilingEcmaFormulas.prototype['ComputeISO.CEILING'] = function () {
53
+ var args = [];
54
+ for (var _i = 0; _i < arguments.length; _i++) {
55
+ args[_i] = arguments[_i];
56
+ }
57
+ if (isNullOrUndefined(args) || args.length < 1 || args.length > 2) {
58
+ return this.parent.formulaErrorStrings[FormulasErrorsStrings.WrongNumberArguments];
59
+ }
60
+ var x = this.resolveNumberArg(args[0]);
61
+ if (typeof x === 'string') {
62
+ return x;
63
+ }
64
+ var sig = 1;
65
+ if (args.length === 2 && args[1] !== '') {
66
+ var s = this.resolveNumberArg(args[1]);
67
+ if (typeof s === 'string') {
68
+ return s;
69
+ }
70
+ sig = Math.abs(s);
71
+ }
72
+ if (x === 0 || sig === 0) {
73
+ return '0';
74
+ }
75
+ var result = Math.ceil(x / sig) * sig;
76
+ return result.toString();
77
+ };
78
+ /**
79
+ * Rounds a number up, away from zero, to the nearest multiple of significance.
80
+ *
81
+ * Excel: `ECMA.CEILING(...)`.
82
+ *
83
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
84
+ * @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
85
+ */
86
+ MathCeilingEcmaFormulas.prototype['ComputeECMA.CEILING'] = function () {
87
+ var args = [];
88
+ for (var _i = 0; _i < arguments.length; _i++) {
89
+ args[_i] = arguments[_i];
90
+ }
91
+ var errCollection = this.parent.getErrorStrings();
92
+ if (isNullOrUndefined(args) || args.length !== 2) {
93
+ return this.parent.formulaErrorStrings[FormulasErrorsStrings.WrongNumberArguments];
94
+ }
95
+ var x = this.resolveNumberArg(args[0]);
96
+ var sig = this.resolveNumberArg(args[1]);
97
+ if (typeof x === 'string') {
98
+ return x;
99
+ }
100
+ if (typeof sig === 'string') {
101
+ return sig;
102
+ }
103
+ if (x === 0 || sig === 0) {
104
+ return '0';
105
+ }
106
+ if (x > 0 && sig < 0) {
107
+ return errCollection[CommonErrors.Num];
108
+ }
109
+ var result;
110
+ if (x > 0) {
111
+ result = Math.ceil(x / sig) * sig;
112
+ }
113
+ else if (sig > 0) {
114
+ result = Math.ceil(x / sig) * sig;
115
+ }
116
+ else {
117
+ result = Math.floor(x / sig) * sig;
118
+ }
119
+ return result.toString();
120
+ };
121
+ return MathCeilingEcmaFormulas;
122
+ }(FormulaModuleBase));
123
+ export { MathCeilingEcmaFormulas };