IronXL How-Tos Insert Rows and Columns How to Insert New Rows and Columns Chaknith Bin Updated:July 28, 2025 The IronXL library offers a convenient way to insert single or multiple rows and columns in C# code without using Office Interop. How to Insert New Rows and Columns in Excel Download the C# library for inserting new rows and columns in Excel Use the InsertRow and InsertRows methods to insert new rows Use the InsertColumn and InsertColumns methods to insert new columns Add data to the newly inserted rows and columns Export the edited Excel file to various file types Get started with IronXL Start using IronXL in your project today with a free trial. First Step: Start for Free Insert a New Row Example Use the InsertRow and InsertRows methods to add new rows to the spreadsheet. These methods enable you to insert rows at a specific index position. Please noteInserting rows directly on the filter row can cause conflicts in the Excel file, requiring you to run Excel repair to properly view the spreadsheet. :path=/static-assets/excel/content-code-examples/how-to/add-rows-columns-rows.cs using IronXL; // Load existing spreadsheet WorkBook workBook = WorkBook.Load("sample.xlsx"); WorkSheet workSheet = workBook.DefaultWorkSheet; // Add a row before row 2 workSheet.InsertRow(1); // Insert multiple rows after row 3 workSheet.InsertRows(3, 3); workBook.SaveAs("addRow.xlsx"); Imports IronXL ' Load existing spreadsheet Private workBook As WorkBook = WorkBook.Load("sample.xlsx") Private workSheet As WorkSheet = workBook.DefaultWorkSheet ' Add a row before row 2 workSheet.InsertRow(1) ' Insert multiple rows after row 3 workSheet.InsertRows(3, 3) workBook.SaveAs("addRow.xlsx") $vbLabelText $csharpLabel Remove a Row Example To remove a row from the spreadsheet, you can use the GetRow method to select the desired row and then use the RemoveRow method on the selected row. Please noteIt is not possible to remove the header row of the table. :path=/static-assets/excel/content-code-examples/how-to/add-rows-columns-remove-row.cs using IronXL; // Load existing spreadsheet WorkBook workBook = WorkBook.Load("sample.xlsx"); WorkSheet workSheet = workBook.DefaultWorkSheet; // Remove row 5 workSheet.GetRow(4).RemoveRow(); workBook.SaveAs("removeRow.xlsx"); Imports IronXL ' Load existing spreadsheet Private workBook As WorkBook = WorkBook.Load("sample.xlsx") Private workSheet As WorkSheet = workBook.DefaultWorkSheet ' Remove row 5 workSheet.GetRow(4).RemoveRow() workBook.SaveAs("removeRow.xlsx") $vbLabelText $csharpLabel Insert a New Column Example To add new column(s) before a specific index position in the table, you can utilize the InsertColumn and InsertColumns methods. Please noteInserting new column(s) within the table range may cause conflicts in the Excel file, requiring you to run Excel repair to properly view the spreadsheet. To remove all empty rows and columns on the range borders, use the Trim() method. Currently, it is not possible to remove column(s). WarningAttempting to insert a new column into a completely empty sheet will result in a System.InvalidOperationException with the message 'Sequence contains no elements'. :path=/static-assets/excel/content-code-examples/how-to/add-rows-columns-columns.cs using IronXL; // Load existing spreadsheet WorkBook workBook = WorkBook.Load("sample.xlsx"); WorkSheet workSheet = workBook.DefaultWorkSheet; // Add a column before column A workSheet.InsertColumn(0); // Insert multiple columns after column B workSheet.InsertColumns(2, 2); workBook.SaveAs("addColumn.xlsx"); Imports IronXL ' Load existing spreadsheet Private workBook As WorkBook = WorkBook.Load("sample.xlsx") Private workSheet As WorkSheet = workBook.DefaultWorkSheet ' Add a column before column A workSheet.InsertColumn(0) ' Insert multiple columns after column B workSheet.InsertColumns(2, 2) workBook.SaveAs("addColumn.xlsx") $vbLabelText $csharpLabel TipsAll row and column index positions follow zero-based indexing. Frequently Asked Questions How can I insert new rows in Excel using C#? You can insert new rows in Excel using IronXL. The library provides InsertRow and InsertRows methods to programmatically add rows at a specific index position in your spreadsheet. What is the method to add columns to an Excel sheet in C#? To add columns to an Excel sheet in C#, you can use IronXL's InsertColumn and InsertColumns methods. These allow you to insert columns at a specified index position within the sheet. Is it possible to remove a row from an Excel spreadsheet using C#? Yes, with IronXL, you can remove a row from an Excel spreadsheet by using the GetRow method to select the desired row and then applying the RemoveRow method. Can columns be removed from an Excel sheet programmatically with IronXL? Currently, IronXL does not support removing columns directly. However, you can insert new columns using the InsertColumn and InsertColumns methods. What precautions should be taken when inserting rows or columns in Excel using IronXL? Inserting rows or columns within certain areas, such as a filter row or a table range, may lead to conflicts in the Excel file. It may be necessary to run Excel repair to view the spreadsheet correctly. What happens if I try to insert a column into an empty Excel sheet using IronXL? Inserting a column into a completely empty sheet using IronXL will trigger a System.InvalidOperationException with the message 'Sequence contains no elements'. How do I save modifications to an Excel workbook after using IronXL? After modifying an Excel workbook with IronXL, you can save the changes by using the SaveAs method, specifying the file path for the updated workbook. What indexing system does IronXL use for rows and columns in Excel? IronXL uses zero-based indexing for rows and columns, meaning the index for both rows and columns starts at 0. Chaknith Bin Chat with engineering team now Software Engineer Chaknith works on IronXL and IronBarcode. He has deep expertise in C# and .NET, helping improve the software and support customers. His insights from user interactions contribute to better products, documentation, and overall experience. Ready to Get Started? Free NuGet Download Total downloads: 1,558,208 View Licenses