return insertXSSFRange(sheet, tRow, lCol, bRow, rCol, horizontal, copyRightBelow);
}
}
private static ChangeInfo insertHSSFRange(Worksheet sheet, int tRow, int lCol, int bRow, int rCol, boolean horizontal, int copyRightBelow) {
final Book book = (Book) sheet.getWorkbook();
final RefSheet refSheet = getRefSheet(book, sheet);
final Set<Ref>[] refs = refSheet.insertRange(tRow, lCol, bRow, rCol, horizontal);
final int num = horizontal ? rCol - lCol + 1 : bRow - tRow + 1;
final List<CellRangeAddress[]> shiftedRanges = horizontal ?
((HSSFSheetImpl)sheet).shiftColumnsRange(lCol, -1, num, tRow, bRow, true, false, true, false, copyRightBelow):
((HSSFSheetImpl)sheet).shiftRowsRange(tRow, -1, num, lCol, rCol, true, false, true, false, copyRightBelow);
final List<MergeChange> changeMerges = prepareChangeMerges(refSheet, shiftedRanges);
final Set<Ref> last = refs[0];
final Set<Ref> all = refs[1];
if (horizontal) {
final int maxcol = book.getSpreadsheetVersion().getLastColumnIndex();
all.add(new AreaRefImpl(tRow, lCol, bRow, maxcol, refSheet));
shiftFormulas(all, sheet, tRow, bRow, 0, lCol, maxcol, num);
} else {
final int maxrow = book.getSpreadsheetVersion().getLastRowIndex();
all.add(new AreaRefImpl(tRow, lCol, maxrow, rCol, refSheet));
shiftFormulas(all, sheet, tRow, maxrow, num, lCol, rCol, 0);
}
return new ChangeInfo(last, all, changeMerges);