|Summary:||shiftRows judge mergedRegions to remove error|
|Component:||XSSF||Assignee:||POI Developers List <dev>|
|OS:||Mac OS X 10.1|
|Attachments:||shift the second row occur error|
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.