You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2016/06/09 17:30:17 UTC
[Bug 59687] New: XSSFSheet.RemoveRow doesn't handle row gaps
properly when removing row comments (typo)
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.woolsey@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-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 59687] XSSFSheet.RemoveRow doesn't handle row gaps properly
when removing row comments (typo)
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59687
Javen O'Neal <on...@apache.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|NEW |RESOLVED
--- Comment #1 from Javen O'Neal <on...@apache.org> ---
Thanks for catching this error, writing a unit test, and suggesting a fix!
Applied in r1761860 and r1761861. Will be included in POI 3.16 beta 1.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 59687] XSSFSheet.RemoveRow doesn't handle row gaps properly when removing row comments (typo)
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59687
--- Comment #2 from Godrej Tiara <go...@gmail.com> ---
Your take on this subject is truly refreshing. It adds a new layer of
understanding to the conversation. Well done!
https://www.godrejtiara.info/
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org