Commit 3a3a5050 authored by Alexander.Trofimov's avatar Alexander.Trofimov

fix bug 33627

SUBTOTAL now calculate with check hidden row (https://support.office.com/en-us/article/SUBTOTAL-function-7b027003-f060-4ade-9040-e478765b9939)
bIsApplyFilterBySheet  -> isApplyFilterBySheet
parent 72947729
......@@ -2635,65 +2635,61 @@ cPOWER.prototype.getInfo = function () {
};
};
function cPRODUCT() {
// cBaseFunction.call( this, "PRODUCT" );
// this.setArgumentsMin( 1 );
// this.setArgumentsMax( 255 );
this.name = "PRODUCT";
this.type = cElementType.func;
this.value = null;
this.argumentsMin = 1;
this.argumentsCurrent = 0;
this.argumentsMax = 255;
this.formatType = {
def:-1, //подразумевается формат первой ячейки входящей в формулу.
noneFormat:-2
};
this.numFormat = this.formatType.def;
}
cPRODUCT.prototype = Object.create( cBaseFunction.prototype );
cPRODUCT.prototype.Calculate = function ( arg ) {
var arg0 = new cNumber( 1 );
for ( var i = 0; i < arg.length; i++ ) {
if ( arg[i] instanceof cArea || arg[i] instanceof cArea3D ) {
var _arrVal = arg[i].getValue();
for ( var j = 0; j < _arrVal.length; j++ ) {
arg0 = _func[arg0.type][_arrVal[j].type]( arg0, _arrVal[j], "*" );
if ( arg0 instanceof cError )
return this.value = arg0;
}
}
else if ( arg[i] instanceof cRef || arg[i] instanceof cRef3D ) {
var _arg = arg[i].getValue();
arg0 = _func[arg0.type][_arg.type]( arg0, _arg, "*" );
}
else if ( arg[i] instanceof cArray ) {
arg[i].foreach( function ( elem ) {
if ( elem instanceof cString || elem instanceof cBool || elem instanceof cEmpty )
return;
arg0 = _func[arg0.type][elem.type]( arg0, elem, "*" );
} )
}
else {
arg0 = _func[arg0.type][arg[i].type]( arg0, arg[i], "*" );
}
if ( arg0 instanceof cError )
return this.value = arg0;
}
return this.value = arg0;
};
cPRODUCT.prototype.getInfo = function () {
return {
name:this.name,
args:"( argument-list )"
};
};
/** @constructor */
function cPRODUCT() {
this.name = "PRODUCT";
this.type = cElementType.func;
this.value = null;
this.argumentsMin = 1;
this.argumentsCurrent = 0;
this.argumentsMax = 255;
this.formatType = {
def: -1, //подразумевается формат первой ячейки входящей в формулу.
noneFormat: -2
};
this.numFormat = this.formatType.def;
}
cPRODUCT.prototype = Object.create(cBaseFunction.prototype);
cPRODUCT.prototype.Calculate = function (arg) {
var arg0 = new cNumber(1);
for (var i = 0; i < arg.length; i++) {
if (cElementType.cellsRange === arg[i].type || cElementType.cellsRange3D === arg[i].type) {
var _arrVal = arg[i].getValue(this.checkExclude, this.excludeHiddenRows);
for (var j = 0; j < _arrVal.length; j++) {
arg0 = _func[arg0.type][_arrVal[j].type](arg0, _arrVal[j], "*");
if (cElementType.error === arg0.type) {
return this.value = arg0;
}
}
} else if (cElementType.cell === arg[i].type || cElementType.cell3D === arg[i].type) {
if (!this.checkExclude || !element.isHidden(this.excludeHiddenRows)) {
var _arg = arg[i].getValue();
arg0 = _func[arg0.type][_arg.type](arg0, _arg, "*");
}
} else if (cElementType.array === arg[i].type) {
arg[i].foreach(function (elem) {
if (cElementType.string === elem.type || cElementType.bool === elem.type || cElementType.empty === elem.type) {
return;
}
arg0 = _func[arg0.type][elem.type](arg0, elem, "*");
})
} else {
arg0 = _func[arg0.type][arg[i].type](arg0, arg[i], "*");
}
if (cElementType.error === arg0.type) {
return this.value = arg0;
}
}
return this.value = arg0;
};
cPRODUCT.prototype.getInfo = function () {
return {
name: this.name, args: "( argument-list )"
};
};
function cQUOTIENT() {
// cBaseFunction.call( this, "QUOTIENT" );
......@@ -3834,144 +3830,161 @@ cSQRTPI.prototype.getInfo = function () {
};
};
/** @constructor */
function cSUBTOTAL() {
cBaseFunction.call(this, "SUBTOTAL");
this.setArgumentsMin(1);
this.setArgumentsMax(255);
}
cSUBTOTAL.prototype = Object.create(cBaseFunction.prototype);
cSUBTOTAL.prototype.Calculate = function (arg) {
var f, arg0 = arg[0];
if (cElementType.cellsRange === arg0.type || cElementType.cellsRange3D === arg0.type) {
arg0 = arg0.cross(arguments[1].first);
}
arg0 = arg0.tocNumber();
if (cElementType.number !== arg0.type) {
return this.value = arg0;
}
arg0 = arg0.getValue();
switch (arg0) {
case cSubTotalFunctionType.includes.AVERAGE:
case cSubTotalFunctionType.excludes.AVERAGE:
this.value = (new AscCommonExcel.cAVERAGE()).Calculate(arg.slice(1));
break;
case cSubTotalFunctionType.includes.COUNT:
case cSubTotalFunctionType.excludes.COUNT:
this.value = (new AscCommonExcel.cCOUNT()).Calculate(arg.slice(1));
break;
case cSubTotalFunctionType.includes.COUNTA:
case cSubTotalFunctionType.excludes.COUNTA:
this.value = (new AscCommonExcel.cCOUNTA()).Calculate(arg.slice(1));
break;
case cSubTotalFunctionType.includes.MAX:
case cSubTotalFunctionType.excludes.MAX:
f = new AscCommonExcel.cMAX();
f.setArgumentsCount(arg.length - 1);
this.value = f.Calculate(arg.slice(1));
break;
case cSubTotalFunctionType.includes.MIN:
case cSubTotalFunctionType.excludes.MIN:
f = new AscCommonExcel.cMIN();
f.setArgumentsCount(arg.length - 1);
this.value = f.Calculate(arg.slice(1));
break;
case cSubTotalFunctionType.includes.PRODUCT:
case cSubTotalFunctionType.excludes.PRODUCT:
this.value = (new cPRODUCT()).Calculate(arg.slice(1));
break;
case cSubTotalFunctionType.includes.STDEV:
case cSubTotalFunctionType.excludes.STDEV:
this.value = (new AscCommonExcel.cSTDEV()).Calculate(arg.slice(1));
break;
case cSubTotalFunctionType.includes.STDEVP:
case cSubTotalFunctionType.excludes.STDEVP:
this.value = (new AscCommonExcel.cSTDEVP()).Calculate(arg.slice(1));
break;
case cSubTotalFunctionType.includes.SUM:
case cSubTotalFunctionType.excludes.SUM:
this.value = (new cSUM()).Calculate(arg.slice(1));
break;
case cSubTotalFunctionType.includes.VAR:
case cSubTotalFunctionType.excludes.VAR:
this.value = (new AscCommonExcel.cVAR()).Calculate(arg.slice(1));
break;
case cSubTotalFunctionType.includes.VARP:
case cSubTotalFunctionType.excludes.VARP:
this.value = (new AscCommonExcel.cVARP()).Calculate(arg.slice(1));
break;
}
return this.value;
};
cSUBTOTAL.prototype.getInfo = function () {
return {
name: this.name, args: "( function-number , argument-list )"
};
};
/** @constructor */
function cSUM() {
this.name = "SUM";
this.type = cElementType.func;
this.value = null;
this.argumentsMin = 1;
this.argumentsCurrent = 0;
this.argumentsMax = 255;
this.formatType = {
def: -1, //подразумевается формат первой ячейки входящей в формулу.
noneFormat: -2
};
this.numFormat = this.formatType.def;
}
cSUM.prototype = Object.create(cBaseFunction.prototype);
cSUM.prototype.Calculate = function (arg) {
var element, _arg, arg0 = new cNumber(0);
for (var i = 0; i < arg.length; i++) {
element = arg[i];
if (cElementType.cellsRange === element.type || cElementType.cellsRange3D === element.type) {
var _arrVal = element.getValue();
for (var j = 0; j < _arrVal.length; j++) {
if (cElementType.bool !== _arrVal[j].type && cElementType.string !== _arrVal[j].type) {
arg0 = _func[arg0.type][_arrVal[j].type](arg0, _arrVal[j], "+");
}
if (cElementType.error === arg0.type) {
return this.value = arg0;
}
}
} else if (cElementType.cell === element.type || cElementType.cell3D === element.type) {
_arg = element.getValue();
if (cElementType.bool !== _arg.type && cElementType.string !== _arg.type) {
arg0 = _func[arg0.type][_arg.type](arg0, _arg, "+");
}
} else if (cElementType.array === element.type) {
element.foreach(function (arrElem) {
if (cElementType.bool !== arrElem.type && cElementType.string !== arrElem.type && cElementType.empty !== arrElem.type) {
arg0 = _func[arg0.type][arrElem.type](arg0, arrElem, "+");
}
})
} else {
_arg = element.tocNumber();
arg0 = _func[arg0.type][_arg.type](arg0, _arg, "+");
}
if (cElementType.error === arg0.type) {
return this.value = arg0;
}
/** @constructor */
function cSUBTOTAL() {
cBaseFunction.call(this, "SUBTOTAL");
this.setArgumentsMin(1);
this.setArgumentsMax(255);
}
cSUBTOTAL.prototype = Object.create(cBaseFunction.prototype);
cSUBTOTAL.prototype.Calculate = function (arg) {
var f, exclude = false, arg0 = arg[0];
if (cElementType.cellsRange === arg0.type || cElementType.cellsRange3D === arg0.type) {
arg0 = arg0.cross(arguments[1].first);
}
arg0 = arg0.tocNumber();
if (cElementType.number !== arg0.type) {
return this.value = arg0;
}
arg0 = arg0.getValue();
switch (arg0) {
case cSubTotalFunctionType.excludes.AVERAGE:
exclude = true;
case cSubTotalFunctionType.includes.AVERAGE:
f = new AscCommonExcel.cAVERAGE();
break;
case cSubTotalFunctionType.excludes.COUNT:
exclude = true;
case cSubTotalFunctionType.includes.COUNT:
f = new AscCommonExcel.cCOUNT();
break;
case cSubTotalFunctionType.excludes.COUNTA:
exclude = true;
case cSubTotalFunctionType.includes.COUNTA:
f = new AscCommonExcel.cCOUNTA();
break;
case cSubTotalFunctionType.excludes.MAX:
exclude = true;
case cSubTotalFunctionType.includes.MAX:
f = new AscCommonExcel.cMAX();
f.setArgumentsCount(arg.length - 1);
break;
case cSubTotalFunctionType.excludes.MIN:
exclude = true;
case cSubTotalFunctionType.includes.MIN:
f = new AscCommonExcel.cMIN();
f.setArgumentsCount(arg.length - 1);
break;
case cSubTotalFunctionType.excludes.PRODUCT:
exclude = true;
case cSubTotalFunctionType.includes.PRODUCT:
f = new cPRODUCT();
break;
case cSubTotalFunctionType.excludes.STDEV:
exclude = true;
case cSubTotalFunctionType.includes.STDEV:
f = new AscCommonExcel.cSTDEV();
break;
case cSubTotalFunctionType.excludes.STDEVP:
exclude = true;
case cSubTotalFunctionType.includes.STDEVP:
f = new AscCommonExcel.cSTDEVP();
break;
case cSubTotalFunctionType.excludes.SUM:
exclude = true;
case cSubTotalFunctionType.includes.SUM:
f = new cSUM();
break;
case cSubTotalFunctionType.excludes.VAR:
exclude = true;
case cSubTotalFunctionType.includes.VAR:
f = new AscCommonExcel.cVAR();
break;
case cSubTotalFunctionType.excludes.VARP:
exclude = true;
case cSubTotalFunctionType.includes.VARP:
f = new AscCommonExcel.cVARP();
break;
}
if (f) {
f.checkExclude = true;
f.excludeHiddenRows = exclude;
this.value = f.Calculate(arg.slice(1));
}
return this.value = arg0;
};
cSUM.prototype.getInfo = function () {
return {
name: this.name, args: "( argument-list )"
};
};
return this.value;
};
cSUBTOTAL.prototype.getInfo = function () {
return {
name: this.name, args: "( function-number , argument-list )"
};
};
/** @constructor */
function cSUM() {
this.name = "SUM";
this.type = cElementType.func;
this.value = null;
this.argumentsMin = 1;
this.argumentsCurrent = 0;
this.argumentsMax = 255;
this.formatType = {
def: -1, //подразумевается формат первой ячейки входящей в формулу.
noneFormat: -2
};
this.numFormat = this.formatType.def;
}
cSUM.prototype = Object.create(cBaseFunction.prototype);
cSUM.prototype.Calculate = function (arg) {
var element, _arg, arg0 = new cNumber(0);
for (var i = 0; i < arg.length; i++) {
element = arg[i];
if (cElementType.cellsRange === element.type || cElementType.cellsRange3D === element.type) {
var _arrVal = element.getValue(this.checkExclude, this.excludeHiddenRows);
for (var j = 0; j < _arrVal.length; j++) {
if (cElementType.bool !== _arrVal[j].type && cElementType.string !== _arrVal[j].type) {
arg0 = _func[arg0.type][_arrVal[j].type](arg0, _arrVal[j], "+");
}
if (cElementType.error === arg0.type) {
return this.value = arg0;
}
}
} else if (cElementType.cell === element.type || cElementType.cell3D === element.type) {
if (!this.checkExclude || !element.isHidden(this.excludeHiddenRows)) {
_arg = element.getValue();
if (cElementType.bool !== _arg.type && cElementType.string !== _arg.type) {
arg0 = _func[arg0.type][_arg.type](arg0, _arg, "+");
}
}
} else if (cElementType.array === element.type) {
element.foreach(function (arrElem) {
if (cElementType.bool !== arrElem.type && cElementType.string !== arrElem.type &&
cElementType.empty !== arrElem.type) {
arg0 = _func[arg0.type][arrElem.type](arg0, arrElem, "+");
}
});
} else {
_arg = element.tocNumber();
arg0 = _func[arg0.type][_arg.type](arg0, _arg, "+");
}
if (cElementType.error === arg0.type) {
return this.value = arg0;
}
}
return this.value = arg0;
};
cSUM.prototype.getInfo = function () {
return {
name: this.name, args: "( argument-list )"
};
};
/** @constructor */
function cSUMIF() {
......
......@@ -960,14 +960,17 @@ cArea.prototype.clone = function () {
cArea.prototype.getWsId = function () {
return this.ws.Id;
};
cArea.prototype.getValue = function () {
cArea.prototype.getValue = function (checkExclude, excludeHiddenRows) {
var val = [], r = this.getRange();
if (!r) {
val.push(new cError(cErrorType.bad_reference));
} else {
if (checkExclude && !excludeHiddenRows) {
excludeHiddenRows = this.ws.isApplyFilterBySheet();
}
r._foreachNoEmpty(function (cell) {
val.push(checkTypeCell(cell));
});
}, excludeHiddenRows);
}
return val;
};
......@@ -980,12 +983,12 @@ cArea.prototype.getWsId = function () {
}
return res;
};
cArea.prototype.getRange = function () {
if ( !this.range ) {
this.range = this.ws.getRange2( this._cells )
}
return this.range;
};
cArea.prototype.getRange = function () {
if (!this.range) {
this.range = this.ws.getRange2(this._cells);
}
return this.range;
};
cArea.prototype.tocNumber = function () {
var v = this.getValue()[0];
if ( !v ) {
......@@ -1174,7 +1177,7 @@ cArea3D.prototype.wsRange = function () {
cArea3D.prototype.getRanges = function () {
return (this.range(this.wsRange()));
};
cArea3D.prototype.getValue = function () {
cArea3D.prototype.getValue = function (checkExclude, excludeHiddenRows) {
var i, _wsA = this.wsRange();
var _val = [];
if (_wsA.length < 1) {
......@@ -1188,15 +1191,19 @@ cArea3D.prototype.wsRange = function () {
}
}
var _exclude;
var _r = this.range(_wsA);
for (i = 0; i < _r.length; i++) {
if (!_r[i]) {
_val.push(new cError(cErrorType.bad_reference));
return _val;
}
if (checkExclude && !(_exclude = excludeHiddenRows)) {
_exclude = _wsA[i].isApplyFilterBySheet();
}
_r[i]._foreachNoEmpty(function (cell) {
_val.push(checkTypeCell(cell));
});
}, _exclude);
}
return _val;
};
......@@ -1356,25 +1363,25 @@ cArea3D.prototype.getWS = function () {
return this.wsFrom === this.wsTo;
};
/** @constructor */
function cRef( val, ws ) {/*Ref means A1 for example*/
this.constructor.call( this, val, cElementType.cell );
this._cells = val;
this.ws = ws;
this.wb = this._wb = ws.workbook;
this.isAbsolute = false;
this.isAbsoluteCol1 = false;
this.isAbsoluteRow1 = false;
var ca = g_oCellAddressUtils.getCellAddress(val.replace(AscCommon.rx_space_g, ""));
this.range = null;
this._valid = ca.isValid();
if ( this._valid ) {
this.range = this.ws.getRange3( ca.getRow0(), ca.getCol0(), ca.getRow0(), ca.getCol0() );
} else {
this.range = this.ws.getRange3( 0, 0, 0, 0 );
}
}
/** @constructor */
function cRef(val, ws) {/*Ref means A1 for example*/
this.constructor.call(this, val, cElementType.cell);
this._cells = val;
this.ws = ws;
this.wb = this._wb = ws.workbook;
this.isAbsolute = false;
this.isAbsoluteCol1 = false;
this.isAbsoluteRow1 = false;
var ca = g_oCellAddressUtils.getCellAddress(val.replace(AscCommon.rx_space_g, ""));
this.range = null;
this._valid = ca.isValid();
if (this._valid) {
this.range = this.ws.getRange3(ca.getRow0(), ca.getCol0(), ca.getRow0(), ca.getCol0());
} else {
this.range = this.ws.getRange3(0, 0, 0, 0);
}
}
cRef.prototype = Object.create( cBaseType.prototype );
cRef.prototype.clone = function () {
......@@ -1408,9 +1415,9 @@ cRef.prototype.tocBool = function () {
cRef.prototype.toString = function () {
return this._cells;
};
cRef.prototype.getRange = function () {
return this.range;
};
cRef.prototype.getRange = function () {
return this.range;
};
cRef.prototype.getWS = function () {
return this.ws;
};
......@@ -1423,18 +1430,24 @@ cRef.prototype.getMatrix = function () {
cRef.prototype.getBBox0 = function () {
return this.getRange().getBBox0();
};
cRef.prototype.isHidden = function (excludeHiddenRows) {
if (!excludeHiddenRows) {
excludeHiddenRows = this.ws.isApplyFilterBySheet();
}
return excludeHiddenRows && this._valid && this.ws.getRowHidden(this.getRange().r1);
};
/** @constructor */
function cRef3D( val, _wsFrom, wb ) {/*Ref means Sheat1!A1 for example*/
this.constructor.call( this, val, cElementType.cell3D );
this.wb = this._wb = wb;
this._cells = val;
this.isAbsolute = false;
this.isAbsoluteCol1 = false;
this.isAbsoluteRow1 = false;
this.ws = this._wb.getWorksheetByName( _wsFrom );
this.range = null;
}
/** @constructor */
function cRef3D(val, _wsFrom, wb) {/*Ref means Sheat1!A1 for example*/
this.constructor.call(this, val, cElementType.cell3D);
this.wb = this._wb = wb;
this._cells = val;
this.isAbsolute = false;
this.isAbsoluteCol1 = false;
this.isAbsoluteRow1 = false;
this.ws = this._wb.getWorksheetByName(_wsFrom);
this.range = null;
}
cRef3D.prototype = Object.create( cBaseType.prototype );
cRef3D.prototype.clone = function () {
......@@ -1449,16 +1462,16 @@ cRef3D.prototype.clone = function () {
cRef3D.prototype.getWsId = function () {
return this.ws.Id;
};
cRef3D.prototype.getRange = function () {
if ( this.ws ) {
if ( this.range ) {
return this.range;
}
return this.range = this.ws.getRange2( this._cells );
} else {
return this.range = null;
}
};
cRef3D.prototype.getRange = function () {
if (this.ws) {
if (this.range) {
return this.range;
}
return this.range = this.ws.getRange2(this._cells);
} else {
return this.range = null;
}
};
cRef3D.prototype.isValid = function () {
return !!this.getRange();
};
......@@ -1496,6 +1509,13 @@ cRef3D.prototype.getBBox0 = function () {
}
return null;
};
cRef3D.prototype.isHidden = function (excludeHiddenRows) {
if (!excludeHiddenRows) {
excludeHiddenRows = this.ws.isApplyFilterBySheet();
}
var _r = this.getRange();
return excludeHiddenRows && _r && this.ws.getRowHidden(_r.r1);
};
/** @constructor */
function cEmpty() {
......
......@@ -469,87 +469,80 @@ cAVEDEV.prototype.getInfo = function () {
};
};
function cAVERAGE() {
// cBaseFunction.call( this, "AVERAGE" );
// this.setArgumentsMin( 1 );
// this.setArgumentsMax( 255 );
this.name = "AVERAGE";
this.type = cElementType.func;
this.value = null;
this.argumentsMin = 1;
this.argumentsCurrent = 0;
this.argumentsMax = 255;
this.formatType = {
def:-1, //подразумевается формат первой ячейки входящей в формулу.
noneFormat:-2
};
this.numFormat = this.formatType.def;
}
cAVERAGE.prototype = Object.create( cBaseFunction.prototype );
cAVERAGE.prototype.Calculate = function ( arg ) {
var count = 0, sum = new cNumber( 0 );
for ( var i = 0; i < arg.length; i++ ) {
var _arg = arg[i];
if ( _arg instanceof cRef || _arg instanceof cRef3D ) {
var _argV = _arg.getValue();
if ( _argV instanceof cString || _argV instanceof cEmpty || _argV instanceof cBool ) {
continue;
}
else if ( _argV instanceof cNumber ) {
sum = _func[sum.type][_argV.type]( sum, _argV, "+" );
count++;
}
else if ( _argV instanceof cError ) {
return this.value = _argV;
}
}
else if ( _arg instanceof cArea || _arg instanceof cArea3D ) {
var _argAreaValue = _arg.getValue();
for ( var j = 0; j < _argAreaValue.length; j++ ) {
var __arg = _argAreaValue[j];
if ( __arg instanceof cString || __arg instanceof cEmpty || __arg instanceof cBool ) {
continue;
}
else if ( __arg instanceof cNumber ) {
sum = _func[sum.type][__arg.type]( sum, __arg, "+" );
count++;
}
else if ( __arg instanceof cError ) {
return this.value = __arg;
}
}
}
else if ( _arg instanceof cArray ) {
_arg.foreach( function ( elem ) {
if ( elem instanceof cString || elem instanceof cEmpty || elem instanceof cBool ) {
return false;
}
var e = elem.tocNumber();
if ( e instanceof cNumber ) {
sum = _func[sum.type][e.type]( sum, e, "+" );
count++;
}
} )
}
else {
_arg = _arg.tocNumber();
if ( _arg instanceof cError )
return this.value = _arg;
sum = _func[sum.type][_arg.type]( sum, _arg, "+" );
count++;
}
}
return this.value = new cNumber( sum.getValue() / count );
};
cAVERAGE.prototype.getInfo = function () {
return {
name:this.name,
args:"( argument-list )"
};
};
/** @constructor */
function cAVERAGE() {
this.name = "AVERAGE";
this.type = cElementType.func;
this.value = null;
this.argumentsMin = 1;
this.argumentsCurrent = 0;
this.argumentsMax = 255;
this.formatType = {
def: -1, //подразумевается формат первой ячейки входящей в формулу.
noneFormat: -2
};
this.numFormat = this.formatType.def;
}
cAVERAGE.prototype = Object.create(cBaseFunction.prototype);
cAVERAGE.prototype.Calculate = function (arg) {
var count = 0, sum = new cNumber(0);
for (var i = 0; i < arg.length; i++) {
var _arg = arg[i];
if (cElementType.cell === _arg.type || cElementType.cell3D === _arg.type) {
if (!this.checkExclude || !_arg.isHidden(this.excludeHiddenRows)) {
var _argV = _arg.getValue();
if (cElementType.string === _argV.type || cElementType.empty === _argV.type ||
cElementType.bool === _argV.type) {
continue;
} else if (cElementType.number === _argV.type) {
sum = _func[sum.type][_argV.type](sum, _argV, "+");
count++;
} else if (cElementType.error === _argV.type) {
return this.value = _argV;
}
}
} else if (cElementType.cellsRange === _arg.type || cElementType.cellsRange3D === _arg.type) {
var _argAreaValue = _arg.getValue(this.checkExclude, this.excludeHiddenRows);
for (var j = 0; j < _argAreaValue.length; j++) {
var __arg = _argAreaValue[j];
if (cElementType.string === __arg.type || cElementType.empty === __arg.type || cElementType.bool === __arg.type) {
continue;
} else if (cElementType.number === __arg.type) {
sum = _func[sum.type][__arg.type](sum, __arg, "+");
count++;
} else if (cElementType.error === __arg.type) {
return this.value = __arg;
}
}
} else if (cElementType.array === _arg.type) {
_arg.foreach(function (elem) {
if (cElementType.string === elem.type || cElementType.empty === elem.type || cElementType.bool === elem.type) {
return false;
}
var e = elem.tocNumber();
if (cElementType.number === e.type) {
sum = _func[sum.type][e.type](sum, e, "+");
count++;
}
})
} else {
_arg = _arg.tocNumber();
if (cElementType.error === _arg.type) {
return this.value = _arg;
}
sum = _func[sum.type][_arg.type](sum, _arg, "+");
count++;
}
}
return this.value = new cNumber(sum.getValue() / count);
};
cAVERAGE.prototype.getInfo = function () {
return {
name: this.name, args: "( argument-list )"
};
};
function cAVERAGEA() {
// cBaseFunction.call( this, "AVERAGEA" );
......@@ -1011,122 +1004,113 @@ cCORREL.prototype.getInfo = function () {
};
};
function cCOUNT() {
this.name = "COUNT";
this.type = cElementType.func;
this.value = null;
this.argumentsMin = 1;
this.argumentsCurrent = 0;
this.argumentsMax = 255;
this.formatType = {
def:-1, //подразумевается формат первой ячейки входящей в формулу.
noneFormat:-2
};
this.numFormat = this.formatType.noneFormat;
}
cCOUNT.prototype = Object.create( cBaseFunction.prototype );
cCOUNT.prototype.Calculate = function ( arg ) {
var count = 0;
for ( var i = 0; i < arg.length; i++ ) {
var _arg = arg[i];
if ( _arg instanceof cRef || _arg instanceof cRef3D ) {
var _argV = _arg.getValue();
if ( _argV instanceof cNumber ) {
count++;
}
}
else if ( _arg instanceof cArea || _arg instanceof cArea3D ) {
var _argAreaValue = _arg.getValue();
for ( var j = 0; j < _argAreaValue.length; j++ ) {
if ( _argAreaValue[j] instanceof cNumber ) {
count++;
}
}
}
else if ( _arg instanceof cNumber || _arg instanceof cBool || _arg instanceof cEmpty ) {
count++;
}
else if ( _arg instanceof cString ) {
if ( _arg.tocNumber() instanceof cNumber )
count++;
}
else if ( _arg instanceof cArray ) {
_arg.foreach( function ( elem ) {
var e = elem.tocNumber();
if ( e instanceof cNumber ) {
count++;
}
} )
}
}
return this.value = new cNumber( count );
};
cCOUNT.prototype.getInfo = function () {
return {
name:this.name,
args:"( argument-list )"
};
};
function cCOUNTA() {
// cBaseFunction.call( this, "COUNTA" );
// this.setArgumentsMin( 1 );
// this.setArgumentsMax( 255 );
// this.setFormat( this.formatType.noneFormat );
this.name = "COUNTA";
this.type = cElementType.func;
this.value = null;
this.argumentsMin = 1;
this.argumentsCurrent = 0;
this.argumentsMax = 255;
this.formatType = {
def:-1, //подразумевается формат первой ячейки входящей в формулу.
noneFormat:-2
};
this.numFormat = this.formatType.noneFormat;
}
cCOUNTA.prototype = Object.create( cBaseFunction.prototype );
cCOUNTA.prototype.Calculate = function ( arg ) {
var count = 0;
for ( var i = 0; i < arg.length; i++ ) {
var _arg = arg[i];
if ( _arg instanceof cRef || _arg instanceof cRef3D ) {
var _argV = _arg.getValue();
if ( !(_argV instanceof cEmpty) ) {
count++;
}
}
else if ( _arg instanceof cArea || _arg instanceof cArea3D ) {
var _argAreaValue = _arg.getValue();
for ( var j = 0; j < _argAreaValue.length; j++ ) {
if ( !(_argAreaValue[j] instanceof cEmpty) ) {
count++;
}
}
}
else if ( _arg instanceof cArray ) {
_arg.foreach( function ( elem ) {
if ( !(elem instanceof cEmpty) ) {
count++;
}
} )
}
else if ( !( _arg instanceof cEmpty ) ) {
count++;
}
}
return this.value = new cNumber( count );
};
cCOUNTA.prototype.getInfo = function () {
return {
name:this.name,
args:"( argument-list )"
};
};
/** @constructor */
function cCOUNT() {
this.name = "COUNT";
this.type = cElementType.func;
this.value = null;
this.argumentsMin = 1;
this.argumentsCurrent = 0;
this.argumentsMax = 255;
this.formatType = {
def: -1, //подразумевается формат первой ячейки входящей в формулу.
noneFormat: -2
};
this.numFormat = this.formatType.noneFormat;
}
cCOUNT.prototype = Object.create(cBaseFunction.prototype);
cCOUNT.prototype.Calculate = function (arg) {
var count = 0;
for (var i = 0; i < arg.length; i++) {
var _arg = arg[i];
if (cElementType.cell === _arg.type || cElementType.cell3D === _arg.type) {
if (!this.checkExclude || !_arg.isHidden(this.excludeHiddenRows)) {
var _argV = _arg.getValue();
if (cElementType.number === _argV.type) {
count++;
}
}
} else if (cElementType.cellsRange === _arg.type || cElementType.cellsRange3D === _arg) {
var _argAreaValue = _arg.getValue(this.checkExclude, this.excludeHiddenRows);
for (var j = 0; j < _argAreaValue.length; j++) {
if (cElementType.number === _argAreaValue[j].type) {
count++;
}
}
} else if (cElementType.number === _arg.type || cElementType.bool === _arg.type || cElementType.empty === _arg.type) {
count++;
} else if (cElementType.string === _arg.type) {
if (cElementType.number === _arg.tocNumber().type) {
count++;
}
} else if (cElementType.array === _arg.type) {
_arg.foreach(function (elem) {
if (cElementType.number === elem.tocNumber().type) {
count++;
}
})
}
}
return this.value = new cNumber(count);
};
cCOUNT.prototype.getInfo = function () {
return {
name: this.name, args: "( argument-list )"
};
};
/** @constructor */
function cCOUNTA() {
this.name = "COUNTA";
this.type = cElementType.func;
this.value = null;
this.argumentsMin = 1;
this.argumentsCurrent = 0;
this.argumentsMax = 255;
this.formatType = {
def: -1, //подразумевается формат первой ячейки входящей в формулу.
noneFormat: -2
};
this.numFormat = this.formatType.noneFormat;
}
cCOUNTA.prototype = Object.create(cBaseFunction.prototype);
cCOUNTA.prototype.Calculate = function (arg) {
var count = 0;
for (var i = 0; i < arg.length; i++) {
var _arg = arg[i];
if (cElementType.cell === _arg.type || cElementType.cell3D === _arg.type) {
if (!this.checkExclude || !element.isHidden(this.excludeHiddenRows)) {
var _argV = _arg.getValue();
if (cElementType.empty !== _argV.type) {
count++;
}
}
} else if (cElementType.cellsRange === _arg.type || cElementType.cellsRange3D === _arg.type) {
var _argAreaValue = _arg.getValue(this.checkExclude, this.excludeHiddenRows);
for (var j = 0; j < _argAreaValue.length; j++) {
if (cElementType.empty !== _argAreaValue[j].type) {
count++;
}
}
} else if (cElementType.array === _arg.type) {
_arg.foreach(function (elem) {
if (cElementType.empty !== elem.type) {
count++;
}
})
} else if (cElementType.empty !== _arg.type) {
count++;
}
}
return this.value = new cNumber(count);
};
cCOUNTA.prototype.getInfo = function () {
return {
name: this.name, args: "( argument-list )"
};
};
function cCOUNTBLANK() {
this.name = "COUNTBLANK";
......@@ -2663,93 +2647,93 @@ cLOGNORMDIST.prototype.getInfo = function () {
};
};
function cMAX() {
// cBaseFunction.call( this, "MAX" );
// this.setArgumentsMin( 1 );
// this.setArgumentsMax( 255 );
this.name = "MAX";
this.type = cElementType.func;
this.value = null;
this.argumentsMin = 1;
this.argumentsCurrent = 0;
this.argumentsMax = 255;
this.formatType = {
def:-1, //подразумевается формат первой ячейки входящей в формулу.
noneFormat:-2
};
this.numFormat = this.formatType.def;
}
cMAX.prototype = Object.create( cBaseFunction.prototype );
cMAX.prototype.Calculate = function ( arg ) {
var argI, argIVal, max = Number.NEGATIVE_INFINITY;
for ( var i = 0; i < this.argumentsCurrent; i++ ) {
argI = arg[i], argIVal = argI.getValue();
if ( argI instanceof cRef || argI instanceof cRef3D ) {
if ( argIVal instanceof cError )
return this.value = argIVal;
if ( argIVal instanceof cNumber ) {
var v = argIVal.tocNumber();
if ( v.getValue() > max )
max = v.getValue();
}
}
else if ( argI instanceof cArea || argI instanceof cArea3D ) {
var argArr = argI.getValue();
for ( var j = 0; j < argArr.length; j++ ) {
if ( argArr[j] instanceof cNumber ) {
var v = argArr[j].tocNumber();
if ( v.getValue() > max )
max = v.getValue();
}
else if ( argArr[j] instanceof cError ) {
return this.value = argArr[j];
}
}
}
else if ( argI instanceof cError )
return this.value = argI;
else if ( argI instanceof cString ) {
var v = argI.tocNumber();
if ( v instanceof cNumber )
if ( v.getValue() > max )
max = v.getValue();
}
else if ( argI instanceof cBool || argI instanceof cEmpty ) {
var v = argI.tocNumber();
if ( v.getValue() > max )
max = v.getValue();
}
else if ( argI instanceof cArray ) {
argI.foreach( function ( elem ) {
if ( elem instanceof cNumber ) {
if ( elem.getValue() > max )
max = elem.getValue();
}
else if ( elem instanceof cError ) {
max = elem;
return true;
}
} );
if ( max instanceof cError ) {
return this.value = max;
}
}
else {
if ( argI.getValue() > max )
max = argI.getValue();
}
}
return this.value = ( max === Number.NEGATIVE_INFINITY ? new cNumber( 0 ) : new cNumber( max ) );
};
cMAX.prototype.getInfo = function () {
return {
name:this.name,
args:"(number1, number2, ...)"
};
};
/** @constructor */
function cMAX() {
this.name = "MAX";
this.type = cElementType.func;
this.value = null;
this.argumentsMin = 1;
this.argumentsCurrent = 0;
this.argumentsMax = 255;
this.formatType = {
def: -1, //подразумевается формат первой ячейки входящей в формулу.
noneFormat: -2
};
this.numFormat = this.formatType.def;
}
cMAX.prototype = Object.create(cBaseFunction.prototype);
cMAX.prototype.Calculate = function (arg) {
var v, argI, argIVal, max = Number.NEGATIVE_INFINITY;
for (var i = 0; i < this.argumentsCurrent; i++) {
argI = arg[i];
argIVal = argI.getValue();
if (cElementType.cell === argI.type || cElementType.cell3D === argI.type) {
if (!this.checkExclude || !element.isHidden(this.excludeHiddenRows)) {
if (cElementType.error === argIVal.type) {
return this.value = argIVal;
}
if (cElementType.number === argIVal.type) {
v = argIVal.tocNumber();
if (v.getValue() > max) {
max = v.getValue();
}
}
}
} else if (cElementType.cellsRange === argI.type || cElementType.cellsRange3D === argI.type) {
var argArr = argI.getValue(this.checkExclude, this.excludeHiddenRows);
for (var j = 0; j < argArr.length; j++) {
if (cElementType.number === argArr[j].type) {
v = argArr[j].tocNumber();
if (v.getValue() > max) {
max = v.getValue();
}
} else if (cElementType.error === argArr[j].type) {
return this.value = argArr[j];
}
}
} else if (cElementType.error === argI.type) {
return this.value = argI;
} else if (cElementType.string === argI.type) {
v = argI.tocNumber();
if (cElementType.number === v.type) {
if (v.getValue() > max) {
max = v.getValue();
}
}
} else if (cElementType.bool === argI.type || cElementType.empty === argI.type) {
v = argI.tocNumber();
if (v.getValue() > max) {
max = v.getValue();
}
} else if (cElementType.array === argI.type) {
argI.foreach(function (elem) {
if (cElementType.number === elem.type) {
if (elem.getValue() > max) {
max = elem.getValue();
}
} else if (cElementType.error === elem.type) {
max = elem;
return true;
}
});
if (cElementType.error === max.type) {
return this.value = max;
}
} else {
if (argI.getValue() > max) {
max = argI.getValue();
}
}
}
return this.value = (max === Number.NEGATIVE_INFINITY ? new cNumber(0) : new cNumber(max));
};
cMAX.prototype.getInfo = function () {
return {
name: this.name, args: "(number1, number2, ...)"
};
};
function cMAXA() {
// cBaseFunction.call( this, "MAXA" );
......@@ -2927,12 +2911,101 @@ cMEDIAN.prototype.getInfo = function () {
};
};
function cMIN() {
// cBaseFunction.call( this, "MIN" );
/** @constructor */
function cMIN() {
this.name = "MIN";
this.type = cElementType.func;
this.value = null;
this.argumentsMin = 1;
this.argumentsCurrent = 0;
this.argumentsMax = 255;
this.formatType = {
def: -1, //подразумевается формат первой ячейки входящей в формулу.
noneFormat: -2
};
this.numFormat = this.formatType.def;
}
cMIN.prototype = Object.create(cBaseFunction.prototype);
cMIN.prototype.Calculate = function (arg) {
var v, argI, argIVal, min = Number.POSITIVE_INFINITY;
for (var i = 0; i < this.argumentsCurrent; i++) {
argI = arg[i];
argIVal = argI.getValue();
if (cElementType.cell === argI.type || cElementType.cell3D === argI.type) {
if (!this.checkExclude || !element.isHidden(this.excludeHiddenRows)) {
if (cElementType.error === argIVal.type) {
return this.value = argIVal;
}
if (cElementType.number === argIVal.type) {
v = argIVal.tocNumber();
if (v.getValue() < min) {
min = v.getValue();
}
}
}
} else if (cElementType.cellsRange === argI.type || cElementType.cellsRange3D === argI.type) {
var argArr = argI.getValue(this.checkExclude, this.excludeHiddenRows);
for (var j = 0; j < argArr.length; j++) {
if (cElementType.number === argArr[j].type) {
v = argArr[j].tocNumber();
if (v.getValue() < min) {
min = v.getValue();
}
continue;
} else if (cElementType.error === argArr[j].type) {
return this.value = argArr[j];
}
}
} else if (cElementType.error === argI.type) {
return this.value = argI;
} else if (cElementType.string === argI.type) {
v = argI.tocNumber();
if (cElementType.number === v.type) {
if (v.getValue() < min) {
min = v.getValue();
}
}
} else if (cElementType.bool === argI.type || cElementType.empty === argI.type) {
v = argI.tocNumber();
if (v.getValue() < min) {
min = v.getValue();
}
} else if (cElementType.array === argI.type) {
argI.foreach(function (elem) {
if (cElementType.number === elem.type) {
if (elem.getValue() < min) {
min = elem.getValue();
}
} else if (cElementType.error === elem.type) {
min = elem;
return true;
}
});
if (cElementType.error === min.type) {
return this.value = min;
}
} else {
if (argI.getValue() < min) {
min = argI.getValue();
}
}
}
return this.value = ( min === Number.POSITIVE_INFINITY ? new cNumber(0) : new cNumber(min) );
};
cMIN.prototype.getInfo = function () {
return {
name: this.name, args: "(number1, number2, ...)"
};
};
function cMINA() {
// cBaseFunction.call( this, "MINA" );
// this.setArgumentsMin( 1 );
// this.setArgumentsMax( 255 );
this.name = "MIN";
this.name = "MINA";
this.type = cElementType.func;
this.value = null;
this.argumentsMin = 1;
......@@ -2946,32 +3019,33 @@ function cMIN() {
}
cMIN.prototype = Object.create( cBaseFunction.prototype );
cMIN.prototype.Calculate = function ( arg ) {
cMINA.prototype = Object.create( cBaseFunction.prototype );
cMINA.prototype.Calculate = function ( arg ) {
var argI, argIVal, min = Number.POSITIVE_INFINITY;
for ( var i = 0; i < this.argumentsCurrent; i++ ) {
argI = arg[i], argIVal = argI.getValue();
if ( argI instanceof cRef || argI instanceof cRef3D ) {
if ( argIVal instanceof cError )
return this.value = argIVal;
if ( argIVal instanceof cNumber ) {
var v = argIVal.tocNumber();
if ( v.getValue() < min )
min = v.getValue();
}
var v = argIVal.tocNumber();
if ( v instanceof cNumber && v.getValue() < min )
min = v.getValue();
}
else if ( argI instanceof cArea || argI instanceof cArea3D ) {
var argArr = argI.getValue();
for ( var j = 0; j < argArr.length; j++ ) {
if ( argArr[j] instanceof cNumber ) {
var v = argArr[j].tocNumber();
if ( v.getValue() < min )
min = v.getValue();
continue;
}
else if ( argArr[j] instanceof cError ) {
if ( argArr[j] instanceof cError ) {
return this.value = argArr[j];
}
var v = argArr[j].tocNumber();
if ( v instanceof cNumber && v.getValue() < min )
min = v.getValue();
}
}
else if ( argI instanceof cError )
......@@ -2989,97 +3063,7 @@ cMIN.prototype.Calculate = function ( arg ) {
}
else if ( argI instanceof cArray ) {
argI.foreach( function ( elem ) {
if ( elem instanceof cNumber ) {
if ( elem.getValue() < min )
min = elem.getValue();
}
else if ( elem instanceof cError ) {
min = elem;
return true;
}
} )
if ( min instanceof cError ) {
return this.value = min;
}
}
else {
if ( argI.getValue() < min )
min = argI.getValue();
}
}
return this.value = ( min === Number.POSITIVE_INFINITY ? new cNumber( 0 ) : new cNumber( min ) );
};
cMIN.prototype.getInfo = function () {
return {
name:this.name,
args:"(number1, number2, ...)"
};
};
function cMINA() {
// cBaseFunction.call( this, "MINA" );
// this.setArgumentsMin( 1 );
// this.setArgumentsMax( 255 );
this.name = "MINA";
this.type = cElementType.func;
this.value = null;
this.argumentsMin = 1;
this.argumentsCurrent = 0;
this.argumentsMax = 255;
this.formatType = {
def:-1, //подразумевается формат первой ячейки входящей в формулу.
noneFormat:-2
};
this.numFormat = this.formatType.def;
}
cMINA.prototype = Object.create( cBaseFunction.prototype );
cMINA.prototype.Calculate = function ( arg ) {
var argI, argIVal, min = Number.POSITIVE_INFINITY;
for ( var i = 0; i < this.argumentsCurrent; i++ ) {
argI = arg[i], argIVal = argI.getValue();
if ( argI instanceof cRef || argI instanceof cRef3D ) {
if ( argIVal instanceof cError )
return this.value = argIVal;
var v = argIVal.tocNumber();
if ( v instanceof cNumber && v.getValue() < min )
min = v.getValue();
}
else if ( argI instanceof cArea || argI instanceof cArea3D ) {
var argArr = argI.getValue();
for ( var j = 0; j < argArr.length; j++ ) {
if ( argArr[j] instanceof cError ) {
return this.value = argArr[j];
}
var v = argArr[j].tocNumber();
if ( v instanceof cNumber && v.getValue() < min )
min = v.getValue();
}
}
else if ( argI instanceof cError )
return this.value = argI;
else if ( argI instanceof cString ) {
var v = argI.tocNumber();
if ( v instanceof cNumber )
if ( v.getValue() < min )
min = v.getValue();
}
else if ( argI instanceof cBool || argI instanceof cEmpty ) {
var v = argI.tocNumber();
if ( v.getValue() < min )
min = v.getValue();
}
else if ( argI instanceof cArray ) {
argI.foreach( function ( elem ) {
if ( elem instanceof cError ) {
if ( elem instanceof cError ) {
min = elem;
return true;
}
......@@ -4724,82 +4708,76 @@ cSTANDARDIZE.prototype.getInfo = function () {
};
};
function cSTDEV() {
// cBaseFunction.call( this, "STDEV" );
// this.setArgumentsMin( 1 );
// this.setArgumentsMax( 255 );
// this.setFormat( this.formatType.noneFormat );
this.name = "STDEV";
this.type = cElementType.func;
this.value = null;
this.argumentsMin = 1;
this.argumentsCurrent = 0;
this.argumentsMax = 255;
this.formatType = {
def:-1, //подразумевается формат первой ячейки входящей в формулу.
noneFormat:-2
};
this.numFormat = this.formatType.noneFormat;
}
cSTDEV.prototype = Object.create( cBaseFunction.prototype );
cSTDEV.prototype.Calculate = function ( arg ) {
var count = 0, sum = new cNumber( 0 ), member = [];
for ( var i = 0; i < arg.length; i++ ) {
var _arg = arg[i];
if ( _arg instanceof cRef || _arg instanceof cRef3D ) {
var _argV = _arg.getValue();
if ( _argV instanceof cNumber ) {
member.push( _argV );
sum = _func[sum.type][_argV.type]( sum, _argV, "+" );
count++;
}
}
else if ( _arg instanceof cArea || _arg instanceof cArea3D ) {
var _argAreaValue = _arg.getValue();
for ( var j = 0; j < _argAreaValue.length; j++ ) {
var __arg = _argAreaValue[j];
if ( __arg instanceof cNumber ) {
member.push( __arg );
sum = _func[sum.type][__arg.type]( sum, __arg, "+" );
count++;
}
}
}
else if ( _arg instanceof cArray ) {
_arg.foreach( function ( elem ) {
var e = elem.tocNumber();
if ( e instanceof cNumber ) {
member.push( e );
sum = _func[sum.type][e.type]( sum, e, "+" );
count++;
}
} )
}
else {
_arg = _arg.tocNumber();
if ( _arg instanceof cNumber ) {
member.push( _arg );
sum = _func[sum.type][_arg.type]( sum, _arg, "+" );
count++;
}
}
}
var average = sum.getValue() / count, res = 0, av;
for ( var i = 0; i < member.length; i++ ) {
av = member[i] - average;
res += av * av;
}
return this.value = new cNumber( Math.sqrt( res / (count - 1) ) );
};
cSTDEV.prototype.getInfo = function () {
return {
name:this.name,
args:"( argument-list )"
};
};
/** @constructor */
function cSTDEV() {
this.name = "STDEV";
this.type = cElementType.func;
this.value = null;
this.argumentsMin = 1;
this.argumentsCurrent = 0;
this.argumentsMax = 255;
this.formatType = {
def: -1, //подразумевается формат первой ячейки входящей в формулу.
noneFormat: -2
};
this.numFormat = this.formatType.noneFormat;
}
cSTDEV.prototype = Object.create(cBaseFunction.prototype);
cSTDEV.prototype.Calculate = function (arg) {
var i, count = 0, sum = new cNumber(0), member = [];
for (i = 0; i < arg.length; i++) {
var _arg = arg[i];
if (cElementType.cell === _arg.type || cElementType.cell3D === _arg.type) {
if (!this.checkExclude || !element.isHidden(this.excludeHiddenRows)) {
var _argV = _arg.getValue();
if (cElementType.number === _argV.type) {
member.push(_argV);
sum = _func[sum.type][_argV.type](sum, _argV, "+");
count++;
}
}
} else if (cElementType.cellsRange === _arg.type || cElementType.cellsRange3D === _arg.type) {
var _argAreaValue = _arg.getValue(this.checkExclude, this.excludeHiddenRows);
for (var j = 0; j < _argAreaValue.length; j++) {
var __arg = _argAreaValue[j];
if (cElementType.number === __arg.type) {
member.push(__arg);
sum = _func[sum.type][__arg.type](sum, __arg, "+");
count++;
}
}
} else if (cElementType.array === _arg.type) {
_arg.foreach(function (elem) {
var e = elem.tocNumber();
if (cElementType.number === e.type) {
member.push(e);
sum = _func[sum.type][e.type](sum, e, "+");
count++;
}
})
} else {
_arg = _arg.tocNumber();
if (cElementType.number === _arg.type) {
member.push(_arg);
sum = _func[sum.type][_arg.type](sum, _arg, "+");
count++;
}
}
}
var average = sum.getValue() / count, res = 0, av;
for (i = 0; i < member.length; i++) {
av = member[i] - average;
res += av * av;
}
return this.value = new cNumber(Math.sqrt(res / (count - 1)));
};
cSTDEV.prototype.getInfo = function () {
return {
name: this.name, args: "( argument-list )"
};
};
function cSTDEVA() {
// cBaseFunction.call( this, "STDEVA" );
......@@ -4878,96 +4856,86 @@ cSTDEVA.prototype.getInfo = function () {
};
};
function cSTDEVP() {
// cBaseFunction.call( this, "STDEVP" );
this.name = "STDEVP";
this.type = cElementType.func;
this.value = null;
this.argumentsMin = 1;
this.argumentsCurrent = 0;
this.argumentsMax = 255;
this.formatType = {
def:-1, //подразумевается формат первой ячейки входящей в формулу.
noneFormat:-2
};
this.numFormat = this.formatType.def;
}
cSTDEVP.prototype = Object.create( cBaseFunction.prototype );
cSTDEVP.prototype.Calculate = function ( arg ) {
function _var( x ) {
var tA = [], sumSQRDeltaX = 0, _x = 0, xLength = 0;
for ( var i = 0; i < x.length; i++ ) {
if ( x[i] instanceof cNumber ) {
_x += x[i].getValue();
tA.push( x[i].getValue() );
xLength++;
}
else if ( x[i] instanceof cError ) {
return x[i];
}
}
_x /= xLength;
for ( var i = 0; i < x.length; i++ ) {
sumSQRDeltaX += (tA[i] - _x) * (tA[i] - _x)
}
return new cNumber( isNaN(_x) ? new cError( cErrorType.division_by_zero ) : Math.sqrt( sumSQRDeltaX / xLength ) );
}
var arr0 = [];
for ( var j = 0; j < arg.length; j++ ) {
var _arg = arg[j];
if ( _arg instanceof cArea || _arg instanceof cArea3D ) {
_arg.foreach2( function ( elem ) {
if ( elem instanceof cNumber || elem instanceof cError ) {
arr0.push( elem );
}
} );
}
else if ( _arg instanceof cRef || _arg instanceof cRef3D ) {
var a = _arg.getValue();
if ( a instanceof cNumber || a instanceof cError ) {
arr0.push( a );
}
}
else if ( _arg instanceof cArray ) {
_arg.foreach( function ( elem ) {
if ( elem instanceof cNumber || elem instanceof cError ) {
arr0.push( elem );
}
} );
}
else if ( _arg instanceof cNumber || _arg instanceof cBool ) {
arr0.push( _arg.tocNumber() );
}
else if ( _arg instanceof cString || _arg instanceof cEmpty ) {
arr0.push( new cNumber( 0 ) );
}
else
return this.value = new cError( cErrorType.wrong_value_type );
}
return this.value = _var( arr0 );
};
cSTDEVP.prototype.getInfo = function () {
return {
name:this.name,
args:"( argument-list )"
};
};
/** @constructor */
function cSTDEVP() {
this.name = "STDEVP";
this.type = cElementType.func;
this.value = null;
this.argumentsMin = 1;
this.argumentsCurrent = 0;
this.argumentsMax = 255;
this.formatType = {
def: -1, //подразумевается формат первой ячейки входящей в формулу.
noneFormat: -2
};
this.numFormat = this.formatType.def;
}
cSTDEVP.prototype = Object.create(cBaseFunction.prototype);
cSTDEVP.prototype.Calculate = function (arg) {
function _var(x) {
var i, tA = [], sumSQRDeltaX = 0, _x = 0, xLength = 0;
for (i = 0; i < x.length; i++) {
if (cElementType.number === x[i].type) {
_x += x[i].getValue();
tA.push(x[i].getValue());
xLength++;
} else if (cElementType.error === x[i].type) {
return x[i];
}
}
_x /= xLength;
for (i = 0; i < x.length; i++) {
sumSQRDeltaX += (tA[i] - _x) * (tA[i] - _x)
}
return new cNumber(isNaN(_x) ? new cError(cErrorType.division_by_zero) : Math.sqrt(sumSQRDeltaX / xLength));
}
var arr0 = [];
for (var j = 0; j < arg.length; j++) {
var _arg = arg[j];
if (cElementType.cellsRange === _arg.type || cElementType.cellsRange3D === _arg.type) {
var _arrVal = arg.getValue(this.checkExclude, this.excludeHiddenRows);
_arrVal.forEach(function (elem) {
if (cElementType.number === elem.type || cElementType.error === elem.type) {
arr0.push(elem);
}
});
} else if (cElementType.cell === _arg.type || cElementType.cell3D === _arg.type) {
if (!this.checkExclude || !element.isHidden(this.excludeHiddenRows)) {
var a = _arg.getValue();
if (cElementType.number === a.type || cElementType.error === a.type) {
arr0.push(a);
}
}
} else if (cElementType.array === _arg.type) {
_arg.foreach(function (elem) {
if (cElementType.number === elem.type || cElementType.error === elem.type) {
arr0.push(elem);
}
});
} else if (cElementType.number === _arg.type || cElementType.bool === _arg.type) {
arr0.push(_arg.tocNumber());
} else if (cElementType.string === _arg.type || cElementType.empty === _arg.type) {
arr0.push(new cNumber(0));
} else {
return this.value = new cError(cErrorType.wrong_value_type);
}
}
return this.value = _var(arr0);
};
cSTDEVP.prototype.getInfo = function () {
return {
name: this.name, args: "( argument-list )"
};
};
function cSTDEVPA() {
// cBaseFunction.call( this, "STDEVPA" );
......@@ -5202,104 +5170,93 @@ function cTTEST() {
cTTEST.prototype = Object.create( cBaseFunction.prototype );
function cVAR() {
// cBaseFunction.call( this, "VAR" );
// this.setArgumentsMin( 1 );
// this.setArgumentsMax( 255 );
this.name = "VAR";
this.type = cElementType.func;
this.value = null;
this.argumentsMin = 1;
this.argumentsCurrent = 0;
this.argumentsMax = 255;
this.formatType = {
def:-1, //подразумевается формат первой ячейки входящей в формулу.
noneFormat:-2
};
this.numFormat = this.formatType.def;
}
cVAR.prototype = Object.create( cBaseFunction.prototype );
cVAR.prototype.Calculate = function ( arg ) {
function _var( x ) {
if( x.length < 1 ){
return new cError( cErrorType.division_by_zero );
}
var tA = [], sumSQRDeltaX = 0, _x = 0, xLength = 0;
for ( var i = 0; i < x.length; i++ ) {
if ( x[i] instanceof cNumber ) {
_x += x[i].getValue();
tA.push( x[i].getValue() );
xLength++;
}
else if ( x[i] instanceof cError ) {
return x[i];
}
}
_x /= xLength;
for ( var i = 0; i < x.length; i++ ) {
sumSQRDeltaX += (tA[i] - _x) * (tA[i] - _x)
}
return new cNumber( sumSQRDeltaX / (xLength - 1) )
}
var arr0 = [];
for ( var j = 0; j < arg.length; j++ ) {
var _arg = arg[j];
if ( _arg instanceof cArea || _arg instanceof cArea3D ) {
_arg.foreach2( function ( elem ) {
if ( elem instanceof cNumber || elem instanceof cError ){
arr0.push( elem );
}
} );
}
else if ( _arg instanceof cRef || _arg instanceof cRef3D ) {
var a = _arg.getValue();
if ( a instanceof cNumber || a instanceof cError ){
arr0.push( a );
}
}
else if ( _arg instanceof cArray ) {
_arg.foreach( function ( elem ) {
if ( elem instanceof cNumber || elem instanceof cError ){
arr0.push( elem );
}
} );
}
else if ( _arg instanceof cNumber || _arg instanceof cBool ) {
arr0.push( _arg.tocNumber() );
}
else if ( _arg instanceof cString || _arg instanceof cEmpty ) {
continue;
}
else{
return this.value = new cError( cErrorType.wrong_value_type );
}
}
return this.value = _var( arr0 );
};
cVAR.prototype.getInfo = function () {
return {
name:this.name,
args:"( argument-list )"
};
};
/** @constructor */
function cVAR() {
this.name = "VAR";
this.type = cElementType.func;
this.value = null;
this.argumentsMin = 1;
this.argumentsCurrent = 0;
this.argumentsMax = 255;
this.formatType = {
def: -1, //подразумевается формат первой ячейки входящей в формулу.
noneFormat: -2
};
this.numFormat = this.formatType.def;
}
cVAR.prototype = Object.create(cBaseFunction.prototype);
cVAR.prototype.Calculate = function (arg) {
function _var(x) {
if (x.length < 1) {
return new cError(cErrorType.division_by_zero);
}
var i, tA = [], sumSQRDeltaX = 0, _x = 0, xLength = 0;
for (i = 0; i < x.length; i++) {
if (cElementType.number === x[i].type) {
_x += x[i].getValue();
tA.push(x[i].getValue());
xLength++;
} else if (cElementType.error === x[i].type) {
return x[i];
}
}
_x /= xLength;
for (i = 0; i < x.length; i++) {
sumSQRDeltaX += (tA[i] - _x) * (tA[i] - _x)
}
return new cNumber(sumSQRDeltaX / (xLength - 1))
}
var arr0 = [];
for (var j = 0; j < arg.length; j++) {
var _arg = arg[j];
if (cElementType.cellsRange === _arg.type || cElementType.cellsRange3D === _arg.type) {
var _arrVal = _arg.getValue(this.checkExclude, this.excludeHiddenRows);
_arrVal.forEach(function (elem) {
if (cElementType.number === elem.type || cElementType.error === elem.type) {
arr0.push(elem);
}
});
} else if (cElementType.cell === _arg.type || cElementType.cell3D === _arg.type) {
if (!this.checkExclude || !element.isHidden(this.excludeHiddenRows)) {
var a = _arg.getValue();
if (cElementType.number === a.type || cElementType.error === a.type) {
arr0.push(a);
}
}
} else if (cElementType.array === _arg.type) {
_arg.foreach(function (elem) {
if (cElementType.number === elem.type || cElementType.error === elem.type) {
arr0.push(elem);
}
});
} else if (cElementType.number === _arg.type || cElementType.bool === _arg.type) {
arr0.push(_arg.tocNumber());
} else if (cElementType.string === _arg.type || cElementType.empty === _arg.type) {
continue;
} else {
return this.value = new cError(cErrorType.wrong_value_type);
}
}
return this.value = _var(arr0);
};
cVAR.prototype.getInfo = function () {
return {
name: this.name, args: "( argument-list )"
};
};
function cVARA() {
// cBaseFunction.call( this, "VARA" );
......@@ -5415,100 +5372,92 @@ cVARA.prototype.getInfo = function () {
};
};
function cVARP() {
// cBaseFunction.call( this, "VARP" );
this.name = "VARP";
this.type = cElementType.func;
this.value = null;
this.argumentsMin = 1;
this.argumentsCurrent = 0;
this.argumentsMax = 255;
this.formatType = {
def:-1, //подразумевается формат первой ячейки входящей в формулу.
noneFormat:-2
};
this.numFormat = this.formatType.def;
}
cVARP.prototype = Object.create( cBaseFunction.prototype );
cVARP.prototype.Calculate = function ( arg ) {
function _var( x ) {
if( x.length < 1 ){
return new cError( cErrorType.division_by_zero );
}
var tA = [], sumSQRDeltaX = 0, _x = 0, xLength = 0;
for ( var i = 0; i < x.length; i++ ) {
if ( x[i] instanceof cNumber ) {
_x += x[i].getValue();
tA.push( x[i].getValue() );
xLength++;
}
else if ( x[i] instanceof cError ) {
return x[i];
}
}
_x /= xLength;
for ( var i = 0; i < x.length; i++ ) {
sumSQRDeltaX += (tA[i] - _x) * (tA[i] - _x);
}
return new cNumber( sumSQRDeltaX / xLength );
}
var arr0 = [];
for ( var j = 0; j < arg.length; j++ ) {
var _arg = arg[j];
if ( _arg instanceof cArea || _arg instanceof cArea3D ) {
_arg.foreach2( function ( elem ) {
if ( elem instanceof cNumber || elem instanceof cError ) {
arr0.push( elem );
}
} );
}
else if ( _arg instanceof cRef || _arg instanceof cRef3D ) {
var a = _arg.getValue();
if ( a instanceof cNumber || a instanceof cError ) {
arr0.push( a );
}
}
else if ( _arg instanceof cArray ) {
_arg.foreach( function ( elem ) {
if ( elem instanceof cNumber || elem instanceof cError ) {
arr0.push( elem );
}
} );
}
else if ( _arg instanceof cNumber || _arg instanceof cBool ) {
arr0.push( _arg.tocNumber() );
}
else if ( _arg instanceof cString || _arg instanceof cEmpty ) {
arr0.push( new cNumber( 0 ) );
}
else
return this.value = new cError( cErrorType.wrong_value_type );
}
return this.value = _var( arr0 );
};
cVARP.prototype.getInfo = function () {
return {
name:this.name,
args:"( argument-list )"
};
};
/** @constructor */
function cVARP() {
this.name = "VARP";
this.type = cElementType.func;
this.value = null;
this.argumentsMin = 1;
this.argumentsCurrent = 0;
this.argumentsMax = 255;
this.formatType = {
def: -1, //подразумевается формат первой ячейки входящей в формулу.
noneFormat: -2
};
this.numFormat = this.formatType.def;
}
cVARP.prototype = Object.create(cBaseFunction.prototype);
cVARP.prototype.Calculate = function (arg) {
function _var(x) {
if (x.length < 1) {
return new cError(cErrorType.division_by_zero);
}
var tA = [], sumSQRDeltaX = 0, _x = 0, xLength = 0;
for (var i = 0; i < x.length; i++) {
if (cElementType.number === x[i].type) {
_x += x[i].getValue();
tA.push(x[i].getValue());
xLength++;
} else if (cElementType.error === x[i].type) {
return x[i];
}
}
_x /= xLength;
for (var i = 0; i < x.length; i++) {
sumSQRDeltaX += (tA[i] - _x) * (tA[i] - _x);
}
return new cNumber(sumSQRDeltaX / xLength);
}
var arr0 = [];
for (var j = 0; j < arg.length; j++) {
var _arg = arg[j];
if (cElementType.cellsRange === _arg.type || cElementType.cellsRange3D === _arg.type) {
var _arrVal = _arg.getValue(this.checkExclude, this.excludeHiddenRows);
_arrVal.forEach(function (elem) {
if (cElementType.number === elem.type || cElementType.error === elem.type) {
arr0.push(elem);
}
});
} else if (cElementType.cell === _arg.type || cElementType.cell3D === _arg.type) {
if (!this.checkExclude || !element.isHidden(this.excludeHiddenRows)) {
var a = _arg.getValue();
if (cElementType.number === a.type || cElementType.error === a.type) {
arr0.push(a);
}
}
} else if (cElementType.array === _arg.type) {
_arg.foreach(function (elem) {
if (cElementType.number === elem.type || cElementType.error === elem.type) {
arr0.push(elem);
}
});
} else if (cElementType.number === _arg.type || cElementType.bool === _arg.type) {
arr0.push(_arg.tocNumber());
} else if (cElementType.string === _arg.type || cElementType.empty === _arg.type) {
arr0.push(new cNumber(0));
} else {
return this.value = new cError(cErrorType.wrong_value_type);
}
}
return this.value = _var(arr0);
};
cVARP.prototype.getInfo = function () {
return {
name: this.name, args: "( argument-list )"
};
};
function cVARdotP() {
// cBaseFunction.call( this, "VARP" );
......
......@@ -5465,7 +5465,7 @@ Woorksheet.prototype.getTableNameColumnByIndex = function(tableName, columnIndex
}
return res;
};
Woorksheet.prototype.bIsApplyFilterBySheet = function(){
Woorksheet.prototype.isApplyFilterBySheet = function(){
var res = false;
if(this.AutoFilter && this.AutoFilter.isApplyAutoFilter())
......
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