Automate Excel with C#

The Basics C# Excel Recipes

This collection contains basic C# recipes for working with Excel such as creating, reading, merging, splitting or formatting Excel with C#.

Convert

How to read JSON and convert list of results to an Excel file using C#

This C# recipe shows how you can query a JSON url and write the results to Excel using C#

How to convert an XLS Excel file to XLSX Excel file

This C# recipe shows how you can convert a XLS file to XLSX file

Creating

How to create an Excel file (XLSX) in C# and populate it using a list of C# objects

This C# recipe shows how you can use EPPlus library to create an Excel file and populate the first worksheet from a list of C# objects

How to create an Excel file (XLSX) in C#

This C# recipe shows how you can use EPPlus library to create an Excel file. Noteably this library does not require Excel to be installed on the server.

Delete

How to delete columns in Excel using C#

This C# recipe shows how you can use EPPlus library to open an Excel file and delete specific columns

Merging

How to merge two Excel Files into a single Excel file

This C# recipe shows how you can merge two Excel files into one Excel file

How to merge multiple Excel Files into a single Excel file

This C# recipe shows how you can use merge multiple Excel files within a directory into a single Excel file

How to merge multiple COLUMNS in an Excel File using C#

This C# recipe shows how you can use merge multiple columns in an Excel file using the EPPlus library

Password

How to unprotect a password protected Excel file in C#

This C# recipe shows how you can unprotect a password protected Excel file and save it a as an unprotected file

How to password protect an Excel file in C#

This C# recipe shows how you can open an unprotected Excel file and save it as a new password protected Excel file

Splitting

How to split an Excel file into multiple Excel files in C#

This C# recipe shows how you split an Excel file's worksheets into multiple Excel files within a directory

Reading

How to read an Excel file and convert it to a List of C# objects

This C# recipe shows how you can use EPPlus library to open an Excel file and read the contents of the first worksheet to a List of C# objects