# Insert and Delete Rows and Columns

DsExcel allows you to insert or delete rows and columns in a worksheet. Learn more in DsExcel docs.

## Content

DsExcel Java provides you with the ability to insert or delete rows and columns in a worksheet.

## Insert rows and columns

DsExcel Java allow you to add rows or columns in a worksheet 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.
When rows are added, the existing rows in the worksheet are shifted in downward direction whereas when columns are added, the existing columns in the worksheet are shifted to the right.
You can also use the [getEntireRow](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/IRange.html#getEntireRow) method to insert rows in a worksheet which includes all the columns. While inserting rows using the getEntireRow method, there is no need to provide the shift direction in the function parameters. If you provide the same, it will be ignored.
In order to insert rows in a worksheet, refer to the following example code.

```Java
// Insert rows
worksheet.getRange("A3:A5").getEntireRow().insert();
// OR
worksheet.getRange("3:5").insert();
```

You can also use the [getEntireColumn](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/IRange.html#getEntireColumn) method to insert columns in the worksheet which includes all rows. While inserting columns using the EntireColumn method, there is no need to provide the shift direction in the function parameters. If you provide the same, it will be ignored.
In order to insert columns in a worksheet, refer to the following example code.

```Java
// Insert columns
worksheet.getRange("A3:A5").getEntireColumn().insert();
// OR
worksheet.getRange("3:5").insert();
```

## Delete row and column

DsExcel Java allows you to delete rows or columns in the worksheet 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.
When rows are deleted, the existing rows in the worksheet are shifted in upwards direction, whereas when columns are deleted, the existing columns in the worksheet are shifted to the left.
In order to delete rows from the worksheet, refer to the following example code.

```Java
// Delete rows
worksheet.getRange("A3:A5").getEntireRow().delete();
// OR
worksheet.getRange("3:5").delete();
```

In order to delete columns from the worksheet, refer to the following example code.

```Java
// Delete columns
worksheet.getRange("A3:A5").getEntireColumn().delete();
// OR
worksheet.getRange("3:5").delete();
```

## See Also

[Work with Worksheets](/document-solutions/java-excel-api/docs/online/Features/ManageWorksheet/WorkWithSheets)