@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,64 @@
1
+ import { IBasicFormula } from '../common/index';
2
+ import { FormulaOwner } from './formula-owner';
3
+ import { FormulaModuleBase } from './formula-module-base';
4
+ /**
5
+ * Advanced text parsing, regex-style extraction, and structured text transforms.
6
+ *
7
+ * Registered functions: ASC, TEXTBEFORE, VALUETOTEXT, ARRAYTOTEXT.
8
+ *
9
+ * @hidden
10
+ */
11
+ export declare class TextAdvancedFormulas 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
+ * Changes full-width characters to half-width.
21
+ *
22
+ * Excel: `ASC(...)`.
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('=ASC(1)');
31
+ * ```
32
+ */
33
+ ComputeASC(...args: string[]): string | number;
34
+ /**
35
+ * Returns text before a given character or string.
36
+ *
37
+ * Excel: `TEXTBEFORE(...)`.
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
+ ComputeTEXTBEFORE(...args: string[]): string | number;
44
+ /**
45
+ * Returns text from any specified value.
46
+ *
47
+ * Excel: `VALUETOTEXT(...)`.
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
+ ComputeVALUETOTEXT(...args: string[]): string | number;
54
+ /**
55
+ * Returns the text representation of an array.
56
+ *
57
+ * Excel: `ARRAYTOTEXT(...)`.
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
+ ComputeARRAYTOTEXT(...args: string[]): string | number;
64
+ }
@@ -0,0 +1,222 @@
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
+ * Advanced text parsing, regex-style extraction, and structured text transforms.
19
+ *
20
+ * Registered functions: ASC, TEXTBEFORE, VALUETOTEXT, ARRAYTOTEXT.
21
+ *
22
+ * @hidden
23
+ */
24
+ var TextAdvancedFormulas = /** @class */ (function (_super) {
25
+ __extends(TextAdvancedFormulas, _super);
26
+ /**
27
+ * @hidden
28
+ * @param {FormulaOwner} owner - Formula registration owner ({@link BasicFormulas}).
29
+ */
30
+ function TextAdvancedFormulas(owner) {
31
+ var _this = _super.call(this, owner) || this;
32
+ /** Formula definitions registered with {@link BasicFormulas}. */
33
+ _this.formulas = [
34
+ { formulaName: 'ASC', category: 'Text', description: 'Changes full-width characters to half-width.' },
35
+ { formulaName: 'TEXTBEFORE', category: 'Text', description: 'Returns text before a given character or string.' },
36
+ { formulaName: 'VALUETOTEXT', category: 'Text', description: 'Returns text from any specified value.' },
37
+ { formulaName: 'ARRAYTOTEXT', category: 'Text', description: 'Returns the text representation of an array.' }
38
+ ];
39
+ return _this;
40
+ }
41
+ /**
42
+ * Changes full-width characters to half-width.
43
+ *
44
+ * Excel: `ASC(...)`.
45
+ *
46
+ * @hidden
47
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
48
+ * @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
49
+ *
50
+ * @example
51
+ * ```ts
52
+ * engine.computeFormula('=ASC(1)');
53
+ * ```
54
+ */
55
+ TextAdvancedFormulas.prototype.ComputeASC = function () {
56
+ var args = [];
57
+ for (var _i = 0; _i < arguments.length; _i++) {
58
+ args[_i] = arguments[_i];
59
+ }
60
+ if (isNullOrUndefined(args) || args.length !== 1) {
61
+ return this.parent.formulaErrorStrings[FormulasErrorsStrings.WrongNumberArguments];
62
+ }
63
+ var text = this.resolveTextArg(args[0]);
64
+ if (this.parent.getErrorStrings().indexOf(text) > -1) {
65
+ return text;
66
+ }
67
+ var result = '';
68
+ for (var i = 0; i < text.length; i++) {
69
+ var code = text.charCodeAt(i);
70
+ if (code >= 0xFF01 && code <= 0xFF5E) {
71
+ result += String.fromCharCode(code - 0xFEE0);
72
+ }
73
+ else if (code === 0x3000) {
74
+ result += ' ';
75
+ }
76
+ else {
77
+ result += text.charAt(i);
78
+ }
79
+ }
80
+ return result;
81
+ };
82
+ /**
83
+ * Returns text before a given character or string.
84
+ *
85
+ * Excel: `TEXTBEFORE(...)`.
86
+ *
87
+ * @hidden
88
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
89
+ * @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
90
+ */
91
+ TextAdvancedFormulas.prototype.ComputeTEXTBEFORE = function () {
92
+ var args = [];
93
+ for (var _i = 0; _i < arguments.length; _i++) {
94
+ args[_i] = arguments[_i];
95
+ }
96
+ var errCollection = this.parent.getErrorStrings();
97
+ if (isNullOrUndefined(args) || args.length < 2 || args.length > 6) {
98
+ return this.parent.formulaErrorStrings[FormulasErrorsStrings.WrongNumberArguments];
99
+ }
100
+ var text = this.resolveTextArg(args[0]);
101
+ if (errCollection.indexOf(text) > -1) {
102
+ return text;
103
+ }
104
+ var delimiter = this.resolveTextArg(args[1]);
105
+ if (errCollection.indexOf(delimiter) > -1) {
106
+ return delimiter;
107
+ }
108
+ var instance = 1;
109
+ if (args.length >= 3 && args[2] !== '') {
110
+ var inst = this.resolveNumberArg(args[2]);
111
+ if (typeof inst === 'string') {
112
+ return inst;
113
+ }
114
+ instance = Math.floor(inst);
115
+ if (instance < 1) {
116
+ return errCollection[CommonErrors.Value];
117
+ }
118
+ }
119
+ var start = 0;
120
+ for (var i = 0; i < instance; i++) {
121
+ var idx = text.indexOf(delimiter, start);
122
+ if (idx < 0) {
123
+ if (args.length >= 6 && args[5] !== '') {
124
+ return this.resolveTextArg(args[5]);
125
+ }
126
+ return errCollection[CommonErrors.NA];
127
+ }
128
+ if (i === instance - 1) {
129
+ return text.substring(0, idx);
130
+ }
131
+ start = idx + delimiter.length;
132
+ }
133
+ return text;
134
+ };
135
+ /**
136
+ * Returns text from any specified value.
137
+ *
138
+ * Excel: `VALUETOTEXT(...)`.
139
+ *
140
+ * @hidden
141
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
142
+ * @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
143
+ */
144
+ TextAdvancedFormulas.prototype.ComputeVALUETOTEXT = function () {
145
+ var args = [];
146
+ for (var _i = 0; _i < arguments.length; _i++) {
147
+ args[_i] = arguments[_i];
148
+ }
149
+ if (isNullOrUndefined(args) || args.length < 1 || args.length > 2) {
150
+ return this.parent.formulaErrorStrings[FormulasErrorsStrings.WrongNumberArguments];
151
+ }
152
+ var errCollection = this.parent.getErrorStrings();
153
+ var val = this.parent.getValueFromArg(args[0]);
154
+ if (errCollection.indexOf(val) > -1) {
155
+ return val;
156
+ }
157
+ if (val === '') {
158
+ return '';
159
+ }
160
+ var concise = true;
161
+ if (args.length === 2) {
162
+ var fmt = this.resolveNumberArg(args[1]);
163
+ if (typeof fmt === 'string') {
164
+ return fmt;
165
+ }
166
+ concise = fmt === 0;
167
+ }
168
+ if (!concise && !this.parent.isCellReference(args[0]) && args[0].indexOf(this.parent.tic) > -1) {
169
+ return this.parent.removeTics(val);
170
+ }
171
+ return val;
172
+ };
173
+ /**
174
+ * Returns the text representation of an array.
175
+ *
176
+ * Excel: `ARRAYTOTEXT(...)`.
177
+ *
178
+ * @hidden
179
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
180
+ * @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
181
+ */
182
+ TextAdvancedFormulas.prototype.ComputeARRAYTOTEXT = function () {
183
+ var _this = this;
184
+ var args = [];
185
+ for (var _i = 0; _i < arguments.length; _i++) {
186
+ args[_i] = arguments[_i];
187
+ }
188
+ if (isNullOrUndefined(args) || args.length < 1 || args.length > 2) {
189
+ return this.parent.formulaErrorStrings[FormulasErrorsStrings.WrongNumberArguments];
190
+ }
191
+ var errCollection = this.parent.getErrorStrings();
192
+ var parts = [];
193
+ var collect = function (arg) {
194
+ if (_this.parent.isCellReference(arg) && arg.indexOf(':') > -1) {
195
+ var cells = _this.parent.getCellCollection(arg);
196
+ var list = Array.isArray(cells) ? cells : [cells];
197
+ for (var i = 0; i < list.length; i++) {
198
+ var val = _this.parent.getValueFromArg(list[i]);
199
+ if (errCollection.indexOf(val) > -1) {
200
+ return val;
201
+ }
202
+ parts.push(val);
203
+ }
204
+ }
205
+ else {
206
+ var val = _this.resolveTextArg(arg);
207
+ if (errCollection.indexOf(val) > -1) {
208
+ return val;
209
+ }
210
+ parts.push(val);
211
+ }
212
+ return null;
213
+ };
214
+ var err = collect(args[0]);
215
+ if (err) {
216
+ return err;
217
+ }
218
+ return parts.join(this.parent.getParseArgumentSeparator());
219
+ };
220
+ return TextAdvancedFormulas;
221
+ }(FormulaModuleBase));
222
+ export { TextAdvancedFormulas };
@@ -0,0 +1,54 @@
1
+ import { IBasicFormula } from '../common/index';
2
+ import { FormulaOwner } from './formula-owner';
3
+ import { FormulaModuleBase } from './formula-module-base';
4
+ /**
5
+ * ECMA text function aliases and byte-oriented variants (FINDB, LENB, USDOLLAR).
6
+ *
7
+ * Registered functions: USDOLLAR, FINDB, LENB.
8
+ *
9
+ * @hidden
10
+ */
11
+ export declare class TextEcmaFormulas 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
+ * Converts a number to text using currency format (US dollar).
21
+ *
22
+ * Excel: `USDOLLAR(...)`.
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('=USDOLLAR(1)');
31
+ * ```
32
+ */
33
+ ComputeUSDOLLAR(...args: string[]): string | number;
34
+ /**
35
+ * Finds text within another string (byte-count alias of FIND).
36
+ *
37
+ * Excel: `FINDB(...)`.
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
+ ComputeFINDB(...args: string[]): string | number;
44
+ /**
45
+ * Returns the length of a text string (byte-count alias of LEN).
46
+ *
47
+ * Excel: `LENB(...)`.
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
+ ComputeLENB(...args: string[]): string | number;
54
+ }
@@ -0,0 +1,106 @@
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 } from '../common/index';
15
+ import { FormulaModuleBase } from './formula-module-base';
16
+ /**
17
+ * ECMA text function aliases and byte-oriented variants (FINDB, LENB, USDOLLAR).
18
+ *
19
+ * Registered functions: USDOLLAR, FINDB, LENB.
20
+ *
21
+ * @hidden
22
+ */
23
+ var TextEcmaFormulas = /** @class */ (function (_super) {
24
+ __extends(TextEcmaFormulas, _super);
25
+ /**
26
+ * @hidden
27
+ * @param {FormulaOwner} owner - Formula registration owner ({@link BasicFormulas}).
28
+ */
29
+ function TextEcmaFormulas(owner) {
30
+ var _this = _super.call(this, owner) || this;
31
+ /** Formula definitions registered with {@link BasicFormulas}. */
32
+ _this.formulas = [
33
+ { formulaName: 'USDOLLAR', category: 'Text', description: 'Converts a number to text using currency format (US dollar).' },
34
+ { formulaName: 'FINDB', category: 'Text', description: 'Finds text within another string (byte-count alias of FIND).' },
35
+ { formulaName: 'LENB', category: 'Text', description: 'Returns the length of a text string (byte-count alias of LEN).' }
36
+ ];
37
+ return _this;
38
+ }
39
+ /**
40
+ * Converts a number to text using currency format (US dollar).
41
+ *
42
+ * Excel: `USDOLLAR(...)`.
43
+ *
44
+ * @hidden
45
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
46
+ * @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
47
+ *
48
+ * @example
49
+ * ```ts
50
+ * engine.computeFormula('=USDOLLAR(1)');
51
+ * ```
52
+ */
53
+ TextEcmaFormulas.prototype.ComputeUSDOLLAR = function () {
54
+ var args = [];
55
+ for (var _i = 0; _i < arguments.length; _i++) {
56
+ args[_i] = arguments[_i];
57
+ }
58
+ var fn = this.owner['ComputeDOLLAR'];
59
+ if (fn) {
60
+ return fn.apply(void 0, args);
61
+ }
62
+ return this.parent.formulaErrorStrings[FormulasErrorsStrings.InvalidArguments];
63
+ };
64
+ /**
65
+ * Finds text within another string (byte-count alias of FIND).
66
+ *
67
+ * Excel: `FINDB(...)`.
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
+ TextEcmaFormulas.prototype.ComputeFINDB = function () {
74
+ var args = [];
75
+ for (var _i = 0; _i < arguments.length; _i++) {
76
+ args[_i] = arguments[_i];
77
+ }
78
+ var fn = this.owner['ComputeFIND'];
79
+ if (fn) {
80
+ return fn.apply(void 0, args);
81
+ }
82
+ return this.parent.formulaErrorStrings[FormulasErrorsStrings.InvalidArguments];
83
+ };
84
+ /**
85
+ * Returns the length of a text string (byte-count alias of LEN).
86
+ *
87
+ * Excel: `LENB(...)`.
88
+ *
89
+ * @hidden
90
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
91
+ * @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
92
+ */
93
+ TextEcmaFormulas.prototype.ComputeLENB = function () {
94
+ var args = [];
95
+ for (var _i = 0; _i < arguments.length; _i++) {
96
+ args[_i] = arguments[_i];
97
+ }
98
+ var fn = this.owner['ComputeLEN'];
99
+ if (fn) {
100
+ return fn.apply(void 0, args);
101
+ }
102
+ return this.parent.formulaErrorStrings[FormulasErrorsStrings.InvalidArguments];
103
+ };
104
+ return TextEcmaFormulas;
105
+ }(FormulaModuleBase));
106
+ export { TextEcmaFormulas };
@@ -0,0 +1,216 @@
1
+ import { IBasicFormula } from '../common/index';
2
+ import { FormulaOwner } from './formula-owner';
3
+ import { FormulaModuleBase } from './formula-module-base';
4
+ /**
5
+ * Extended text functions for search, replace, formatting, and character-code conversion.
6
+ *
7
+ * Registers 19 functions including LEFT, RIGHT, MID, UPPER, LOWER, and others.
8
+ *
9
+ * @hidden
10
+ */
11
+ export declare class TextExtraFormulas 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 the leftmost characters from a text value.
21
+ *
22
+ * Excel: `LEFT(...)`.
23
+ *
24
+ * @hidden
25
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
26
+ * @returns {string | number} - Computed text result or an Excel error token such as `#VALUE!`.
27
+ *
28
+ * @example
29
+ * ```ts
30
+ * engine.computeFormula('=LEFT("Calculate",4)');
31
+ * ```
32
+ */
33
+ ComputeLEFT(...args: string[]): string;
34
+ /**
35
+ * Returns the rightmost characters from a text value.
36
+ *
37
+ * Excel: `RIGHT(...)`.
38
+ *
39
+ * @hidden
40
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
41
+ * @returns {string | number} - Computed text result or an Excel error token such as `#VALUE!`.
42
+ */
43
+ ComputeRIGHT(...args: string[]): string;
44
+ private substringSide;
45
+ /**
46
+ * Returns a specific number of characters from a text string starting at the position you specify.
47
+ *
48
+ * Excel: `MID(...)`.
49
+ *
50
+ * @hidden
51
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
52
+ * @returns {string | number} - Computed text result or an Excel error token such as `#VALUE!`.
53
+ */
54
+ ComputeMID(...args: string[]): string;
55
+ /**
56
+ * Converts text to uppercase.
57
+ *
58
+ * Excel: `UPPER(...)`.
59
+ *
60
+ * @hidden
61
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
62
+ * @returns {string | number} - Computed text result or an Excel error token such as `#VALUE!`.
63
+ */
64
+ ComputeUPPER(...args: string[]): string;
65
+ /**
66
+ * Converts text to lowercase.
67
+ *
68
+ * Excel: `LOWER(...)`.
69
+ *
70
+ * @hidden
71
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
72
+ * @returns {string | number} - Computed text result or an Excel error token such as `#VALUE!`.
73
+ */
74
+ ComputeLOWER(...args: string[]): string;
75
+ private caseTransform;
76
+ /**
77
+ * Removes spaces from text except for single spaces between words.
78
+ *
79
+ * Excel: `TRIM(...)`.
80
+ *
81
+ * @hidden
82
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
83
+ * @returns {string | number} - Computed text result or an Excel error token such as `#VALUE!`.
84
+ */
85
+ ComputeTRIM(...args: string[]): string;
86
+ /**
87
+ * Replaces characters within text.
88
+ *
89
+ * Excel: `REPLACE(...)`.
90
+ *
91
+ * @hidden
92
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
93
+ * @returns {string | number} - Computed text result or an Excel error token such as `#VALUE!`.
94
+ */
95
+ ComputeREPLACE(...args: string[]): string;
96
+ /**
97
+ * Substitutes new text for old text in a text string.
98
+ *
99
+ * Excel: `SUBSTITUTE(...)`.
100
+ *
101
+ * @hidden
102
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
103
+ * @returns {string | number} - Computed text result or an Excel error token such as `#VALUE!`.
104
+ */
105
+ ComputeSUBSTITUTE(...args: string[]): string;
106
+ /**
107
+ * Repeats text a given number of times.
108
+ *
109
+ * Excel: `REPT(...)`.
110
+ *
111
+ * @hidden
112
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
113
+ * @returns {string | number} - Computed text result or an Excel error token such as `#VALUE!`.
114
+ */
115
+ ComputeREPT(...args: string[]): string;
116
+ /**
117
+ * Finds one text value within another (not case-sensitive).
118
+ *
119
+ * Excel: `SEARCH(...)`.
120
+ *
121
+ * @hidden
122
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
123
+ * @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
124
+ */
125
+ ComputeSEARCH(...args: string[]): string | number;
126
+ /**
127
+ * Converts a text argument to a number.
128
+ *
129
+ * Excel: `VALUE(...)`.
130
+ *
131
+ * @hidden
132
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
133
+ * @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
134
+ */
135
+ ComputeVALUE(...args: string[]): string | number;
136
+ /**
137
+ * Removes all nonprintable characters from text.
138
+ *
139
+ * Excel: `CLEAN(...)`.
140
+ *
141
+ * @hidden
142
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
143
+ * @returns {string | number} - Computed text result or an Excel error token such as `#VALUE!`.
144
+ */
145
+ ComputeCLEAN(...args: string[]): string;
146
+ /**
147
+ * Formats a number as text with a fixed number of decimals.
148
+ *
149
+ * Excel: `FIXED(...)`.
150
+ *
151
+ * @hidden
152
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
153
+ * @returns {string | number} - Computed text result or an Excel error token such as `#VALUE!`.
154
+ */
155
+ ComputeFIXED(...args: string[]): string;
156
+ /**
157
+ * Combines text from multiple ranges/strings with a delimiter.
158
+ *
159
+ * Excel: `TEXTJOIN(...)`.
160
+ *
161
+ * @hidden
162
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
163
+ * @returns {string | number} - Computed text result or an Excel error token such as `#VALUE!`.
164
+ */
165
+ ComputeTEXTJOIN(...args: string[]): string;
166
+ /**
167
+ * Returns the leftmost characters from a text value (byte count alias).
168
+ *
169
+ * Excel: `LEFTB(...)`.
170
+ *
171
+ * @hidden
172
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
173
+ * @returns {string | number} - Computed text result or an Excel error token such as `#VALUE!`.
174
+ */
175
+ ComputeLEFTB(...args: string[]): string;
176
+ /**
177
+ * Returns the rightmost characters from a text value (byte count alias).
178
+ *
179
+ * Excel: `RIGHTB(...)`.
180
+ *
181
+ * @hidden
182
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
183
+ * @returns {string | number} - Computed text result or an Excel error token such as `#VALUE!`.
184
+ */
185
+ ComputeRIGHTB(...args: string[]): string;
186
+ /**
187
+ * Returns characters from a text string (byte count alias).
188
+ *
189
+ * Excel: `MIDB(...)`.
190
+ *
191
+ * @hidden
192
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
193
+ * @returns {string | number} - Computed text result or an Excel error token such as `#VALUE!`.
194
+ */
195
+ ComputeMIDB(...args: string[]): string;
196
+ /**
197
+ * Replaces characters within text (byte count alias).
198
+ *
199
+ * Excel: `REPLACEB(...)`.
200
+ *
201
+ * @hidden
202
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
203
+ * @returns {string | number} - Computed text result or an Excel error token such as `#VALUE!`.
204
+ */
205
+ ComputeREPLACEB(...args: string[]): string;
206
+ /**
207
+ * Finds one text value within another (byte count alias).
208
+ *
209
+ * Excel: `SEARCHB(...)`.
210
+ *
211
+ * @hidden
212
+ * @param {string[]} args - Formula argument tokens from the Calculate engine.
213
+ * @returns {string | number} - Computed Excel-compatible numeric or text result, or an error token such as `#VALUE!`, `#NUM!`, `#N/A`.
214
+ */
215
+ ComputeSEARCHB(...args: string[]): string | number;
216
+ }