@syncfusion/ej2-calculate 35.1.37 → 35.1.40
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/dist/ej2-calculate.umd.min.js +2 -2
- package/dist/ej2-calculate.umd.min.js.map +1 -1
- package/dist/es6/ej2-calculate.es2015.js +79 -7
- package/dist/es6/ej2-calculate.es2015.js.map +1 -1
- package/dist/es6/ej2-calculate.es5.js +79 -7
- package/dist/es6/ej2-calculate.es5.js.map +1 -1
- package/dist/global/ej2-calculate.min.js +2 -2
- package/dist/global/ej2-calculate.min.js.map +1 -1
- package/dist/global/index.d.ts +1 -1
- package/package.json +3 -3
- package/src/base/calculate.js +47 -2
- package/src/base/parser.js +18 -0
- package/src/formulas/text-extra.js +14 -5
|
@@ -16423,6 +16423,11 @@ var TextExtraFormulas = /** @__PURE__ @class */ (function (_super) {
|
|
|
16423
16423
|
return this.substringSide(args, false);
|
|
16424
16424
|
};
|
|
16425
16425
|
TextExtraFormulas.prototype.substringSide = function (args, fromLeft) {
|
|
16426
|
+
var nestedFormula;
|
|
16427
|
+
if (args && args.length > 0 && args[args.length - 1] === 'nestedFormulaTrue') {
|
|
16428
|
+
nestedFormula = true;
|
|
16429
|
+
args.pop();
|
|
16430
|
+
}
|
|
16426
16431
|
var errCollection = this.parent.getErrorStrings();
|
|
16427
16432
|
if (isNullOrUndefined(args) || (args.length === 1 && args[0] === '')) {
|
|
16428
16433
|
return this.parent.formulaErrorStrings[FormulasErrorsStrings.InvalidArguments];
|
|
@@ -16445,10 +16450,8 @@ var TextExtraFormulas = /** @__PURE__ @class */ (function (_super) {
|
|
|
16445
16450
|
return errCollection[CommonErrors.Value];
|
|
16446
16451
|
}
|
|
16447
16452
|
}
|
|
16448
|
-
|
|
16449
|
-
|
|
16450
|
-
}
|
|
16451
|
-
return count >= text.length ? text : text.substring(text.length - count);
|
|
16453
|
+
var result = fromLeft ? text.substring(0, count) : (count >= text.length ? text : text.substring(text.length - count));
|
|
16454
|
+
return nestedFormula ? this.parent.tic + result + this.parent.tic : result;
|
|
16452
16455
|
};
|
|
16453
16456
|
/**
|
|
16454
16457
|
* Returns a specific number of characters from a text string starting at the position you specify.
|
|
@@ -16544,6 +16547,11 @@ var TextExtraFormulas = /** @__PURE__ @class */ (function (_super) {
|
|
|
16544
16547
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
16545
16548
|
args[_i] = arguments[_i];
|
|
16546
16549
|
}
|
|
16550
|
+
var nestedFormula;
|
|
16551
|
+
if (args && args.length > 0 && args[args.length - 1] === 'nestedFormulaTrue') {
|
|
16552
|
+
nestedFormula = true;
|
|
16553
|
+
args.pop();
|
|
16554
|
+
}
|
|
16547
16555
|
var errCollection = this.parent.getErrorStrings();
|
|
16548
16556
|
if (isNullOrUndefined(args) || args.length !== 1) {
|
|
16549
16557
|
return this.parent.formulaErrorStrings[FormulasErrorsStrings.WrongNumberArguments];
|
|
@@ -16552,7 +16560,8 @@ var TextExtraFormulas = /** @__PURE__ @class */ (function (_super) {
|
|
|
16552
16560
|
if (errCollection.indexOf(text) > -1) {
|
|
16553
16561
|
return text;
|
|
16554
16562
|
}
|
|
16555
|
-
|
|
16563
|
+
var result = text.trim().replace(/\s+/g, ' ');
|
|
16564
|
+
return nestedFormula ? this.parent.tic + result + this.parent.tic : result;
|
|
16556
16565
|
};
|
|
16557
16566
|
/**
|
|
16558
16567
|
* Replaces characters within text.
|
|
@@ -22083,6 +22092,24 @@ var Parser = /** @__PURE__ @class */ (function () {
|
|
|
22083
22092
|
var criteriaStr = this_1.parent.substring(substr, leftBraceIdx, substr.indexOf('}') - leftBraceIdx + 1);
|
|
22084
22093
|
substr = substr.split(criteriaStr).join(criteriaStr.split(argsSep).join(this_1.parent.tic + this_1.parent.tic));
|
|
22085
22094
|
}
|
|
22095
|
+
if ((libFormula === 'VLOOKUP' || libFormula === 'HLOOKUP') && substr.includes('{')) {
|
|
22096
|
+
var searchStartIdx = 0;
|
|
22097
|
+
var leftBraceIdx = substr.indexOf('{', searchStartIdx);
|
|
22098
|
+
while (leftBraceIdx > -1) {
|
|
22099
|
+
var rightBraceIdx = substr.indexOf('}', leftBraceIdx);
|
|
22100
|
+
if (rightBraceIdx > leftBraceIdx) {
|
|
22101
|
+
var criteriaStr = this_1.parent.substring(substr, leftBraceIdx, rightBraceIdx - leftBraceIdx + 1);
|
|
22102
|
+
var protectedStr = criteriaStr.split(';').join(this_1.parent.tic + 'RSEP' + this_1.parent.tic)
|
|
22103
|
+
.split(argsSep).join(this_1.parent.tic + 'CSEP' + this_1.parent.tic);
|
|
22104
|
+
substr = substr.split(criteriaStr).join(protectedStr);
|
|
22105
|
+
searchStartIdx = leftBraceIdx + protectedStr.length;
|
|
22106
|
+
leftBraceIdx = substr.indexOf('{', searchStartIdx);
|
|
22107
|
+
}
|
|
22108
|
+
else {
|
|
22109
|
+
break;
|
|
22110
|
+
}
|
|
22111
|
+
}
|
|
22112
|
+
}
|
|
22086
22113
|
}
|
|
22087
22114
|
try {
|
|
22088
22115
|
var args = void 0;
|
|
@@ -23655,7 +23682,7 @@ var Calculate = /** @__PURE__ @class */ (function (_super) {
|
|
|
23655
23682
|
}
|
|
23656
23683
|
if (nestedFormula && libFormula) {
|
|
23657
23684
|
var formulas = ['IF', 'INDEX', 'SORT', 'T', 'EXACT',
|
|
23658
|
-
'PROPER', 'DOLLAR', 'DATE', 'TEXT', 'ISNUMBER'];
|
|
23685
|
+
'PROPER', 'DOLLAR', 'DATE', 'TEXT', 'ISNUMBER', 'TRIM', 'LEFT'];
|
|
23659
23686
|
if (formulas.some(function (formula) { return formula === libFormula; })) {
|
|
23660
23687
|
args.push('nestedFormulaTrue');
|
|
23661
23688
|
}
|
|
@@ -24052,7 +24079,52 @@ var Calculate = /** @__PURE__ @class */ (function (_super) {
|
|
|
24052
24079
|
return errorStrings[CommonErrors.Value];
|
|
24053
24080
|
}
|
|
24054
24081
|
}
|
|
24055
|
-
var
|
|
24082
|
+
var rangeArg = argArr[1];
|
|
24083
|
+
var rowSepMarker = this.tic + 'RSEP' + this.tic;
|
|
24084
|
+
var isInlineArray = rangeArg.includes(rowSepMarker) ||
|
|
24085
|
+
(rangeArg.startsWith('(') && rangeArg.endsWith(')') && rangeArg.includes(rowSepMarker));
|
|
24086
|
+
if (isInlineArray) {
|
|
24087
|
+
var innerStr = rangeArg.startsWith('(') && rangeArg.endsWith(')')
|
|
24088
|
+
? rangeArg.substring(1, rangeArg.length - 1) : rangeArg;
|
|
24089
|
+
var rowBoundary = this.tic + 'RSEP' + this.tic;
|
|
24090
|
+
var colBoundary_1 = this.tic + 'CSEP' + this.tic;
|
|
24091
|
+
var rows = innerStr.split(rowBoundary).map(function (rowStr) {
|
|
24092
|
+
return rowStr.split(colBoundary_1).map(function (cell) {
|
|
24093
|
+
if (cell.startsWith(_this.tic) && cell.endsWith(_this.tic)) {
|
|
24094
|
+
return cell.substring(1, cell.length - 1);
|
|
24095
|
+
}
|
|
24096
|
+
if (_this.isCellReference(cell.trim())) {
|
|
24097
|
+
return _this.getValueFromArg(cell.trim());
|
|
24098
|
+
}
|
|
24099
|
+
return cell.trim();
|
|
24100
|
+
});
|
|
24101
|
+
});
|
|
24102
|
+
var numRows = rows.length;
|
|
24103
|
+
var numCols = rows[0] ? rows[0].length : 0;
|
|
24104
|
+
var matchColIdx = colNumIdx - 1;
|
|
24105
|
+
if (isVlookup && numCols <= matchColIdx) {
|
|
24106
|
+
return errorStrings[CommonErrors.Ref];
|
|
24107
|
+
}
|
|
24108
|
+
if (!isVlookup && numRows <= matchColIdx) {
|
|
24109
|
+
return errorStrings[CommonErrors.Ref];
|
|
24110
|
+
}
|
|
24111
|
+
var lookupValUpper = lookupValue.toUpperCase();
|
|
24112
|
+
var iterCount = isVlookup ? numRows : numCols;
|
|
24113
|
+
for (var r = 0; r < iterCount; r++) {
|
|
24114
|
+
var cellVal = (isVlookup ? rows[r][0] : rows[0][r]) || '';
|
|
24115
|
+
var isMatch = this.isNumber(lookupValue) && this.isNumber(cellVal)
|
|
24116
|
+
? this.parseFloat(lookupValue) === this.parseFloat(cellVal) : cellVal.toUpperCase() === lookupValUpper;
|
|
24117
|
+
if (isMatch) {
|
|
24118
|
+
var matchVal = isVlookup
|
|
24119
|
+
? (rows[r][matchColIdx] !== undefined ? rows[r][matchColIdx] : '')
|
|
24120
|
+
: (rows[matchColIdx] !== undefined && rows[matchColIdx][r] !== undefined
|
|
24121
|
+
? rows[matchColIdx][r] : '');
|
|
24122
|
+
return matchVal !== '' ? matchVal : '';
|
|
24123
|
+
}
|
|
24124
|
+
}
|
|
24125
|
+
return errorStrings[CommonErrors.NA];
|
|
24126
|
+
}
|
|
24127
|
+
var rangeArr = rangeArg.split(':');
|
|
24056
24128
|
var startIdx;
|
|
24057
24129
|
var endIdx;
|
|
24058
24130
|
var idx;
|