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 () {
}
valueForSearching = AscCommonExcel.parseNum(search) ? new cNumber(search) : new cString(search);
if (cElementType.cellsRange === arg1.type) {
var arg1Matrix = arg1.getMatrix();
for (i = 0; i < arg1Matrix.length; i++) {
for (j = 0; j < arg1Matrix[i].length; j++) {
if (arg0Matrix[i][j] && !AscCommonExcel.matching(arg1Matrix[i][j], valueForSearching, oper)) {
arg0Matrix[i][j] = null;
}
}
}
} else {
return this.value = new cError(cErrorType.wrong_value_type);
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++) {
if (arg0Matrix[i].length !== arg1Matrix[i].length) {
return this.value = new cError(cErrorType.wrong_value_type);
}
for (j = 0; j < arg1Matrix[i].length; j++) {
if (arg0Matrix[i][j] && !AscCommonExcel.matching(arg1Matrix[i][j], valueForSearching, oper)) {
arg0Matrix[i][j] = null;
}
}
}
}
var valMatrix0;
......@@ -4165,7 +4167,7 @@ cSQRTPI.prototype.getInfo = function () {
return this.value = new cNumber(_sum);
};
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 () {
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