mirror of https://github.com/apache/poi.git
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
This commit is contained in:
parent
89e7fbe6cd
commit
67683086b5
|
@ -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.
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue