Commit 122e1e5c authored by GoshaZotov's avatar GoshaZotov

add IFNA formula

parent 729ef67c
...@@ -4312,6 +4312,14 @@ $( function () { ...@@ -4312,6 +4312,14 @@ $( function () {
} ); } );
test( "Test: \"IFNA\"", function () {
oParser = new parserFormula( 'IFNA(MATCH(30,B1:B5,0),"Not found")', "A2", ws );
ok( oParser.parse(), 'IFNA(MATCH(30,B1:B5,0),"Not found")' );
strictEqual( oParser.calculate().getValue(), "Not found", 'IFNA(MATCH(30,B1:B5,0),"Not found")' );
} );
test( "Test: \"XNPV\"", function () { test( "Test: \"XNPV\"", function () {
function xnpv( rate, valueArray, dateArray ){ function xnpv( rate, valueArray, dateArray ){
......
...@@ -73,8 +73,6 @@ ...@@ -73,8 +73,6 @@
cFormulaFunctionGroup['LookupAndReference'].push(cFORMULATEXT); cFormulaFunctionGroup['LookupAndReference'].push(cFORMULATEXT);
cFormulaFunctionGroup['Information'] = cFormulaFunctionGroup['Information'] || []; cFormulaFunctionGroup['Information'] = cFormulaFunctionGroup['Information'] || [];
cFormulaFunctionGroup['Information'].push(cISFORMULA, cSHEET, cSHEETS); cFormulaFunctionGroup['Information'].push(cISFORMULA, cSHEET, cSHEETS);
cFormulaFunctionGroup['Logical'] = cFormulaFunctionGroup['Logical'] || [];
cFormulaFunctionGroup['Logical'].push(cIFNA);
/** /**
* @constructor * @constructor
...@@ -604,18 +602,6 @@ ...@@ -604,18 +602,6 @@
cHYPGEOM_DIST.prototype = Object.create(cBaseFunction.prototype); cHYPGEOM_DIST.prototype = Object.create(cBaseFunction.prototype);
cHYPGEOM_DIST.prototype.constructor = cHYPGEOM_DIST; cHYPGEOM_DIST.prototype.constructor = cHYPGEOM_DIST;
/**
* @constructor
* @extends {AscCommonExcel.cBaseFunction}
*/
function cIFNA() {
cBaseFunction.call(this, "IFNA");
this.isXLFN = true;
}
cIFNA.prototype = Object.create(cBaseFunction.prototype);
cIFNA.prototype.constructor = cIFNA;
/** /**
* @constructor * @constructor
* @extends {AscCommonExcel.cBaseFunction} * @extends {AscCommonExcel.cBaseFunction}
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
var cFormulaFunctionGroup = AscCommonExcel.cFormulaFunctionGroup; var cFormulaFunctionGroup = AscCommonExcel.cFormulaFunctionGroup;
cFormulaFunctionGroup['Logical'] = cFormulaFunctionGroup['Logical'] || []; cFormulaFunctionGroup['Logical'] = cFormulaFunctionGroup['Logical'] || [];
cFormulaFunctionGroup['Logical'].push(cAND, cFALSE, cIF, cIFERROR, cNOT, cOR, cTRUE, cXOR); cFormulaFunctionGroup['Logical'].push(cAND, cFALSE, cIF, cIFERROR, cIFNA, cNOT, cOR, cTRUE, cXOR);
/** /**
* @constructor * @constructor
...@@ -237,6 +237,45 @@ ...@@ -237,6 +237,45 @@
}; };
}; };
/**
* @constructor
* @extends {AscCommonExcel.cBaseFunction}
*/
function cIFNA() {
this.name = "IFNA";
this.value = null;
this.argumentsCurrent = 0;
}
cIFNA.prototype = Object.create(cBaseFunction.prototype);
cIFNA.prototype.constructor = cIFNA;
cIFNA.prototype.argumentsMin = 2;
cIFNA.prototype.argumentsMax = 2;
cIFNA.prototype.isXLFN = true;
cIFNA.prototype.Calculate = function (arg) {
var arg0 = arg[0];
if (arg0 instanceof cArray) {
arg0 = arg0.getElement(0);
}
if (arg0 instanceof AscCommonExcel.cRef || arg0 instanceof AscCommonExcel.cRef3D) {
arg0 = arg0.getValue();
}
if (arg0 instanceof cArea || arg0 instanceof cArea3D) {
arg0 = arg0.cross(arguments[1]);
}
if (arg0 instanceof cError && cErrorType.not_available === arg0.errorType) {
return this.value = arg[1] instanceof cArray ? arg[1].getElement(0) : arg[1];
} else {
return this.value = arg[0];
}
};
cIFNA.prototype.getInfo = function () {
return {
name: this.name, args: "(value, value_if_na)"
};
};
/** /**
* @constructor * @constructor
* @extends {AscCommonExcel.cBaseFunction} * @extends {AscCommonExcel.cBaseFunction}
......
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