Test in a live environment
Test in production without watermarks.
Works wherever you need it to.
It's simple to create a CSV parser. With only two lines of code you can load a CSV document, convert and export it to Excel.
Before I show you how to create a CSV parser, we'll first install IronXL to your project (free in development and debugging environment).
You can download directly from the Iron Software website by using the following link: https://ironsoftware.com/csharp/excel/docs/
or
Simply, you can also use the Developer Command Prompt:
Install-Package IronXL.Excel
After you have installed IronXL, create a new project and add the IronXL namespace
using IronXL;
using IronXL;
Imports IronXL
The following code uses the Workbook object’s Load
method to load a CSV file into Excel. This file is then parsed. Lastly, it uses the SaveAs
method to save the file in the csv format.
private void button4_Click(object sender, EventArgs e)
{
// Import XLSX, XLS, XLSM, XLTX, CSV and TSV
WorkBook workBook = WorkBook.Load("Normal_Excel_File.xlsx");
//Exported as : Parsed_CSV.Sheet1.csv
workBook.SaveAs("Parsed_CSV.csv");
}
private void button4_Click(object sender, EventArgs e)
{
// Import XLSX, XLS, XLSM, XLTX, CSV and TSV
WorkBook workBook = WorkBook.Load("Normal_Excel_File.xlsx");
//Exported as : Parsed_CSV.Sheet1.csv
workBook.SaveAs("Parsed_CSV.csv");
}
Private Sub button4_Click(ByVal sender As Object, ByVal e As EventArgs)
' Import XLSX, XLS, XLSM, XLTX, CSV and TSV
Dim workBook As WorkBook = WorkBook.Load("Normal_Excel_File.xlsx")
'Exported as : Parsed_CSV.Sheet1.csv
workBook.SaveAs("Parsed_CSV.csv")
End Sub
Don’t forget to create an Excel Workbook named Normal_Excel_File.xlsx containing the following data:
Interestingly, the exported CSV file will be saved as Parsed_CSV.Sheet1.csv because the data is on Sheet1 inside of the Excel Workbook. Below is what the file would look like in File Explorer when selected.
Learn more and share how to merge, unmerge, and work with cells in Excel spreadsheets using the handy IronXL API Reference Documentation.
IronXL API Reference Documentation9 .NET API products for your office documents