https://bz.apache.org/bugzilla/show_bug.cgi?id=59687
Bug ID: 59687 Summary: XSSFSheet.RemoveRow doesn't handle row gaps properly when removing row comments (typo) Product: POI Version: 3.15-dev Hardware: All OS: All Status: NEW Severity: normal Priority: P2 Component: XSSF Assignee: dev@poi.apache.org Reporter: greg.wool...@gmail.com Created attachment 33936 --> https://bz.apache.org/bugzilla/attachment.cgi?id=33936&action=edit simple file that causes trouble when removing rows with comments and missing rows above. The attached file was created with Excel 2016. It has only one cell with data, A4, with a comment on that cell. The XML for the sheet shows only that one row defined. The following test method fails, because XSSFSheet.removeRow(row) uses the physical offset, not the logical row #, when looking for row comments to remove. If there are undefined rows (gaps in the physical sequence) these are different, and the comments remain after the row is deleted. The fix is to store the rowNum from the row being deleted, and use that rather than the physical idx in the comment removal loop in XSSFSheet.removeRow(row). I'd do this as a patch, but I have another patch pending, and would rather not revert and reapply for so small a change. If that's what it takes, I'll do it, though. Add this test to TestXSSFSheetShiftRows, and the attached file to test-data/spreadsheet: @Test public void testRemoveRowWithCommentAndGapAbove() throws IOException { final XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("removeRowWithCommentBug.xlsx"); final XSSFSheet sheet = wb.getSheetAt(0); // comment exists CellAddress commentCellAddress = new CellAddress(3, 0); assertNotNull(sheet.getCellComment(commentCellAddress)); assertEquals("Wrong starting # of comments", 1, sheet.getCommentsTable(true).getNumberOfComments()); sheet.removeRow(sheet.getRow(commentCellAddress.getRow())); assertEquals("There should not be any comments left!", 0, sheet.getCommentsTable(true).getNumberOfComments()); } -- You are receiving this mail because: You are the assignee for the bug. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org For additional commands, e-mail: dev-h...@poi.apache.org