diff options
author | Dominik Stadler <centic@apache.org> | 2017-12-28 08:45:43 +0000 |
---|---|---|
committer | Dominik Stadler <centic@apache.org> | 2017-12-28 08:45:43 +0000 |
commit | 67683086b5e9820472db79ba3c1601e85828de33 (patch) | |
tree | e0c3e73ed7867d96481e3f817f7fdf571cf06282 /src | |
parent | 89e7fbe6cdc88968644f8588f66979dcc8531af7 (diff) | |
download | poi-67683086b5e9820472db79ba3c1601e85828de33.tar.gz poi-67683086b5e9820472db79ba3c1601e85828de33.zip |
Bug 61798: Fix usage of getLastCellNum(), unfortunately this is a bit misleading compared to getFirstCellNum()...
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1819404 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
3 files changed, 29 insertions, 5 deletions
diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRow.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRow.java index 8f89c67d2f..6c4956dba0 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRow.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRow.java @@ -266,7 +266,7 @@ public class XSSFRow implements Row, Comparable<XSSFRow> { } /** - * Get the number of the first cell contained in this row. + * Get the 0-based number of the first cell contained in this row. * * @return short representing the first logical cell in the row, * or -1 if the row does not contain any cells. diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java index c2ee5f5bef..8ca7d2b1ef 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java @@ -3492,9 +3492,9 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet { // Resetting the hyperlink array seems to break some XML nodes. //worksheet.getHyperlinks().setHyperlinkArray(new CTHyperlink[0]); worksheet.unsetHyperlinks(); - } else { + } /*else { // nothing to do - } + }*/ } int minCell=Integer.MAX_VALUE, maxCell=Integer.MIN_VALUE; @@ -3507,7 +3507,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet { minCell = Math.min(minCell, row.getFirstCellNum()); } if(row.getLastCellNum() != -1) { - maxCell = Math.max(maxCell, row.getLastCellNum()); + maxCell = Math.max(maxCell, row.getLastCellNum()-1); } } diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java index f788619ad4..106dceb494 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java @@ -3102,6 +3102,8 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { Cell cell = row.createCell(1); cell.setCellValue("blabla"); + //0 1 2 3 4 5 6 7 + //A B C D E F G H row = sheet.createRow(4); cell = row.createCell(7); cell.setCellValue("blabla"); @@ -3110,7 +3112,29 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { // to avoid having to iterate all rows/cells in each add/remove of a row or cell wb.write(new NullOutputStream()); - assertEquals("B2:I5", ((XSSFSheet) sheet).getCTWorksheet().getDimension().getRef()); + assertEquals("B2:H5", ((XSSFSheet) sheet).getCTWorksheet().getDimension().getRef()); + + wb.close(); + } + + @Test + public void test61798() throws IOException { + Workbook wb = new XSSFWorkbook(); + Sheet sheet = wb.createSheet("test"); + Row row = sheet.createRow(1); + Cell cell = row.createCell(1); + cell.setCellValue("blabla"); + + row = sheet.createRow(4); + // Allowable column range for EXCEL2007 is (0..16383) or ('A'..'XDF') + cell = row.createCell(16383); + cell.setCellValue("blabla"); + + // we currently only populate the dimension during writing out + // to avoid having to iterate all rows/cells in each add/remove of a row or cell + wb.write(new NullOutputStream()); + + assertEquals("B2:XFD5", ((XSSFSheet)sheet).getCTWorksheet().getDimension().getRef()); wb.close(); } |