[prev in list] [next in list] [prev in thread] [next in thread]
List: poi-dev
Subject: Fwd: svn commit: r1856655 - in /poi/trunk/src: java/org/apache/poi/ss/formula/SheetNameFormatter.jav
From: Greg Woolsey <gwoolsey () apache ! org>
Date: 2019-03-31 3:54:41
Message-ID: CAEwphwoU3HeUQj10-3WdGthHcAQkfXcW0-jENc=xbt_cUzx06g () mail ! gmail ! com
[Download RAW message or body]
I handled this similarly to other code that converted missing external
sheet info to empty String values, but if someone thinks this should still
throw an exception, I'm open to discussing a new "MissingExternalReference"
checked exception or something like that. Appears Excel does this to avoid
errors, so POI has been also, just not for this case but not on purpose.
---------- Forwarded message ---------
From: <gwoolsey@apache.org>
Date: Sat, Mar 30, 2019 at 8:49 PM
Subject: svn commit: r1856655 - in /poi/trunk/src:
java/org/apache/poi/ss/formula/SheetNameFormatter.java
testcases/org/apache/poi/hssf/usermodel/TestHSSFEvaluationSheet.java
To: <commits@poi.apache.org>
Author: gwoolsey
Date: Sun Mar 31 03:49:16 2019
New Revision: 1856655
URL: http://svn.apache.org/viewvc?rev=1856655&view=rev
Log:
fix a condition not seen until a recent expansion of the stress test.
Gracefully ignore missing/invalid external sheet references in one more
path (there were several already with comments like "this seems to be what
Excel does in this case")
Modified:
poi/trunk/src/java/org/apache/poi/ss/formula/SheetNameFormatter.java
poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFEvaluationSheet.java
Modified:
poi/trunk/src/java/org/apache/poi/ss/formula/SheetNameFormatter.java
URL:
http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/formula/SheetNameFormatter.java?rev=1856655&r1=1856654&r2=1856655&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/formula/SheetNameFormatter.java
(original)
+++ poi/trunk/src/java/org/apache/poi/ss/formula/SheetNameFormatter.java
Sun Mar 31 03:49:16 2019
@@ -179,7 +179,7 @@ public final class SheetNameFormatter {
int len = rawSheetName.length();
if(len < 1) {
- throw new RuntimeException("Zero length string is
an invalid sheet name");
+ return false; // some cases we get missing external
references, resulting in empty sheet names
}
if(Character.isDigit(rawSheetName.charAt(0))) {
// sheet name with digit in the first position
always requires delimiting
Modified:
poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFEvaluationSheet.java
URL:
http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFEvaluationSheet.java?rev=1856655&r1=1856654&r2=1856655&view=diff
==============================================================================
---
poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFEvaluationSheet.java
(original)
+++
poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFEvaluationSheet.java
Sun Mar 31 03:49:16 2019
@@ -17,9 +17,12 @@
package org.apache.poi.hssf.usermodel;
+import org.apache.poi.hssf.HSSFTestDataSamples;
import org.apache.poi.ss.formula.EvaluationSheet;
import org.apache.poi.ss.usermodel.BaseTestXEvaluationSheet;
+import org.apache.poi.ss.usermodel.Name;
import org.apache.poi.ss.usermodel.Sheet;
+import org.junit.Test;
import java.util.AbstractMap;
import java.util.Map;
@@ -30,4 +33,15 @@ public class TestHSSFEvaluationSheet ext
HSSFSheet sheet = new HSSFWorkbook().createSheet();
return new AbstractMap.SimpleEntry<>(sheet, new
HSSFEvaluationSheet(sheet));
}
+
+ @Test
+ public void testMissingExternalName() {
+ HSSFWorkbook wb =
HSSFTestDataSamples.openSampleWorkbook("external_name.xls");
+ for (Name name : wb.getAllNames()) {
+ // this sometimes causes exceptions
+ if(!name.isFunctionName()) {
+ name.getRefersToFormula();
+ }
+ }
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic