<changes>
<release version="3.8-beta5" date="2011-??-??">
+ <action dev="poi-developers" type="fix">51963 - Correct AreaReference handling of references containing a sheet name which includes a comma</action>
<action dev="poi-developers" type="fix">51955 - XSSFReader supplied StylesTables need to have the theme data available</action>
<action dev="poi-developers" type="fix">51716 - Removed incorrect assert in SXSSFSheet#getSXSSFSheet</action>
<action dev="poi-developers" type="fix">51834 - Opening and Writing .doc file results in corrupt document</action>
* unbroken) area, or is it made up of
* several different parts?
* (If it is, you will need to call
- * ....
+ * {@link #generateContiguous(String)})
*/
public static boolean isContiguous(String reference) {
- if(reference.indexOf(',') == -1) {
- return true;
- }
- return false;
+ // If there's a sheet name, strip it off
+ int sheetRefEnd = reference.indexOf('!');
+ if(sheetRefEnd != -1) {
+ reference = reference.substring(sheetRefEnd);
+ }
+
+ // Check for the , as a sign of non-coniguous
+ if(reference.indexOf(',') == -1) {
+ return true;
+ }
+ return false;
}
public static AreaReference getWholeRow(String start, String end) {
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.ss.util.AreaReference;
import org.apache.poi.xssf.XSSFITestDataProvider;
import org.apache.poi.xssf.XSSFTestDataSamples;
import org.apache.poi.xssf.model.CalculationChain;
assertNotNull(sh1.getCommentsTable(false));
assertEquals(2, sh1.getCommentsTable(false).getNumberOfComments());
}
+
+ /**
+ * Sheet names with a , in them
+ */
+ public void test51963() throws Exception {
+ XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("51963.xlsx");
+ XSSFSheet sheet = wb.getSheetAt(0);
+ assertEquals("Abc,1", sheet.getSheetName());
+
+ Name name = wb.getName("Intekon.ProdCodes");
+ assertEquals("'Abc,1'!$A$1:$A$2", name.getRefersToFormula());
+
+ AreaReference ref = new AreaReference(name.getRefersToFormula());
+ assertEquals(0, ref.getFirstCell().getRow());
+ assertEquals(0, ref.getFirstCell().getCol());
+ assertEquals(1, ref.getLastCell().getRow());
+ assertEquals(0, ref.getLastCell().getCol());
+ }
}