private static Function[] produceFunctions() {
Function[] retval = new Function[368];
retval[0] = new Count(); // COUNT
- retval[1] = null; // Specialflag(); // SPECIALFLAG
+ retval[1] = new If(); // IF
retval[2] = new IsNa(); // ISNA
retval[3] = new IsError(); // ISERROR
retval[4] = new Sum(); // SUM
--- /dev/null
+/*\r
+ * Created on Nov 25, 2006\r
+ *\r
+ */\r
+package org.apache.poi.hssf.record.formula.functions;\r
+\r
+import org.apache.poi.hssf.record.formula.eval.BoolEval;\r
+import org.apache.poi.hssf.record.formula.eval.ErrorEval;\r
+import org.apache.poi.hssf.record.formula.eval.Eval;\r
+\r
+/**\r
+ * @author Amol S. Deshmukh < amolweb at ya hoo dot com >\r
+ * \r
+ */\r
+public class If implements Function {\r
+\r
+ public Eval evaluate(Eval[] evals, int srcCellRow, short srcCellCol) {\r
+ Eval retval = null;\r
+ Eval evalWhenFalse = BoolEval.FALSE;\r
+ switch (evals.length) {\r
+ case 3:\r
+ evalWhenFalse = evals[2];\r
+ case 2:\r
+ BoolEval beval = (BoolEval) evals[0];\r
+ if (beval.getBooleanValue()) {\r
+ retval = evals[1];\r
+ }\r
+ else {\r
+ retval = evalWhenFalse;\r
+ }\r
+ break;\r
+ default:\r
+ retval = ErrorEval.UNKNOWN_ERROR;\r
+ }\r
+ return retval;\r
+ }\r
+\r
+\r
+}\r