Commit 5ceefeea authored by GoshaZotov's avatar GoshaZotov

add check on errors/subtotal/aggregate cell values into cArea/cArea3D...

add check on errors/subtotal/aggregate cell values into cArea/cArea3D functions (need by cAggregate function)
parent 674e958b
......@@ -404,7 +404,7 @@
var nOption = argClone[1].getValue();
var ignoreHiddenRows = false;
var ignoreErrors = false;
var ignoreErrorsVal = false;
var ignoreNestedStAg = false;
switch ( nOption) {
case 0 : // ignore nested SUBTOTAL and AGGREGATE functions
......@@ -416,12 +416,12 @@
break;
case 2 : // ignore error values, nested SUBTOTAL and AGGREGATE functions
ignoreNestedStAg = true;
ignoreErrors = true;
ignoreHiddenRows = true;
break;
case 3 : // ignore hidden rows, error values, nested SUBTOTAL and AGGREGATE functions
ignoreNestedStAg = true;
ignoreHiddenRows = true;
ignoreErrors = true;
ignoreHiddenRows = true;
break;
case 4 : // ignore nothing
break;
......@@ -429,23 +429,26 @@
ignoreHiddenRows = true;
break;
case 6 : // ignore error values
ignoreErrors = true;
ignoreHiddenRows = true;
break;
case 7 : // ignore hidden rows and error values
ignoreHiddenRows = true;
ignoreErrors = true;
ignoreHiddenRows = true;
break;
default :
return this.value = new cError(cErrorType.not_numeric);
}
if (f) {
//f.checkExclude = true;
f.excludeHiddenRows = ignoreHiddenRows;
f.excludeErrorsVal = ignoreErrorsVal;
f.excludeNestedStAg = ignoreNestedStAg;
var newArgs = [];
for(var i = 2; i < arg.length; i++){
newArgs.push(arg[i]);
}
f.setArgumentsCount(newArgs.length);
this.value = f.Calculate(newArgs);
}
......@@ -5128,5 +5131,7 @@
window['AscCommonExcel'].cPRODUCT = cPRODUCT;
window['AscCommonExcel'].cSUM = cSUM;
window['AscCommonExcel'].cAGGREGATE = cAGGREGATE;
window['AscCommonExcel'].cSUBTOTAL = cSUBTOTAL;
})(window);
......@@ -970,7 +970,7 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara
cArea.prototype.getWsId = function () {
return this.ws.Id;
};
cArea.prototype.getValue = function (checkExclude, excludeHiddenRows) {
cArea.prototype.getValue = function (checkExclude, excludeHiddenRows, excludeErrorsVal, excludeNestedStAg) {
var val = [], r = this.getRange();
if (!r) {
val.push(new cError(cErrorType.bad_reference));
......@@ -979,7 +979,23 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara
excludeHiddenRows = this.ws.isApplyFilterBySheet();
}
r._foreachNoEmpty(function (cell) {
val.push(checkTypeCell(cell));
var bIsFoundNestedStAg = false;
if(excludeNestedStAg && cell.formulaParsed && cell.formulaParsed.outStack){
var outStack = cell.formulaParsed.outStack;
for(var i = 0; i < outStack.length; i++){
if(outStack[i] instanceof AscCommonExcel.cAGGREGATE || outStack[i] instanceof AscCommonExcel.cSUBTOTAL){
bIsFoundNestedStAg = true;
break;
}
}
}
if(!bIsFoundNestedStAg){
var checkTypeVal = checkTypeCell(cell);
if(!(excludeErrorsVal && CellValueType.Error === checkTypeVal.type)){
val.push(checkTypeVal);
}
}
}, excludeHiddenRows);
}
return val;
......@@ -1179,7 +1195,7 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara
cArea3D.prototype.getRanges = function () {
return (this.range(this.wsRange()));
};
cArea3D.prototype.getValue = function (checkExclude, excludeHiddenRows) {
cArea3D.prototype.getValue = function (checkExclude, excludeHiddenRows, excludeErrorsVal, excludeNestedStAg) {
var i, _wsA = this.wsRange();
var _val = [];
if (_wsA.length < 1) {
......@@ -1203,8 +1219,25 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara
if (checkExclude && !(_exclude = excludeHiddenRows)) {
_exclude = _wsA[i].isApplyFilterBySheet();
}
_r[i]._foreachNoEmpty(function (cell) {
_val.push(checkTypeCell(cell));
var bIsFoundNestedStAg = false;
if(excludeNestedStAg && cell.formulaParsed && cell.formulaParsed.outStack){
var outStack = cell.formulaParsed.outStack;
for(var i = 0; i < outStack.length; i++){
if(outStack[i] instanceof AscCommonExcel.cAGGREGATE || outStack[i] instanceof AscCommonExcel.cSUBTOTAL){
bIsFoundNestedStAg = true;
break;
}
}
}
if(!bIsFoundNestedStAg){
var checkTypeVal = checkTypeCell(cell);
if(!(excludeErrorsVal && CellValueType.Error === checkTypeVal.type)){
_val.push(checkTypeVal);
}
}
}, _exclude);
}
return _val;
......
......@@ -1464,7 +1464,7 @@
}
}
} else if (cElementType.cellsRange === _arg.type || cElementType.cellsRange3D === _arg.type) {
var _argAreaValue = _arg.getValue(this.checkExclude, this.excludeHiddenRows);
var _argAreaValue = _arg.getValue(this.checkExclude, this.excludeHiddenRows, this.excludeErrorsVal, this.excludeNestedStAg);
for (var j = 0; j < _argAreaValue.length; j++) {
var __arg = _argAreaValue[j];
if (cElementType.string === __arg.type || cElementType.empty === __arg.type ||
......@@ -2505,7 +2505,7 @@
}
}
} else if (cElementType.cellsRange === _arg.type || cElementType.cellsRange3D === _arg.type) {
var _argAreaValue = _arg.getValue(this.checkExclude, this.excludeHiddenRows);
var _argAreaValue = _arg.getValue(this.checkExclude, this.excludeHiddenRows, this.excludeErrorsVal, this.excludeNestedStAg);
for (var j = 0; j < _argAreaValue.length; j++) {
if (cElementType.number === _argAreaValue[j].type) {
count++;
......@@ -2555,7 +2555,7 @@
}
}
} else if (cElementType.cellsRange === element.type || cElementType.cellsRange3D === element.type) {
var _argAreaValue = element.getValue(this.checkExclude, this.excludeHiddenRows);
var _argAreaValue = element.getValue(this.checkExclude, this.excludeHiddenRows, this.excludeErrorsVal, this.excludeNestedStAg);
for (var j = 0; j < _argAreaValue.length; j++) {
if (cElementType.empty !== _argAreaValue[j].type) {
count++;
......@@ -4881,7 +4881,7 @@
}
}
} else if (cElementType.cellsRange === element.type || cElementType.cellsRange3D === element.type) {
var argArr = element.getValue(this.checkExclude, this.excludeHiddenRows);
var argArr = element.getValue(this.checkExclude, this.excludeHiddenRows, this.excludeErrorsVal, this.excludeNestedStAg);
for (var j = 0; j < argArr.length; j++) {
if (cElementType.number === argArr[j].type) {
v = argArr[j].tocNumber();
......@@ -5324,7 +5324,7 @@
}
}
} else if (cElementType.cellsRange === element.type || cElementType.cellsRange3D === element.type) {
var argArr = element.getValue(this.checkExclude, this.excludeHiddenRows);
var argArr = element.getValue(this.checkExclude, this.excludeHiddenRows, this.excludeErrorsVal, this.excludeNestedStAg);
for (var j = 0; j < argArr.length; j++) {
if (cElementType.number === argArr[j].type) {
v = argArr[j].tocNumber();
......@@ -7252,7 +7252,7 @@
}
}
} else if (cElementType.cellsRange === element.type || cElementType.cellsRange3D === element.type) {
var _argAreaValue = element.getValue(this.checkExclude, this.excludeHiddenRows);
var _argAreaValue = element.getValue(this.checkExclude, this.excludeHiddenRows, this.excludeErrorsVal, this.excludeNestedStAg);
for (var j = 0; j < _argAreaValue.length; j++) {
var __arg = _argAreaValue[j];
if (cElementType.number === __arg.type) {
......@@ -7403,7 +7403,7 @@
for (var j = 0; j < arg.length; j++) {
element = arg[j];
if (cElementType.cellsRange === element.type || cElementType.cellsRange3D === element.type) {
var _arrVal = element.getValue(this.checkExclude, this.excludeHiddenRows);
var _arrVal = element.getValue(this.checkExclude, this.excludeHiddenRows, this.excludeErrorsVal, this.excludeNestedStAg);
_arrVal.forEach(function (elem) {
if (cElementType.number === elem.type || cElementType.error === elem.type) {
arr0.push(elem);
......@@ -8115,7 +8115,7 @@
for (var j = 0; j < arg.length; j++) {
element = arg[j];
if (cElementType.cellsRange === element.type || cElementType.cellsRange3D === element.type) {
var _arrVal = element.getValue(this.checkExclude, this.excludeHiddenRows);
var _arrVal = element.getValue(this.checkExclude, this.excludeHiddenRows, this.excludeErrorsVal, this.excludeNestedStAg);
_arrVal.forEach(function (elem) {
if (cElementType.number === elem.type || cElementType.error === elem.type) {
arr0.push(elem);
......@@ -8285,7 +8285,7 @@
for (var j = 0; j < arg.length; j++) {
element = arg[j];
if (cElementType.cellsRange === element.type || cElementType.cellsRange3D === element.type) {
var _arrVal = element.getValue(this.checkExclude, this.excludeHiddenRows);
var _arrVal = element.getValue(this.checkExclude, this.excludeHiddenRows, this.excludeErrorsVal, this.excludeNestedStAg);
_arrVal.forEach(function (elem) {
if (cElementType.number === elem.type || cElementType.error === elem.type) {
arr0.push(elem);
......@@ -8376,7 +8376,7 @@
for (var j = 0; j < arg.length; j++) {
element = arg[j];
if (cElementType.cellsRange === element.type || cElementType.cellsRange3D === element.type) {
var _arrVal = element.getValue(this.checkExclude, this.excludeHiddenRows);
var _arrVal = element.getValue(this.checkExclude, this.excludeHiddenRows, this.excludeErrorsVal, this.excludeNestedStAg);
_arrVal.forEach(function (elem) {
if (cElementType.number === elem.type || cElementType.error === elem.type) {
arr0.push(elem);
......
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