IRONSOFTWAREHOME

How to Convert XLSX to CSV, JSON, XML and more in C#

Curtis Chau
Curtis Chau
Updated: August 2, 2026

IronXL converts Excel files to multiple formats including JSON, CSV, XML, and older Excel formats like XLS, using simple one-line commands that eliminate manual parsing.

IronXL converts any Excel file into various formats, providing developers with tools to work with Excel in C# without Interop. Whether migrating data between systems, creating data exports for web applications, or integrating with legacy systems, IronXL simplifies the conversion process.

These formats include: JSON for modern web APIs, CSV for data interchange, XML for structured data storage, and older Excel formats such as XLS for backward compatibility. Each format serves specific use cases - CSV works well for database imports, JSON integrates with REST APIs, and XML maintains hierarchical data relationships.

This article demonstrates how to use IronXL to convert to XML, CSV, JSON, and export Excel worksheets as datasets for direct integration with .NET data controls.

Quickstart: Convert an XLSX file to CSV with one line

This example shows how IronXL converts an existing Excel workbook into a CSV file in one line. Load your workbook and save it directly as CSV to get started immediately.

  1. 1Install IronXL with NuGet Package Manager

    PM > Install-Package IronXL.Excel

  2. 2Copy and run this code snippet.

    IronXL.WorkBook.Load("input.xlsx").SaveAsCsv("output.csv");
    C#
  3. 3Deploy to test on your live environment

    Start using IronXL in your project today with a free trial
    arrow pointer

Step 1

How Do I Install the IronXL Library?

First, install IronXL before using it in your applications. IronXL supports .NET MAUI, Blazor, and traditional .NET applications. Use either of these installation methods:

Download: https://ironsoftware.com/csharp/excel/docs/

Or use the NuGet Package Manager:

  • Right-click the Solution name in Solution Explorer
  • Click Manage NuGet Packages
  • Browse for IronXL.Excel
  • Install

PM > Install-Package IronXL.Excel


How to Tutorial

How Can I Convert Excel Files to Different Formats?

IronXL provides conversion capabilities that handle complex parsing and formatting automatically.

Add the following code:

using IronXL;

// Load an existing Excel workbook
WorkBook workbook = WorkBook.Load("Normal_Excel_File.xlsx");

// Set metadata title for the workbook
workbook.Metadata.Title = "Normal_Excel_File.xlsx";

// Save the workbook in different formats
workbook.SaveAs("XLS_Export.xls");
workbook.SaveAs("XLSX_Export.xlsx");
workbook.SaveAsCsv("CSV_Export.csv");
workbook.SaveAsJson("JSON_Export.json");
workbook.SaveAsXml("XML_Export.xml");

// Convert the workbook to a DataSet, allowing integration with other data tools like DataGridView
System.Data.DataSet dataSet = workbook.ToDataSet();

The code above loads an XLSX file, adds a Title, then converts it to several formats. When converting to CSV, IronXL handles special characters, multi-line cells, and proper escaping. For JSON exports, it creates a structured object representation of your spreadsheet data. XML conversion preserves cell formatting and data types. Finally, it exports the Worksheet as a DataSet for use with DataGridView objects, which works well when working with DataTables.

Here's another example showing how to convert specific worksheets with custom options:

using IronXL;

// Load workbook and select specific worksheet
WorkBook workbook = WorkBook.Load("MultiSheet.xlsx");
WorkSheet sheet = workbook.WorkSheets["SalesData"];

// Convert just one worksheet to CSV with custom delimiter
sheet.SaveAsCsv("SalesData.csv", delimiter: ";");

// Export to JSON
sheet.SaveAsJson("SalesData.json");

// Convert to XML
sheet.SaveAsXml("SalesData.xml");
C#

For advanced scenarios, you can export to multiple formats simultaneously or handle large files efficiently:

using IronXL;
using System.Threading.Tasks;

// Async conversion for large files
public async Task ConvertLargeFileAsync(string inputPath)
{
    WorkBook workbook = WorkBook.Load(inputPath);
    
    // Parallel export to multiple formats
    var tasks = new[]
    {
        Task.Run(() => workbook.SaveAsCsv("output.csv")),
        Task.Run(() => workbook.SaveAsJson("output.json")),
        Task.Run(() => workbook.SaveAsXml("output.xml"))
    };
    
    await Task.WhenAll(tasks);
}

The various exported files are shown below.

CSV file export showing comma-separated values in a text editor with properly escaped data

Figure 1

CSV File Export

XML export displaying hierarchical structure with properly formatted elements and attributes representing Excel data

Figure 2

XML Export

JSON export showing structured data in JavaScript object notation format with proper nesting and data types

Figure 3

JSON Export

