We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Insert Excel rows and columns in C#, VB.NET

Syncfusion Excel (XlsIO) library is a .NET Excel library used to create, read, and edit Excel documents. Also, converts Excel documents to PDF files. Using this library, you can insert Excel rows and columns in C#, VB.NET.

‘InsertRow’ and ‘InsertColumn’ methods are designed to work if the row index or column index falls within the used range of the worksheet. Also, these methods take input in one based index, and hence to insert a column at ‘A’, you must use worksheet.InsertColumn(1);

As per Microsoft Excel behavior,

  • the merged formats of the previous or next row/column to the inserted one, won’t be copied.
  • the styles and borders applied to the previous row/column will be updated.
  • formulas won’t be updated.

Steps to insert Excel rows and columns, programmatically:

Step 1: Create a new C# console application project.

Insert excel row and column in Project Application

Create a new C# console application

Step 2: Install the Syncfusion.XlsIO.WinForms NuGet package as reference to your .NET Framework application from NuGet.org.

NuGet Package Manager in project application.

Install NuGet package

Step 3: Include the following namespace in the Program.cs file.


using Syncfusion.XlsIO;



Imports Syncfusion.XlsIO


Step 4: Use the following code snippet to insert Excel rows and columns in C#, VB.NET.


using (ExcelEngine excelEngine = new ExcelEngine())
    //Instantiate the application object
    IApplication application = excelEngine.Excel;
    //Add a workbook
    IWorkbook workbook = application.Workbooks.Open("InsertRowsandColumnsTemplate.xlsx", ExcelOpenType.Automatic);
    //The first worksheet object in the worksheets collection is accessed
    IWorksheet worksheet = workbook.Worksheets[0];
    //Inserting Rows
    //Inserting Columns
    //Save the workbook



Using excelEngine As ExcelEngine = New ExcelEngine()
    'Instantiate the application object
    Dim application As IApplication = excelEngine.Excel
    'Add a workbook
    Dim workbook As IWorkbook = application.Workbooks.Open("InsertRowsandColumnsTemplate.xlsx", ExcelOpenType.Automatic)
    'The first worksheet object in the worksheets collection is accessed
    Dim worksheet As IWorksheet = workbook.Worksheets(0)
    'Inserting Rows
    'Inserting Columns
    'Save the workbook
End Using


A complete Windows Forms working example of how to insert Excel rows and columns in C# and VB can be downloaded from Insert Excel Rows And Columns.zip.

By executing the program, you will get the output Excel file as shown below.

Excel file in Project Application

Output Excel document

Refer here to explore the rich set of Syncfusion Excel (XlsIO) library features.

See Also:

How do I insert a row after last row?

Why formulas are not updated when inserting rows?

How do I delete a bunch of rows or columns?

How to copy and insert a chart in the same worksheet using C#,VB.NET?

How do I insert watermark in MS Excel?

How to insert an Hyperlink in a cell?


Starting with v16.2.0.x, if you reference Syncfusion assemblies from trial setup or from the NuGet feed, include a license key in your projects. Refer the link to learn about generating and registering Syncfusion license key in your application to use the components without trail message.


2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile