add delete rows or columns in Excel in C#

Excel files are widely used to create and manipulate spreadsheets within different applications programmatically. While processing a spreadsheet, you may need to add new rows and columns or delete the existing ones from the worksheets. To achieve that, this article shows how to add or delete rows and columns in Excel in C#.

C# Library to Add or Delete Excel Rows and Columns

To add or delete rows and columns in Excel XLSX/XLS files, we’ll use Aspose.Cells for .NET. It is a high-speed and powerful library to create and process Excel files seamlessly. In addition, it provides a high fidelity converter for back and forth conversion of XLSX files. You can download it’s DLL from the downloads section or install it from NuGet.

PM> Install-Package Aspose.Cells

How to Add Rows in Excel in C#

The following are the steps to add rows in an Excel worksheet in C#.

The following code sample shows how to add rows in an Excel worksheet using C#.

How to Add Columns in Excel in C#

The following are the steps to add columns in an Excel worksheet using C#.

The following code sample shows how to add columns in an Excel worksheet using C#.

Delete Rows in an Excel XLSX in C#

The following are the steps to delete rows from an Excel worksheet using C#.

The following code sample shows how to delete rows from an Excel worksheet in C#.

Delete Columns in Excel XLSX in C#

The following are the steps to delete columns from an Excel worksheet using C#.

The following code sample shows how to delete columns from an Excel worksheet using C#.

Get a Free API License

You can get a free temporary license in order to use the API without evaluation limitations.

Conclusion

In this article, you have learned how to work with rows and columns in Excel programmatically. Particularly, you have seen how to add or delete rows and columns in Excel worksheets in C#. In addition, you can explore more about the C# Excel API using the documentation. Furthermore, you can share your queries with us via our forum.

See Also