Browse Source

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
tags/REL_3_10_FINAL
Cédric Walter 10 years ago
parent
commit
805d583bab

+ 1
- 1
src/java/org/apache/poi/ss/formula/atp/AnalysisToolPak.java View File

@@ -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);

+ 11
- 1
src/java/org/apache/poi/ss/formula/functions/Delta.java View File

@@ -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;
}
}

+ 13
- 0
src/testcases/org/apache/poi/ss/formula/functions/TestDeltaFunctionsFromSpreadsheet.java View File

@@ -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";
}
}

BIN
test-data/spreadsheet/DeltaFunctionTestCaseData.xls View File


Loading…
Cancel
Save