We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Documentation / example for Cells.insertRange

Please could you expand the documentation (and example source) around Cells.insertRange:

public void insertRange(CellArea area, int shiftNumber, int shiftType, boolean updateReference)

For example, for a specified CellArea, where in the sheet are the cells inserted?

On a related note, is there a quick way to copy a range of cells and insert them immediately below the selection?

Hi Nick,

Thanks for your posting and using Aspose.Cells.

The shiftNumber paremets inside the insertRange() method specifies how many columns or rows to be inserted. shiftType parameter specifies whether the inserted cells are to be shifted left, right, up or down. updateReference parameter will update the references of the shifted cells in other worksheets

Please see the following code. It inserts range by shifting cells to right and inserting 5 columns. I have attached the sample xlsx file used in this code and output xlsx file generated by it for your reference.


Workbook workbook = new Workbook(“sample.xlsx”);

Worksheet worksheet = workbook.getWorksheets().get(0);

CellArea area = CellArea.createCellArea(“D6”, “G11”);

//It will insert the range and shift cells to right and insert 5 columns

worksheet.getCells().insertRange(area, 5, ShiftType.RIGHT, true);