How to Convert Excel to CSV in C#

We occasionally need to export data from one format to another for a variety of reasons. In this post, we’ll show you how to convert Excel to CSV in C# and provide some sample code. This article explains how to set up the functionality and perform simple document transformation to CSV format. In just a few minutes, you can convert Excel to CSV using C# by following the steps and code below.

Steps to Convert Excel to CSV in C#

  1. Install GroupDocs.Conversion for .NET package from the NuGet.org
  2. Use GroupDocs.Conversion namespace
  3. Initialize Converter class and input the source Excel file
  4. Create an object of the SpreadsheetConvertOptions class and set properties for the converted document
  5. Finally, save the converted file to disc by invoking the Converter class’s Convert method with the converted file name and an instance of the SpreadsheetConvertOptions class

You should now have a good understanding of how simple it is to follow these steps and develop the c# convert Excel to CSV feature. You can begin by downloading the needed package from the NuGet website and invoking the Converter class with the source Excel file. Then set the format for the rendering file by initializing the SpreadsheetConvertOptions class. Finally, pass the name of the output file to the Convert method, along with the object produced in the previous step, so that the document can be saved to a disc.

Code to Convert Excel to CSV in C#

We have written some sample code for basic document conversion that demonstrates how to use the C# convert XLSX to CSV capability. In addition to specifying the file type for the output document, we have also specified two properties for the converted document: the list of page indexes and the number of pages. You can also add many other attributes to the rendering document, such as a Password, the starting page number, the zoom level, and a Watermark.

The feature of converting a PDF to HTML in C# was discussed in our previous post. Check out the how to convert PDF to HTML using C# guide if you want to learn more.

 English