}
// Performance optimization: explicit boxing is slightly faster than auto-unboxing, though may use more memory
- final Integer rownumI = new Integer(row.getRowNum()); // NOSONAR
- int idx = _rows.headMap(rownumI).size();
- _rows.remove(rownumI);
+ final int rowNum = row.getRowNum();
+ final Integer rowNumI = new Integer(rowNum); // NOSONAR
+ // this is not the physical row number!
+ final int idx = _rows.headMap(rowNumI).size();
+ _rows.remove(rowNumI);
worksheet.getSheetData().removeRow(idx);
// also remove any comment located in that row
if(sheetComments != null) {
for (CellAddress ref : getCellComments().keySet()) {
- if (ref.getRow() == idx) {
+ if (ref.getRow() == rowNum) {
sheetComments.removeComment(ref);
}
}
}
// bug 59687: XSSFSheet.RemoveRow doesn't handle row gaps properly when removing row comments
- // This test is currently failing (thus expected AssertionError). When this bug is fixed, no error should be thrown.
- @Test(expected=AssertionError.class)
+ @Test
public void testRemoveRowWithCommentAndGapAbove() throws IOException {
final Workbook wb = _testDataProvider.openSampleWorkbook("59687.xlsx");
final Sheet sheet = wb.getSheetAt(0);