mirror of https://github.com/apache/poi.git
implemented IF() function
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@479289 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
17fd168dbc
commit
2b0eb9be33
|
@ -23,7 +23,7 @@ public abstract class FunctionEval implements OperationEval {
|
||||||
private static Function[] produceFunctions() {
|
private static Function[] produceFunctions() {
|
||||||
Function[] retval = new Function[368];
|
Function[] retval = new Function[368];
|
||||||
retval[0] = new Count(); // COUNT
|
retval[0] = new Count(); // COUNT
|
||||||
retval[1] = null; // Specialflag(); // SPECIALFLAG
|
retval[1] = new If(); // IF
|
||||||
retval[2] = new IsNa(); // ISNA
|
retval[2] = new IsNa(); // ISNA
|
||||||
retval[3] = new IsError(); // ISERROR
|
retval[3] = new IsError(); // ISERROR
|
||||||
retval[4] = new Sum(); // SUM
|
retval[4] = new Sum(); // SUM
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
/*
|
||||||
|
* Created on Nov 25, 2006
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.apache.poi.hssf.record.formula.functions;
|
||||||
|
|
||||||
|
import org.apache.poi.hssf.record.formula.eval.BoolEval;
|
||||||
|
import org.apache.poi.hssf.record.formula.eval.ErrorEval;
|
||||||
|
import org.apache.poi.hssf.record.formula.eval.Eval;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Amol S. Deshmukh < amolweb at ya hoo dot com >
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class If implements Function {
|
||||||
|
|
||||||
|
public Eval evaluate(Eval[] evals, int srcCellRow, short srcCellCol) {
|
||||||
|
Eval retval = null;
|
||||||
|
Eval evalWhenFalse = BoolEval.FALSE;
|
||||||
|
switch (evals.length) {
|
||||||
|
case 3:
|
||||||
|
evalWhenFalse = evals[2];
|
||||||
|
case 2:
|
||||||
|
BoolEval beval = (BoolEval) evals[0];
|
||||||
|
if (beval.getBooleanValue()) {
|
||||||
|
retval = evals[1];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
retval = evalWhenFalse;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
retval = ErrorEval.UNKNOWN_ERROR;
|
||||||
|
}
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue