From 176f64cfe3e6f566d650f0730e2e5ec1522d7d3a Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Mon, 23 May 2022 13:49:50 +0000 Subject: [PATCH] partial implementation FLOOR.MATH function (needs more testing and bad param support) git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1901171 13f79535-47bb-0310-9956-ffa450edef68 --- .../poi/ss/formula/atp/AnalysisToolPak.java | 1 + .../poi/ss/formula/functions/CeilingMath.java | 15 +--- .../poi/ss/formula/functions/FloorMath.java | 83 +++++++++++++++++++ .../poi/ss/formula/functions/MathX.java | 27 +++++- .../ss/formula/functions/TestCeilingMath.java | 4 - .../ss/formula/functions/TestFloorMath.java | 74 +++++++++++++++++ 6 files changed, 187 insertions(+), 17 deletions(-) create mode 100644 poi/src/main/java/org/apache/poi/ss/formula/functions/FloorMath.java create mode 100644 poi/src/test/java/org/apache/poi/ss/formula/functions/TestFloorMath.java diff --git a/poi/src/main/java/org/apache/poi/ss/formula/atp/AnalysisToolPak.java b/poi/src/main/java/org/apache/poi/ss/formula/atp/AnalysisToolPak.java index 1482a39197..bf92661089 100644 --- a/poi/src/main/java/org/apache/poi/ss/formula/atp/AnalysisToolPak.java +++ b/poi/src/main/java/org/apache/poi/ss/formula/atp/AnalysisToolPak.java @@ -112,6 +112,7 @@ public final class AnalysisToolPak implements UDFFinder { r(m, "ERF", null); r(m, "ERFC", null); r(m, "FACTDOUBLE", FactDouble.instance); + r(m, "FLOOR.MATH", FloorMath.instance); r(m, "FVSCHEDULE", null); r(m, "GCD", Gcd.instance); r(m, "GESTEP", null); diff --git a/poi/src/main/java/org/apache/poi/ss/formula/functions/CeilingMath.java b/poi/src/main/java/org/apache/poi/ss/formula/functions/CeilingMath.java index 8ca82f7c2e..6c84abfea0 100644 --- a/poi/src/main/java/org/apache/poi/ss/formula/functions/CeilingMath.java +++ b/poi/src/main/java/org/apache/poi/ss/formula/functions/CeilingMath.java @@ -24,9 +24,10 @@ import org.apache.poi.ss.formula.eval.NumberEval; import org.apache.poi.ss.formula.eval.OperandResolver; import org.apache.poi.ss.formula.eval.ValueEval; -import java.math.BigDecimal; import java.math.RoundingMode; +import static org.apache.poi.ss.formula.functions.MathX.scaledRoundUsingBigDecimal; + /** * Implementation for Excel CEILING.MATH() function. *