Commit 89ed71f8 authored by Dmitry.Shahtanov's avatar Dmitry.Shahtanov Committed by Alexander.Trofimov

fix: Bug 27784 - Формула AVERAGEIF рассчитывается некорректно если Диапазон...

fix: Bug 27784 - Формула AVERAGEIF рассчитывается некорректно если Диапазон задан многомерным массивом

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@61002 954022d7-b5bf-4e40-9824-e11837661b57
parent 7c8340d9
...@@ -616,7 +616,7 @@ cArea.prototype.foreach2 = function ( action ) { ...@@ -616,7 +616,7 @@ cArea.prototype.foreach2 = function ( action ) {
var t = this, r = this.getRange(); var t = this, r = this.getRange();
if (r) { if (r) {
r._foreach2(function (cell) { r._foreach2(function (cell) {
action(t._parseCellValue(cell)); action(t._parseCellValue(cell),cell);
}); });
} }
}; };
......
...@@ -338,9 +338,7 @@ cAVERAGEA.prototype.getInfo = function () { ...@@ -338,9 +338,7 @@ cAVERAGEA.prototype.getInfo = function () {
} }
function cAVERAGEIF() { function cAVERAGEIF() {
// cBaseFunction.call( this, "AVERAGEIF" ); // cBaseFunction.call( this, "AVERAGEIF", 2, 3 );
// this.setArgumentsMin( 2 );
// this.setArgumentsMax( 3 );
this.name = "AVERAGEIF"; this.name = "AVERAGEIF";
this.type = cElementType.func; this.type = cElementType.func;
...@@ -392,11 +390,23 @@ cAVERAGEIF.prototype.Calculate = function ( arg ) { ...@@ -392,11 +390,23 @@ cAVERAGEIF.prototype.Calculate = function ( arg ) {
} }
valueForSearching = parseNum( search ) ? new cNumber( search ) : new cString( search ); valueForSearching = parseNum( search ) ? new cNumber( search ) : new cString( search );
if ( arg0 instanceof cArea ) { if ( arg0 instanceof cArea ) {
var r = arg0.getRange().first.getRow0(), ws = arg0.getWS(), c1 = arg2.getRange().first.getCol0(), i = 0; var r = arg0.getRange().first.getRow0(), ws = arg0.getWS(), c/*c1*/ = arg2.getRange().first.getCol0(), i = 0,
arg0.foreach2( function ( c ) { tmpCellArg0 = arg0.getRange().getCells()[0],
if ( matching( c, valueForSearching, oper ) ) { tmpCellArg2 = arg2.getRange(),
var r1 = r + i, offset, bbox, r2;
r2 = new cRef( ws.getRange3( r1, c1, r1, c1 ).getName(), ws ); arg0.foreach2( function ( v, cell ) {
if ( matching( v, valueForSearching, oper ) ) {
offset = cell.getOffset(tmpCellArg0);
tmpCellArg2 = arg2.getRange();
tmpCellArg2.setOffset(offset);
bbox = tmpCellArg2.getBBox0();
offset.offsetCol *= -1;
offset.offsetRow *= -1;
r2 = new cRef( ws.getRange3( bbox.r1, bbox.c1, bbox.r1, bbox.c1 ).getName(), ws );
tmpCellArg2.setOffset(offset);
if ( r2.getValue() instanceof cNumber ) { if ( r2.getValue() instanceof cNumber ) {
_sum += r2.getValue().getValue(); _sum += r2.getValue().getValue();
_count++; _count++;
......
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