Commit c77aea10 authored by Alexander.Trofimov's avatar Alexander.Trofimov

fix SUMIFS calculation.

Check the same number of rows and columns for range arguments. The Criteria_range argument must contain the same number of rows and columns as the Sum_range argument.
parent c283fd71
...@@ -4140,18 +4140,20 @@ cSQRTPI.prototype.getInfo = function () { ...@@ -4140,18 +4140,20 @@ cSQRTPI.prototype.getInfo = function () {
} }
valueForSearching = AscCommonExcel.parseNum(search) ? new cNumber(search) : new cString(search); valueForSearching = AscCommonExcel.parseNum(search) ? new cNumber(search) : new cString(search);
if (cElementType.cellsRange === arg1.type) {
var arg1Matrix = arg1.getMatrix(); var arg1Matrix = arg1.getMatrix();
if (arg0Matrix.length !== arg1Matrix.length) {
return this.value = new cError(cErrorType.wrong_value_type);
}
for (i = 0; i < arg1Matrix.length; i++) { for (i = 0; i < arg1Matrix.length; i++) {
if (arg0Matrix[i].length !== arg1Matrix[i].length) {
return this.value = new cError(cErrorType.wrong_value_type);
}
for (j = 0; j < arg1Matrix[i].length; j++) { for (j = 0; j < arg1Matrix[i].length; j++) {
if (arg0Matrix[i][j] && !AscCommonExcel.matching(arg1Matrix[i][j], valueForSearching, oper)) { if (arg0Matrix[i][j] && !AscCommonExcel.matching(arg1Matrix[i][j], valueForSearching, oper)) {
arg0Matrix[i][j] = null; arg0Matrix[i][j] = null;
} }
} }
} }
} else {
return this.value = new cError(cErrorType.wrong_value_type);
}
} }
var valMatrix0; var valMatrix0;
...@@ -4165,7 +4167,7 @@ cSQRTPI.prototype.getInfo = function () { ...@@ -4165,7 +4167,7 @@ cSQRTPI.prototype.getInfo = function () {
return this.value = new cNumber(_sum); return this.value = new cNumber(_sum);
}; };
cSUMIFS.prototype.checkArguments = function () { cSUMIFS.prototype.checkArguments = function () {
return (this.argumentsCurrent % 2) && cBaseFunction.prototype.checkArguments.apply(this, arguments); return 1 === this.argumentsCurrent % 2 && cBaseFunction.prototype.checkArguments.apply(this, arguments);
}; };
cSUMIFS.prototype.getInfo = function () { cSUMIFS.prototype.getInfo = function () {
return { return {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment