import org.apache.poi.ss.formula.eval.ValueEval;
import org.apache.poi.ss.formula.function.FunctionMetadata;
import org.apache.poi.ss.formula.function.FunctionMetadataRegistry;
-import org.apache.poi.ss.formula.functions.EDate;
-import org.apache.poi.ss.formula.functions.FreeRefFunction;
-import org.apache.poi.ss.formula.functions.Sumifs;
+import org.apache.poi.ss.formula.functions.*;
import org.apache.poi.ss.formula.udf.UDFFinder;
import java.util.*;
r(m, "BIN2DEC", null);
r(m, "BIN2HEX", null);
r(m, "BIN2OCT", null);
- r(m, "COMPLEX", null);
+ r(m, "COMPLEX", Complex.instance);
r(m, "CONVERT", null);
r(m, "COUNTIFS", null);
r(m, "COUPDAYBS", null);
package org.apache.poi.ss.formula.functions;\r
\r
+import org.apache.poi.ss.formula.OperationEvaluationContext;\r
import org.apache.poi.ss.formula.eval.*;\r
\r
/**\r
*\r
* @author cedric dot walter @ gmail dot com\r
*/\r
-public class Complex extends Var2or3ArgFunction {\r
+public class Complex extends Var2or3ArgFunction implements FreeRefFunction {\r
+\r
+ public static final FreeRefFunction instance = new Complex();\r
\r
public static final String DEFAULT_SUFFIX = "i";\r
public static final String SUPPORTED_SUFFIX = "j";\r
return (number == Math.floor(number)) && !Double.isInfinite(number);\r
}\r
\r
+ @Override\r
+ public ValueEval evaluate(ValueEval[] args, OperationEvaluationContext ec) {\r
+ if (args.length == 2) {\r
+ return evaluate(ec.getRowIndex(), ec.getColumnIndex(), args[0], args[1]);\r
+ }\r
+ if (args.length == 3) {\r
+ return evaluate(ec.getRowIndex(), ec.getColumnIndex(), args[0], args[1], args[2]);\r
+ }\r
+\r
+ return ErrorEval.VALUE_INVALID;\r
+ }\r
}\r