XLS export opened in Microsoft Excel showing compatibility with older Excel format while preserving formatting

Figure 4

XLS Export

Original Excel XLSX file showing source data with multiple columns and formatting before conversion to various formats

Figure 5

Excel Input for all exports

Each conversion format serves different purposes in modern applications. CSV files work well for importing data into databases or data analysis tools. JSON format suits web APIs and JavaScript applications. XML maintains data structure and is commonly used in enterprise systems. The legacy XLS format ensures compatibility with older Excel versions and systems that require backward compatibility.

When working with these conversions, IronXL handles many complexities automatically:

  • Character Encoding: Proper UTF-8 encoding for international characters
  • Data Type Preservation: Maintains numeric, date, and text formatting
  • Formula Evaluation: Calculates formula results before export
  • Large File Handling: Efficient memory usage for big spreadsheets
  • Error Handling: Graceful handling of corrupted or protected files

For applications requiring high performance or dealing with file size limits, IronXL provides optimization options. You can integrate these conversions into automated workflows, web services, or desktop applications.


Library Quick Access

IronXL API Reference Documentation

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 Documentation

Frequently Asked Questions

How can I convert an XLSX file to CSV using IronXL?

With IronXL, you can convert an XLSX file to CSV using a single line of code. Load your workbook with IronXL and save it directly as a CSV file using `WorkBook.Load("input.xlsx").SaveAsCsv("output.csv");`.

What formats can IronXL convert Excel files into?

IronXL can convert Excel files into multiple formats such as CSV, JSON, XML, and XLS. These formats are useful for various applications, including data interchange and legacy system integration.

Does IronXL support Excel conversion in .NET applications?

Yes, IronXL supports conversion in various .NET application frameworks, including .NET MAUI, Blazor, and traditional .NET applications.

Can IronXL handle special characters and multi-line cells during CSV conversion?

Yes, IronXL handles special characters, multi-line cells, and proper data escaping when converting Excel files to CSV format.

Is it possible to convert only specific worksheets using IronXL?

Yes, you can select specific worksheets for conversion in IronXL. Load the workbook, select a worksheet, and save it using methods like `sheet.SaveAsCsv("SalesData.csv")`.

How does IronXL handle formula evaluation in Excel files?

IronXL can evaluate formulas in Excel files before export, ensuring that the final output includes computed values rather than the formula text.

What are the advantages of using JSON format with IronXL?

The JSON format is advantageous for its integration with web APIs and JavaScript applications. IronXL enables conversion of Excel data to JSON, preserving the structured data representation.

How does IronXL ensure compatibility with older Excel versions?

IronXL can export Excel files to the legacy XLS format, maintaining backward compatibility for applications and systems that require older Excel file support.

Can IronXL be used for automated workflows involving Excel file conversions?

Yes, IronXL supports integration into automated workflows and web services, providing efficient and comprehensive conversion solutions for diverse applications.

Does IronXL support large file handling during Excel conversions?

IronXL is optimized for large files, using efficient memory management to process big spreadsheets during conversions while maintaining performance.

Curtis Chau
Technical Writer

Curtis Chau holds a Bachelor’s degree in Computer Science (Carleton University) and specializes in front-end development with expertise in Node.js, TypeScript, JavaScript, and React. Passionate about crafting intuitive and aesthetically pleasing user interfaces, Curtis enjoys working with modern frameworks and creating well-structured, visually appealing manuals.

...
Read More

Ready to Get Started?

Nuget Downloads 2,237,574Version:2026.9just released

Get your free 30-day Trial Key instantly.
No credit card or account creation required
C# NuGet Library for PDF
Install with NuGet

Version: 2026.9

PM > Install-Package IronXL.Excel
nuget.org/packages/IronXL.Excel/
  1. In Solution Explorer, right-click References, Manage NuGet Packages
  2. Select Browse and search "IronXL"
  3. Select the package and install
C# PDF DLL
Download DLL

Version: 2026.9

  1. Download and unzip IronXL to a location such as ~/Libs within your Solution directory
  2. In Visual Studio Solution Explorer, right click References. Select Browse, "IronXL.dll"

Licenses from $999

Key in blue circle

Get your free 30-day Trial Key instantly.

Your trial license will be sent to your email address

No limitations. 100% unlocked. No credit card.

bullet_checkedNo credit card or account creation requiredNo limitations. 100% unlocked. No credit card.
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
Book your free Live Demo
Booking Badge

Trusted by Millions of Engineers Worldwide

Iron Software's customer logos
Get Your No-Obligation Consult
Complete the form below or email sales@ironsoftware.com
Your details will always be kept confidential.
Trusted by Millions of Engineers Worldwide
Iron Software's customer logos
Get your free 30-day Trial Key instantly.
No credit card or account creation required