Worksheet.InsertCells(CellRange, InsertCellsMode) Method
A CellRange object specifying a cell range where new cells should be inserted.
An InsertCellsMode enumeration member specifying in which direction to shift other cells.
Use the InsertCells method to insert new cells at the position of the specified cell range.
You can insert a new range and shift other cells in the same column down, or shift other cells in the same row to the right. You can also insert empty rows and columns above or to the left of the specified range of cells, respectively (the same number of rows or columns that comprise the specified range).
Another way to insert and delete the cell range is to use the range's RangeExtensions.Insert and RangeExtensions.Delete extension methods, defined by the RangeExtensions class. These extension methods are accessible as methods of the CellRange object and called by using the instance method syntax.
This example demonstrates how to insert cells into a worksheet. To do this, use the Worksheet.InsertCells method. Pass a cell or cell range where you want to insert new cells, and the InsertCellsMode.ShiftCellsDown or InsertCellsMode.ShiftCellsRight enumeration member to specify how to shift other cells.
using DevExpress.Spreadsheet; // ... IWorkbook workbook = spreadsheetControl1.Document; Worksheet worksheet = workbook.Worksheets; // Insert a cell into the C5 position, shifting other cells in the same column down. worksheet.InsertCells(worksheet.Cells["C5"], InsertCellsMode.ShiftCellsDown); // Insert cells into the location of the H11:I12 range, shifting other cells in the same row to the right. worksheet.InsertCells(worksheet.Range["H11:I12"], InsertCellsMode.ShiftCellsRight);