Bug 64046 - shiftRows judge mergedRegions to remove error
Summary: shiftRows judge mergedRegions to remove error
Status: NEW
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: 4.1.1-FINAL
Hardware: PC Mac OS X 10.1
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-01-03 09:37 UTC by YueshanLin
Modified: 2020-01-03 09:37 UTC (History)
0 users



Attachments
shift the second row occur error (11.39 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2020-01-03 09:37 UTC, YueshanLin
Details

Note You need to log in before you can comment on or make changes to this bug.
Description YueshanLin 2020-01-03 09:37:19 UTC
Created attachment 36944 [details]
shift the second row occur error

The method of removalNeeded in abstract class RowShifter exist bug, the CellRangeAddress of overwrite is defined as "overwrite = new CellRangeAddress(firstRow, lastRow, 0, 0);". If the delete row's first column is not a mergedRegion, then all the mergedRegion in the Row will not be deleted, when to add mergeRegion, will occur IllegalStateException of "Cannot add merged region " + candidateRegion.formatAsString() + " to sheet because it overlaps with an existing merged region (" + existingRegion.formatAsString() + ").
My solution: the overwrite CellRangeAddress should be defined as "overwrite = new CellRangeAddress(firstRow, lastRow, 0, Integer.MAX_VALUE);", then all the mergedRegion in the deleteRow will be deleted, then can shiftRow successfully.