- Document Solutions for Excel, .NET Edition Overview
- Key Features
- Getting Started
-
Features
-
Worksheet
- Work with Worksheets
-
Range Operations
- Access a Range
- Get Intersection, Union and Offset Range
- Access Areas in a Range
- Get Range and Range Area
- Get Special Cell Ranges
- Access Cells, Rows and Columns in a Range
- Get Address of Cell Range
- Cut or Copy Cell Ranges
- Cut or Copy Shape, Slicer, Chart and Picture
- Paste or Ignore Data in Hidden Range
- Find and Replace Data
- Get Row and Column Count
- Hide Rows and Columns
- Insert And Delete Cell Ranges
- Insert and Delete Rows and Columns
- Merge Cells
- Auto Merge Cells
- Protect Cell Range
- Set Values to a Range
- Set Custom Objects to a Range
- Set Row Height and Column Width
- Auto Fit Row Height and Column Width
- Work with Used Range
- Measure Digital Width
- Set Default Values for Cell Range
- Set Cell Background Image for Cell Range
- Ignore Errors in Cell Range
- Customize Worksheets
- Worksheet Views
- Cell Types
- Quote Prefix
- Tags
- Rich Text
- Background Image
- Workbook
- Comments
- Hyperlinks
- Sort
- Filter
- Group
- Conditional Formatting
- Data Validations
- Data Binding
- Import Data
- Digital Signatures
- Formulas
- Custom Functions
- Shapes
- Document Properties
- Styles
- Form Controls
- Barcodes
- Themes and Colors
- Chart
- Table
- Pivot Table
- Pivot Chart
- Sparkline
- Slicer
- Logging
- Defined Names
-
Worksheet
- Templates
- File Operations
- Document Solutions Data Viewer
- API Reference
- Release Notes
Insert and Delete Rows and Columns
DsExcel provides you with the ability to insert or delete rows and columns in a worksheet.
Insert rows and columns
DsExcel allow you to add rows or columns in a worksheet by calling Insert method of IRange.
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 EntireRow property to insert rows in a worksheet which includes all the columns. While inserting rows using the EntireRow property, there is no need to provide the shift direction in the function parameters. If you provide the same, it will be ignored.
Refer to the following example code to insert rows in a worksheet.
//Insert rows
worksheet.Range["A3:A5"].EntireRow.Insert();
// OR
worksheet.Range["3:5"].Insert(InsertShiftDirection.Down);You can also use the EntireColumn property to insert columns in the worksheet which includes all rows. While inserting columns using the EntireColumn property, there is no need to provide the shift direction in the function parameters. If you provide the same, it will be ignored.
Refer to the following example code to insert columns in a worksheet.
//Insert column
worksheet.Range["A3:B5"].EntireColumn.Insert();
// OR
worksheet.Range["B:C"].Insert(InsertShiftDirection.Down);Delete row and column
DsExcel allows you to delete rows or columns in the worksheet by calling Delete method of IRange.
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.
Refer to the following example code to delete rows from the worksheet.
//Delete rows
worksheet.Range["A3:A5"].EntireRow.Delete();
// OR
worksheet.Range["3:5"].Delete();Refer to the following example code to delete columns from the worksheet.
//Delete Columns
worksheet.Range["A3:A5"].EntireColumn.Delete();
// OR
worksheet.Range["A:A"].Delete(DeleteShiftDirection.Left);