# Insert And Delete Cell Ranges

DsExcel allows you to insert and delete a cell or a range of cells while working with spreadsheets. Learn more in DsExcel docs.

## Content

DsExcel Java enables users to insert and delete a cell or a range of cells while working with spreadsheets. This facilitates the customization of worksheets based on specific requirements.

## Insert cell range

DsExcel Java allows you to add a cell or a range of cells in a worksheets by calling the [insert](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/IRange.html#insert) method of the [IRange](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/IRange.html) interface. To add a cell or a range of cells, specify the cell range, for example **A3** for single cell or **A3:A5** for a range of cells.
You can choose from the following options while inserting a cell or a range of cells in a worksheet.

| **Method** | **Description** |
| ------ | ----------- |
| insert | This method automatically inserts a cell or a range of cells. |
| insert(InsertShiftDirection.Down) | This method inserts the range of cells and shifts the existing range of cells in downward direction. |
| insert(InsertShiftDirection.Right) | This method inserts the range of cells and shifts the existing range of cells to the right. |

In order to insert a single cell and a cell range in the worksheet, refer to the following example code.

```Java
// Insert the range of cell
worksheet.getRange("A3").insert();
        
// Insert the range of cells
worksheet.getRange("A3:C10").insert();
```

In order to insert cell range in a worksheet while specifying the desired shift direction for the existing cells, refer to the following example code.

```Java
// Insert the range of cells from desired direction
worksheet.getRange("A3:C10").insert(InsertShiftDirection.Down);
worksheet.getRange("A3:C10").insert(InsertShiftDirection.Right);
```

## Delete cell range

DsExcel Java allow you to delete a cell or a range of cells in the worksheets by calling the [delete](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/IRange.html#delete) method of the [IRange](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/IRange.html) interface. To remove a cell or a range of cells, specify the cell range, for example **B4** for a single cell or **B4:C4** for a range of cells.
DsExcel Java provides the following different options to delete a cell or range of cells.

| **Method** | **Description** |
| ------ | ----------- |
| delete | This method automatically deletes a cell or the range of cells. |
| delete(DeleteShiftDirection.Left) | This method deletes the range of cells and moves the existing range of cells to the left. |
| delete(DeleteShiftDirection.Up) | This method delete the range of cells and move the existing range of cells in upward direction. |

In order to delete a single cell or a cell range in a worksheet, refer to the following example code.

```Java
// Delete the range of cell
worksheet.getRange("A3").delete();
        
// Delete the range of cells
worksheet.getRange("A3:C10").delete();
```

In order to delete a single cell or a range of cells in a worksheet while specifying the desired shift direction for the existing cells, refer to the following example code.

```Java
// Delete the range of cells from desired direction
worksheet.getRange("A3:C10").delete(DeleteShiftDirection.Left);
worksheet.getRange("A3:C10").delete(DeleteShiftDirection.Up);
```

## See Also

[Cut or Copy Cell Ranges](/document-solutions/java-excel-api/docs/online/Features/ManageWorksheet/RangeOperations/CutOrCopyCellRanges)