Bug 57307 - removeMergedRegion() throws IndexOutOfBoundsException on .xlsx MS-Excel file
Summary: removeMergedRegion() throws IndexOutOfBoundsException on .xlsx MS-Excel file
Status: RESOLVED WONTFIX
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: 3.10-FINAL
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-12-04 12:22 UTC by Prejith Pulikkottil
Modified: 2014-12-06 14:25 UTC (History)
0 users



Attachments
removeMergedRegion tested excel (72.52 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2014-12-04 12:22 UTC, Prejith Pulikkottil
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Prejith Pulikkottil 2014-12-04 12:22:08 UTC
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)
        }
    }
}
Comment 1 Andreas Beeker 2014-12-06 14:25:23 UTC
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.