[github-164] Fix Bug in XSSFTable.setCellReferences when table is single cell. Thanks to Travis Russell. This closes #164

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1871184 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
PJ Fanning 2019-12-11 20:07:01 +00:00
parent 6602cb2cfb
commit f12a414662
2 changed files with 9 additions and 1 deletions

View File

@ -637,7 +637,7 @@ public class XSSFTable extends POIXMLDocumentPart implements Table {
if (ref != null) {
String[] boundaries = ref.split(":", 2);
String from = boundaries[0];
String to = boundaries[1];
String to = boundaries.length == 2 ? boundaries[1] : boundaries[0];
startCellReference = new CellReference(from);
endCellReference = new CellReference(to);
}

View File

@ -215,6 +215,14 @@ public final class TestXSSFTable {
}
}
@Test
public void getEndCellReferenceFromSingleCellTable() throws IOException {
try (XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("SingleCellTable.xlsx")) {
XSSFTable table = wb.getTable("Table3");
assertEquals(new CellReference("A2"), table.getEndCellReference());
}
}
@Test
public void getNumberOfMappedColumns() throws IOException {
try (XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("StructuredReferences.xlsx")) {