aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPJ Fanning <fanningpj@apache.org>2021-08-07 14:27:41 +0000
committerPJ Fanning <fanningpj@apache.org>2021-08-07 14:27:41 +0000
commitfc83c4929eaa2967150486d84f854cd0a0728aa6 (patch)
tree836d0e7162cded2b30ddddf283ef94183644837b
parentbb515fdc3089dc83f4e3a849c73c6a855f77fd29 (diff)
downloadpoi-fc83c4929eaa2967150486d84f854cd0a0728aa6.tar.gz
poi-fc83c4929eaa2967150486d84f854cd0a0728aa6.zip
[bug-49202] add PERCENTRANK function
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1892078 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--poi/src/main/java/org/apache/poi/ss/formula/functions/PercentRank.java3
-rw-r--r--poi/src/test/java/org/apache/poi/ss/formula/functions/TestPercentRank.java1
2 files changed, 4 insertions, 0 deletions
diff --git a/poi/src/main/java/org/apache/poi/ss/formula/functions/PercentRank.java b/poi/src/main/java/org/apache/poi/ss/formula/functions/PercentRank.java
index 03a9ae54bc..115adf647e 100644
--- a/poi/src/main/java/org/apache/poi/ss/formula/functions/PercentRank.java
+++ b/poi/src/main/java/org/apache/poi/ss/formula/functions/PercentRank.java
@@ -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();
}
diff --git a/poi/src/test/java/org/apache/poi/ss/formula/functions/TestPercentRank.java b/poi/src/test/java/org/apache/poi/ss/formula/functions/TestPercentRank.java
index 6d96426dd9..3892a3eb1d 100644
--- a/poi/src/test/java/org/apache/poi/ss/formula/functions/TestPercentRank.java
+++ b/poi/src/test/java/org/apache/poi/ss/formula/functions/TestPercentRank.java
@@ -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);
}
}