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
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;
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();
+ }
+ }
+ }
}