mirror of https://github.com/apache/poi.git
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
This commit is contained in:
parent
9395942e91
commit
a45b2cd33f
|
@ -34,6 +34,7 @@
|
|||
|
||||
<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>
|
||||
|
|
|
@ -152,13 +152,20 @@ public class AreaReference {
|
|||
* 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) {
|
||||
|
|
|
@ -43,6 +43,7 @@ import org.apache.poi.ss.usermodel.Name;
|
|||
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;
|
||||
|
@ -1230,4 +1231,22 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
|||
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());
|
||||
}
|
||||
}
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue