Cells.DeleteRange

Cells.DeleteRange method

Deletes a range of cells and shift cells according to the shift option.

public void DeleteRange(int startRow, int startColumn, int endRow, int endColumn, 
    ShiftType shiftType)
ParameterTypeDescription
startRowInt32Start row index.
startColumnInt32Start column index.
endRowInt32End row index.
endColumnInt32End column index.
shiftTypeShiftTypeShift cells option.

Examples

using System;
using Aspose.Cells;

namespace AsposeCellsExamples
{
    public class CellsMethodDeleteRangeWithInt32Int32Int32Int32ShiftTypeDemo
    {
        public static void Run()
        {
            // Create a new workbook
            Workbook workbook = new Workbook();
            Worksheet sheet = workbook.Worksheets[0];
            
            // Populate some sample data
            sheet.Cells["A1"].PutValue("A1");
            sheet.Cells["B1"].PutValue("B1");
            sheet.Cells["C1"].PutValue("C1");
            sheet.Cells["A2"].PutValue("A2");
            sheet.Cells["B2"].PutValue("B2");
            sheet.Cells["C2"].PutValue("C2");

            // Delete range and shift left
            sheet.Cells.DeleteRange(0, 1, 1, 2, ShiftType.Left);

            // Save the workbook
            workbook.Save("DeleteRangeExample.xlsx");
        }
    }
}

See Also