mirror of https://github.com/apache/poi.git
Bug 55037: patch for missing function DELTA
Add missing TestDeltaFunctionsFromSpreadsheet and register Delta in AnalysisToolPak git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1529809 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
927dc0ce1d
commit
805d583bab
|
@ -91,7 +91,7 @@ public final class AnalysisToolPak implements UDFFinder {
|
|||
r(m, "DEC2BIN", null);
|
||||
r(m, "DEC2HEX", null);
|
||||
r(m, "DEC2OCT", null);
|
||||
r(m, "DELTA", null);
|
||||
r(m, "DELTA", Delta.instance);
|
||||
r(m, "DISC", null);
|
||||
r(m, "DOLLARDE", null);
|
||||
r(m, "DOLLARFR", null);
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
package org.apache.poi.ss.formula.functions;
|
||||
|
||||
import org.apache.poi.ss.formula.OperationEvaluationContext;
|
||||
import org.apache.poi.ss.formula.eval.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
@ -37,7 +38,9 @@ import java.math.BigDecimal;
|
|||
*
|
||||
* @author cedric dot walter @ gmail dot com
|
||||
*/
|
||||
public final class Delta extends Fixed2ArgFunction {
|
||||
public final class Delta extends Fixed2ArgFunction implements FreeRefFunction {
|
||||
|
||||
public static final FreeRefFunction instance = new Delta();
|
||||
|
||||
private final static NumberEval ONE = new NumberEval(1);
|
||||
private final static NumberEval ZERO = new NumberEval(0);
|
||||
|
@ -72,4 +75,11 @@ public final class Delta extends Fixed2ArgFunction {
|
|||
return result == 0 ? ONE : ZERO;
|
||||
}
|
||||
|
||||
public ValueEval evaluate(ValueEval[] args, OperationEvaluationContext ec) {
|
||||
if (args.length == 2) {
|
||||
return evaluate(ec.getRowIndex(), ec.getColumnIndex(), args[0], args[1]);
|
||||
}
|
||||
|
||||
return ErrorEval.VALUE_INVALID;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package org.apache.poi.ss.formula.functions;
|
||||
|
||||
/**
|
||||
* Tests DELTA() as loaded from a test data spreadsheet.<p/>
|
||||
*
|
||||
* @author cedric dot walter @ gmail dot com
|
||||
*/
|
||||
public class TestDeltaFunctionsFromSpreadsheet extends BaseTestFunctionsFromSpreadsheet {
|
||||
|
||||
protected String getFilename() {
|
||||
return "DeltaFunctionTestCaseData.xls";
|
||||
}
|
||||
}
|
Binary file not shown.
Loading…
Reference in New Issue