aboutsummaryrefslogtreecommitdiffstats
path: root/poi/src/main/java
diff options
context:
space:
mode:
authorPJ Fanning <fanningpj@apache.org>2021-08-07 11:52:35 +0000
committerPJ Fanning <fanningpj@apache.org>2021-08-07 11:52:35 +0000
commit87ea84cf48cc115994b4dfa2f2c6ee00febe1d92 (patch)
tree65c3039e4722412fdc70dff120ac46152f47fd58 /poi/src/main/java
parentf00456e38d5be4c268a78dae383df6f93e7f8005 (diff)
downloadpoi-87ea84cf48cc115994b4dfa2f2c6ee00febe1d92.tar.gz
poi-87ea84cf48cc115994b4dfa2f2c6ee00febe1d92.zip
fix TextJoin use case that was not handled
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1892070 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi/src/main/java')
-rw-r--r--poi/src/main/java/org/apache/poi/ss/formula/atp/TextJoinFunction.java8
1 files changed, 6 insertions, 2 deletions
diff --git a/poi/src/main/java/org/apache/poi/ss/formula/atp/TextJoinFunction.java b/poi/src/main/java/org/apache/poi/ss/formula/atp/TextJoinFunction.java
index 8cd588715a..85a527261f 100644
--- a/poi/src/main/java/org/apache/poi/ss/formula/atp/TextJoinFunction.java
+++ b/poi/src/main/java/org/apache/poi/ss/formula/atp/TextJoinFunction.java
@@ -96,14 +96,14 @@ final class TextJoinFunction implements FreeRefFunction {
if (delimiterArgs.size() == 0) {
return new StringEval(String.join("", textValues));
} else if (delimiterArgs.size() == 1) {
- String delimiter = OperandResolver.coerceValueToString(delimiterArgs.get(0));
+ String delimiter = coerceValueToString(delimiterArgs.get(0));
return new StringEval(String.join(delimiter, textValues));
} else {
//https://support.microsoft.com/en-us/office/textjoin-function-357b449a-ec91-49d0-80c3-0e8fc845691c
//see example 3 to see why this is needed
List<String> delimiters = new ArrayList<>();
for (ValueEval delimiterArg: delimiterArgs) {
- delimiters.add(OperandResolver.coerceValueToString(delimiterArg));
+ delimiters.add(coerceValueToString(delimiterArg));
}
StringBuilder sb = new StringBuilder();
for (int i = 0; i < textValues.size(); i++) {
@@ -120,6 +120,10 @@ final class TextJoinFunction implements FreeRefFunction {
}
}
+ private String coerceValueToString(ValueEval eval) {
+ return (eval instanceof MissingArgEval) ? "" : OperandResolver.coerceValueToString(eval);
+ }
+
//https://support.microsoft.com/en-us/office/textjoin-function-357b449a-ec91-49d0-80c3-0e8fc845691c
//in example 3, the delimiter is defined by a large area but only the last row of that area seems to be used
//this is why lastRowOnly is supported