Browse Source

Fix bug #51963 - Correct AreaReference handling of references containing a sheet name which includes a comma

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1179444 13f79535-47bb-0310-9956-ffa450edef68
tags/REL_3_8_BETA5
Nick Burch 12 years ago
parent
commit
a45b2cd33f

+ 1
- 0
src/documentation/content/xdocs/status.xml View File



<changes> <changes>
<release version="3.8-beta5" date="2011-??-??"> <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">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">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> <action dev="poi-developers" type="fix">51834 - Opening and Writing .doc file results in corrupt document</action>

+ 12
- 5
src/java/org/apache/poi/ss/util/AreaReference.java View File

* unbroken) area, or is it made up of * unbroken) area, or is it made up of
* several different parts? * several different parts?
* (If it is, you will need to call * (If it is, you will need to call
* ....
* {@link #generateContiguous(String)})
*/ */
public static boolean isContiguous(String reference) { 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) { public static AreaReference getWholeRow(String start, String end) {

+ 19
- 0
src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java View File

import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook; 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.XSSFITestDataProvider;
import org.apache.poi.xssf.XSSFTestDataSamples; import org.apache.poi.xssf.XSSFTestDataSamples;
import org.apache.poi.xssf.model.CalculationChain; import org.apache.poi.xssf.model.CalculationChain;
assertNotNull(sh1.getCommentsTable(false)); assertNotNull(sh1.getCommentsTable(false));
assertEquals(2, sh1.getCommentsTable(false).getNumberOfComments()); 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());
}
} }

BIN
test-data/spreadsheet/51963.xlsx View File


Loading…
Cancel
Save