Information is sometimes exchanged as key-value pairs, or comma-separated values (CSV) in different scenarios. In certain cases, you might need to manipulate or convert that CSV data to Excel (XLS or XLSX) format for further processing. So let us walk through the process of converting CSV files to Excel XLS XLSX in C#.
- C# CSV to Excel Converter – Free Download
- Steps to Convert CSV Files to Excel XLS in C#
- Export CSV to XLSX in C#
C# CSV to Excel Converter – Free Download
Aspose.Cells for .NET is an amazing API for the inter-conversion of CSV and Excel (XLS/XLSX) files. We will use this API to convert our CSV files to XLS/XLSX formats. You can download it from New Releases or use the command below to install it from NuGet.
PM> Install-Package Aspose.Cells
Steps to Convert CSV to XLSX in C#
Aspose.Cells for .NET provides the simplest way of converting CSV files to Excel XLS or XLSX format. The following are the steps that you need to perform for CSV to Excel conversion.
- Load the CSV file from the disk.
- Create a new Excel file.
- Export data from CSV file to Excel worksheet.
- Save the Excel file to the desired location.
Let’s now have a look at how to convert a CSV file to XLS in C#.
Export CSV to XLS in C#
The following are the steps to save a CSV file as XLS in C#.
- Create an instance of LoadOptions class and set the load format as CSV.
- Create a Workbook object and load the CSV file.
- Save the Excel file using Workbook.Save() method to desired location.
The code below shows how to convert a CSV file to Excel XLSX in C#.
CSV to XLS C# Converter - Get a Free License
You can get a free temporary license and convert CSV files to Excel format without evaluation limitations.
In this article, you have learned how to convert CSV files to Excel XLS or XLSX in C#. The steps and code sample have demonstrated how to export data from a CSV file to XLSX in C#. Likewise, different other file format conversions are also possible that you can explore by visiting documentation and API references. Moreover, you can always reach out to us at our free support forum.