Summary: | removeMergedRegion() throws IndexOutOfBoundsException on .xlsx MS-Excel file | ||
---|---|---|---|
Product: | POI | Reporter: | Prejith Pulikkottil <pulikkot> |
Component: | XSSF | Assignee: | POI Developers List <dev> |
Status: | RESOLVED WONTFIX | ||
Severity: | normal | ||
Priority: | P2 | ||
Version: | 3.10-FINAL | ||
Target Milestone: | --- | ||
Hardware: | PC | ||
OS: | All | ||
Attachments: | removeMergedRegion tested excel |
Merged regions aren't addressed via the row/cell index. Although I think the handling in the hssf method InternalSheet.removeMergedRegion() is wrong and it actually should throw an IOOB, I won't fix this handling, as it potentially breaks (a lot of) user code. |
Created attachment 32259 [details] removeMergedRegion tested excel removeMergedRegion() throws an IndexOutOfBoundsException on .xlsx file. But is working on .xls file Here I have pasted the tested the code void removeRow(Sheet sheet){ if(sheet){ for(i in sheet.getFirstRowNum()..sheet.getLastRowNum()){ Row row = sheet.getRow(i) if(!row){ continue } for(j in row.getFirstCellNum()..row.getLastCellNum()){ if(j<0){ continue } sheet.removeMergedRegion(j) } sheet.removeMergedRegion(i) sheet.removeRow(row) } } }