CSV (Comma Separated Values) is used to save data in plain-text form. Because of its simple format, data in CSV files can load to spreadsheet and database. Also, because it is widely recognized, some software applications support to import or export CSV.
In this post, I will introduce a method to convert Excel to CSV. The original Excel file I want to convert has several formats, such as font style, background color and so on. After converting, we can find that all the formats in original file are moved.
Original Excel File
The following steps show details to convert Excel to CSV by using C#.
Note: I use a C# .NET Excel component Spire.XLS for .NET in my example. Therefore, I have added its DLL file as reference in my project. The other references I add is system.text because CSV is plain text file.
- Load the file which I want to convert and initialize worksheets.
- Save this file to CSV.
- Launch this converted file.
static void Main(string args)
//Load File and Initialize Worksheet
Workbook workbook = new Workbook();
Worksheet sheet = workbook.Worksheets;
//Save File as CSV and Launch