Test in production without watermarks.
Works wherever you need it to.
Get 30 days of fully functional product.
Have it up and running in minutes.
Full access to our support engineering team during your product trial
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
Alternatively, you can also use the Developer Command Prompt:
dotnet add package IronXL.Excel
After you have installed IronXL, create a new C# project and add the IronXL namespace to access its functionality:
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 various Excel file formats, such as XLSX, XLS, XLSM, XLTX, and CSV
WorkBook workBook = WorkBook.Load("Normal_Excel_File.xlsx");
// Export the loaded workbook to a CSV file named Parsed_CSV.csv
workBook.SaveAs("Parsed_CSV.csv");
}
private void button4_Click(object sender, EventArgs e)
{
// Import various Excel file formats, such as XLSX, XLS, XLSM, XLTX, and CSV
WorkBook workBook = WorkBook.Load("Normal_Excel_File.xlsx");
// Export the loaded workbook to a CSV file named Parsed_CSV.csv
workBook.SaveAs("Parsed_CSV.csv");
}
Private Sub button4_Click(ByVal sender As Object, ByVal e As EventArgs)
' Import various Excel file formats, such as XLSX, XLS, XLSM, XLTX, and CSV
Dim workBook As WorkBook = WorkBook.Load("Normal_Excel_File.xlsx")
' Export the loaded workbook to a CSV file named Parsed_CSV.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 DocumentationIronXL is a C# library that simplifies working with Excel files, including creating CSV parsers without using Interop.
You can install IronXL via the NuGet Package Manager in Visual Studio by searching for 'IronXL.Excel' or use the command 'dotnet add package IronXL.Excel' in the Developer Command Prompt.
Use the WorkBook object's Load method to load a CSV file into Excel, which allows you to inspect and modify the data in C#.
You can export the parsed data into a new CSV file using the SaveAs method, which will save each Excel sheet into a separate CSV file.
First, download and install IronXL. Create a new C# project and add the IronXL namespace. Load your CSV file into Excel using the Load method, then parse and export it using the SaveAs method.
IronXL is free to use in development and debugging environments, allowing you to test its functionality before purchasing.
The IronXL API Reference Documentation is available on the Iron Software website, offering detailed information on using the library's features.
IronXL can load various Excel file formats, including XLSX, XLS, XLSM, XLTX, and CSV.
The article provides a code example that uses the Load and SaveAs methods of the WorkBook object to parse and export CSV files. Review the current version of IronXL for any updates that might affect the code.
When exporting an Excel workbook with multiple sheets to CSV, IronXL saves each sheet as a separate CSV file.