mirror of https://github.com/apache/poi.git
#59746 XSSF support for files from certain alternate tools where the row XML is missing the row number
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1749971 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
cf9d309cde
commit
6e492e290c
|
@ -77,6 +77,16 @@ public class XSSFRow implements Row, Comparable<XSSFRow> {
|
|||
_cells.put(colI, cell);
|
||||
sheet.onReadCell(cell);
|
||||
}
|
||||
|
||||
if (! row.isSetR()) {
|
||||
// Certain file format writers skip the row number
|
||||
// Assume no gaps, and give this the next row number
|
||||
int nextRowNum = sheet.getLastRowNum()+2;
|
||||
if (nextRowNum == 2 && sheet.getPhysicalNumberOfRows() == 0) {
|
||||
nextRowNum = 1;
|
||||
}
|
||||
row.setR(nextRowNum);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -3088,7 +3088,6 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
|||
* to include the row number on the row tags
|
||||
*/
|
||||
@Test
|
||||
@Ignore("Not yet supported")
|
||||
public void noRowNumbers59746() {
|
||||
Workbook wb = XSSFTestDataSamples.openSampleWorkbook("59746_NoRowNums.xlsx");
|
||||
Sheet sheet = wb.getSheetAt(0);
|
||||
|
@ -3096,5 +3095,8 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
|||
assertEquals("Checked", sheet.getRow(0).getCell(0).getStringCellValue());
|
||||
assertEquals("Checked", sheet.getRow(9).getCell(2).getStringCellValue());
|
||||
assertEquals(false, sheet.getRow(70).getCell(8).getBooleanCellValue());
|
||||
assertEquals(71, sheet.getPhysicalNumberOfRows());
|
||||
assertEquals(70, sheet.getLastRowNum());
|
||||
assertEquals(70, sheet.getRow(sheet.getLastRowNum()).getRowNum());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue