]> source.dussan.org Git - poi.git/commitdiff
[bug-49202] add PERCENTRANK function
authorPJ Fanning <fanningpj@apache.org>
Sat, 7 Aug 2021 14:27:41 +0000 (14:27 +0000)
committerPJ Fanning <fanningpj@apache.org>
Sat, 7 Aug 2021 14:27:41 +0000 (14:27 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1892078 13f79535-47bb-0310-9956-ffa450edef68

poi/src/main/java/org/apache/poi/ss/formula/functions/PercentRank.java
poi/src/test/java/org/apache/poi/ss/formula/functions/TestPercentRank.java

index 03a9ae54bcfab7e44503c4ccf62c1e327d36a89e..115adf647e1b2e9b9f8f21b863ab2a87eadd5c4a 100644 (file)
@@ -89,6 +89,9 @@ public final class PercentRank implements Function {
             try {
                 ValueEval ev = OperandResolver.getSingleValue(args[2], srcRowIndex, srcColumnIndex);
                 significance = OperandResolver.coerceValueToInt(ev);
+                if (significance < 1) {
+                    return ErrorEval.NUM_ERROR;
+                }
             } catch (EvaluationException e) {
                 return e.getErrorEval();
             }
index 6d96426dd98a8575c9d01d5b240218e84bce8c7b..3892a3eb1d284d2938d351ffb10ce84c42a4ce87 100644 (file)
@@ -57,6 +57,7 @@ public class TestPercentRank {
             confirmErrorResult(fe, cell, "PERCENTRANK(A2:A11,0)", FormulaError.NA);
             confirmErrorResult(fe, cell, "PERCENTRANK(A2:A11,100)", FormulaError.NA);
             confirmErrorResult(fe, cell, "PERCENTRANK(B2:B11,100)", FormulaError.NUM);
+            confirmErrorResult(fe, cell, "PERCENTRANK(A2:A11,8,0)", FormulaError.NUM);
         }
     }