diff options
author | PJ Fanning <fanningpj@apache.org> | 2019-12-11 20:07:01 +0000 |
---|---|---|
committer | PJ Fanning <fanningpj@apache.org> | 2019-12-11 20:07:01 +0000 |
commit | f12a414662702c56ccb6b3b4339465f71dcfe903 (patch) | |
tree | d3f30a6151f52b18d1528b0b10f5e4752d5d5d91 | |
parent | 6602cb2cfbecd014c1d3779cd1f35fc2782c86f0 (diff) | |
download | poi-f12a414662702c56ccb6b3b4339465f71dcfe903.tar.gz poi-f12a414662702c56ccb6b3b4339465f71dcfe903.zip |
[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
-rw-r--r-- | src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFTable.java | 2 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFTable.java | 8 |
2 files changed, 9 insertions, 1 deletions
diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFTable.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFTable.java index ab874c8bde..31b6e320cf 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFTable.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFTable.java @@ -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); } diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFTable.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFTable.java index 955e149101..733da646f9 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFTable.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFTable.java @@ -216,6 +216,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")) { XSSFTable table = wb.getTable("\\_Prime.1"); |