IronXL How-Tos C# Export to Excel C# Export to Excel: Complete Developer Guide Jacob Mellor Updated:August 20, 2025 Working with Excel data often requires exporting spreadsheets to different formats for integration with various systems and applications. This guide demonstrates how to export Excel files to multiple formats including .xlsx, .xls, .csv, .xml, and .json using C# and IronXL—without requiring Microsoft Office Interop dependencies. How to Export Excel Files in C# Download the C# library to export Excel files Load existing Excel workbooks using the `WorkBook.Load()` method Export to XLSX format with the `.xlsx` extension Convert Excel files to CSV using `SaveAsCsv()` Export spreadsheet data to XML with `SaveAsXml()` Generate JSON files from Excel using `SaveAsJson()` Step 1 How to Install IronXL for Excel Export? IronXL provides a streamlined approach to working with Excel files in .NET applications. Download the IronXL DLL directly or install via NuGet for development and testing. Install-Package IronXL.Excel After installation, add the IronXL reference to access all Excel manipulation features through the IronXL namespace. The library supports .NET Framework, .NET Core, and .NET 5+ applications, making it compatible with modern development environments. How to Tutorial What Excel Export Formats Does C# Support? IronXL enables seamless data export from Excel workbooks to multiple file formats. The library supports exporting to: Excel formats: .xlsx (modern) and .xls (legacy) Data interchange formats: .csv, .json, and .xml Tab-separated values: .tsv Each format serves specific use cases—CSV for database imports, JSON for web APIs, and XML for enterprise system integration. We can also export the file formats metioned above to their respective output streams to intergrate with other applications. Let's explore how to implement each export type. How to Export Excel to XLSX in C#? Converting between Excel formats is straightforward with IronXL. The following example demonstrates loading an older .xls file and saving it as a modern .xlsx file: :path=/static-assets/excel/content-code-examples/how-to/c-sharp-export-to-excel-xlsx.cs using IronXL; // Import .xls, .csv, or .tsv file WorkBook workbook = WorkBook.Load("XlsFile.xls"); // Export as .xlsx file workbook.SaveAs("newFile.xlsx"); Imports IronXL ' Import .xls, .csv, or .tsv file Private workbook As WorkBook = WorkBook.Load("XlsFile.xls") ' Export as .xlsx file workbook.SaveAs("newFile.xlsx") $vbLabelText $csharpLabel The SaveAs method automatically detects the desired format based on the file extension. When converting from .xls to .xlsx, the process preserves all worksheets, formulas, formatting, and data types. This conversion is particularly useful when modernizing legacy Excel files for compatibility with newer Office versions. Export to XLSX Stream Alternatively, you can also use ToXlsxStream to export the document to an XLSX to integrate with other applications. Here's a brief example on how to do it. :path=/static-assets/excel/content-code-examples/how-to/c-sharp-export-to-excel-xlsx-stream.cs using IronXL; // Load the workbook WorkBook workbook = WorkBook.Load("xlsFile.xlsx"); // Exports the workbook to a XLSX stream. var stream = workbook.ToXlsxStream(); Imports IronXL ' Load the workbook Private workbook As WorkBook = WorkBook.Load("xlsFile.xlsx") ' Exports the workbook to a XLSX stream. Private stream = workbook.ToXlsxStream() $vbLabelText $csharpLabel How to Export Excel to XLS Format? Legacy systems sometimes require the older .xls format. IronXL handles this conversion seamlessly: :path=/static-assets/excel/content-code-examples/how-to/c-sharp-export-to-excel-xls.cs using IronXL; // Import .xlsx, .csv or .tsv file WorkBook workbook = WorkBook.Load("XlsxFile.xlsx"); // Export as .xls file workbook.SaveAs("newFile.xls"); Imports IronXL ' Import .xlsx, .csv or .tsv file Private workbook As WorkBook = WorkBook.Load("XlsxFile.xlsx") ' Export as .xls file workbook.SaveAs("newFile.xls") $vbLabelText $csharpLabel This conversion maintains compatibility with Excel 97-2003 versions. The SaveAs method handles the format conversion internally, ensuring data integrity while adapting to the .xls format limitations such as the 65,536 row limit per worksheet. Export to XLS Stream In addition to using SaveAs to export to the legacy .XLS format, IronXL also supports exporting as an XLS stream. :path=/static-assets/excel/content-code-examples/how-to/c-sharp-export-to-excel-xls-stream.cs using IronXL; // Load the workbook WorkBook workbook = WorkBook.Load("xlsxFile.xlsx"); // Exports the workbook to a XLS stream. workbook.ToXlsStream(); Imports IronXL ' Load the workbook Private workbook As WorkBook = WorkBook.Load("xlsxFile.xlsx") ' Exports the workbook to a XLS stream. workbook.ToXlsStream() $vbLabelText $csharpLabel How to Convert Excel to CSV in C#? CSV export is essential for data exchange between different systems. IronXL provides a dedicated method for CSV conversion: :path=/static-assets/excel/content-code-examples/how-to/c-sharp-export-to-excel-csv.cs using IronXL; // Import .xlsx or xls file WorkBook workbook = WorkBook.Load("sample.xlsx"); // Export as .xls file workbook.SaveAsCsv("newFile.csv"); Imports IronXL ' Import .xlsx or xls file Private workbook As WorkBook = WorkBook.Load("sample.xlsx") ' Export as .xls file workbook.SaveAsCsv("newFile.csv") $vbLabelText $csharpLabel When exporting multi-sheet workbooks, IronXL creates separate CSV files for each worksheet. For a workbook with three sheets named "Sheet1", "Sheet2", and "Sheet3", the export generates: Multiple CSV files generated from a three-sheet Excel workbook, with each worksheet exported as a separate CSV file The original Excel file structure with three worksheets: Original Excel workbook displaying three worksheets that will be exported as individual CSV files The SaveAsCsv method preserves data values while removing formatting, formulas, and other Excel-specific features. This makes CSV ideal for importing data into databases or processing with other applications. Export Excel Worksheet to CSV Stream To convert only a specified worksheet within the workbook to a CSV stream, we can use the ToCsvStream method and provide an integer indicating the worksheet's index to return as a CSV stream. Below is an example of this method. :path=/static-assets/excel/content-code-examples/how-to/c-sharp-export-to-excel-csv-stream.cs using IronXL; // Load the workbook WorkBook workbook = WorkBook.Load("sample.xlsx"); // Exports the first sheet of the workbook to a CSV stream var stream = workbook.ToCsvStream(0); Imports IronXL ' Load the workbook Private workbook As WorkBook = WorkBook.Load("sample.xlsx") ' Exports the first sheet of the workbook to a CSV stream Private stream = workbook.ToCsvStream(0) $vbLabelText $csharpLabel Export All to CSV Stream IronXL also supports converting the entire workbook into a CSV stream; we use the method ToCsvStreams instead to convert all worksheets in the workbook. :path=/static-assets/excel/content-code-examples/how-to/c-sharp-export-to-excel-csv-streams.cs using IronXL; // Load the workbook WorkBook workbook = WorkBook.Load("sample.xlsx"); // Exports the entire workbook to a CSV stream var workBookStream = workbook.ToCsvStreams(); Imports IronXL ' Load the workbook Private workbook As WorkBook = WorkBook.Load("sample.xlsx") ' Exports the entire workbook to a CSV stream Private workBookStream = workbook.ToCsvStreams() $vbLabelText $csharpLabel How to Export Excel Data to XML? XML export enables structured data exchange with enterprise systems. IronXL simplifies this process: :path=/static-assets/excel/content-code-examples/how-to/c-sharp-export-to-excel-xml.cs using IronXL; // Import .xlsx, .xls or .csv file WorkBook workbook = WorkBook.Load("sample.xlsx"); // Export as .xml file workbook.SaveAsXml("newFile.xml"); Imports IronXL ' Import .xlsx, .xls or .csv file Private workbook As WorkBook = WorkBook.Load("sample.xlsx") ' Export as .xml file workbook.SaveAsXml("newFile.xml") $vbLabelText $csharpLabel The SaveAsXml method converts each worksheet into a separate XML file with a structured representation of the spreadsheet data. This includes: Cell values and data types Row and column positioning Basic structural information XML export is particularly valuable for integrating Excel data with web services or systems that require structured data formats. Export Data as XML Stream To export a specified worksheet to an XML stream, we use the ToXmlStream method and provide an integer parameter, which represents the index of the worksheet. :path=/static-assets/excel/content-code-examples/how-to/c-sharp-export-to-excel-xml-stream.cs using IronXL; // Load the workbook WorkBook workbook = WorkBook.Load("sample.xlsx"); // Converts the first worksheet to a XML Stream var stream = workbook.ToXmlStream(0); Imports IronXL ' Load the workbook Private workbook As WorkBook = WorkBook.Load("sample.xlsx") ' Converts the first worksheet to a XML Stream Private stream = workbook.ToXmlStream(0) $vbLabelText $csharpLabel Export All Data to XML Streams To export the entire workbook as XML streams, we use the ToXmlStreams method. :path=/static-assets/excel/content-code-examples/how-to/c-sharp-export-to-excel-xml-streams.cs using IronXL; // Load the workbook WorkBook workbook = WorkBook.Load("sample.xlsx"); // Exports the entire workbook to a XML stream var workBookStream = workbook.ToXmlStreams(); Imports IronXL ' Load the workbook Private workbook As WorkBook = WorkBook.Load("sample.xlsx") ' Exports the entire workbook to a XML stream Private workBookStream = workbook.ToXmlStreams() $vbLabelText $csharpLabel How to Generate JSON from Excel Files? Modern web applications often require JSON format for data exchange. IronXL provides direct JSON export functionality: :path=/static-assets/excel/content-code-examples/how-to/c-sharp-export-to-excel-json.cs using IronXL; // Import Excel file WorkBook workbook = WorkBook.Load("sample.xlsx"); // Export as JSON file workbook.SaveAsJson("newFile.json"); Imports IronXL ' Import Excel file Private workbook As WorkBook = WorkBook.Load("sample.xlsx") ' Export as JSON file workbook.SaveAsJson("newFile.json") $vbLabelText $csharpLabel The SaveAsJson method creates JSON files with array-based structures representing spreadsheet data. Each worksheet exports as a separate JSON file, making it easy to: Integrate with RESTful APIs Process data in JavaScript applications Store spreadsheet data in NoSQL databases For advanced scenarios, developers can combine JSON export with IronXL's data manipulation features to transform data before exporting. Export Excel Worksheet as JSON Stream To convert a specified worksheet to a JSON stream, we use the method ToJsonStream and provide an integer as an index of the worksheet you wish to convert. :path=/static-assets/excel/content-code-examples/how-to/c-sharp-export-to-excel-json-stream.cs using IronXL; // Load the workbook WorkBook workbook = WorkBook.Load("sample.xlsx"); // Exports the first sheet of the workbook to a JSON stream var stream = workbook.ToJsonStream(0); Imports IronXL ' Load the workbook Private workbook As WorkBook = WorkBook.Load("sample.xlsx") ' Exports the first sheet of the workbook to a JSON stream Private stream = workbook.ToJsonStream(0) $vbLabelText $csharpLabel Export All as JSON Streams To convert the entire workbook to a JSON stream, we use the method ToJsonStreams instead. :path=/static-assets/excel/content-code-examples/how-to/c-sharp-export-to-excel-json-streams.cs using IronXL; // Load the workbook WorkBook workbook = WorkBook.Load("sample.xlsx"); // Exports the entire workbook to a JSON stream var workBookStream = workbook.ToJsonStreams(); Imports IronXL ' Load the workbook Private workbook As WorkBook = WorkBook.Load("sample.xlsx") ' Exports the entire workbook to a JSON stream Private workBookStream = workbook.ToJsonStreams() $vbLabelText $csharpLabel Tutorial Quick Access API Reference Documentation Explore the complete IronXL API including all namespaces, classes, methods, and properties for advanced Excel manipulation. View API Reference Ready to Export Excel Files? IronXL simplifies Excel file export operations in C# applications. Whether converting between Excel formats or exporting to data interchange formats like CSV, JSON, or XML, the library provides intuitive methods that handle complex conversions automatically. Start implementing Excel export functionality today with a free trial of IronXL. For production deployments, explore our flexible licensing options designed for teams of all sizes. Get stated with IronXL now. Start for Free Frequently Asked Questions What is the purpose of this tutorial? This tutorial teaches developers how to export Excel spreadsheet data into various formats including .xml, .csv, .xls, .xlsx, and .json using C# and IronXL, eliminating the need for Microsoft.Office.Interop.Excel dependencies. How can I install the library for Excel file export? Install IronXL through NuGet Package Manager using the command Install-Package IronXL.Excel or download the DLL directly from the IronXL website for manual installation. What file formats are supported for Excel export? IronXL supports exporting Excel data to .xls, .xlsx, .csv, .tsv, .xml, and .json formats, each serving different integration requirements. How do I export Excel files to CSV format? Use the SaveAsCsv() method to export Excel files to CSV format. When exporting workbooks with multiple sheets, IronXL creates separate CSV files for each worksheet automatically. Can I export Excel data to XML format? Yes, IronXL provides the SaveAsXml() method to export Excel data to XML format. Each worksheet exports as a separate XML file with structured data representation. How do I convert Excel files to JSON? Use the SaveAsJson() method to export Excel data to JSON format. IronXL creates array-based JSON structures for each worksheet, ideal for web API integration. Where are exported files saved by default? By default, exported files save to the bin\Debug folder of the project. Specify custom paths using the full file path in the SaveAs() method parameters. What's required to export Excel files successfully? Include the correct file extension when specifying the export filename, ensure IronXL is properly referenced in the project, and use the appropriate export method for each format. Is Microsoft Office required for Excel export operations? No, IronXL operates independently without requiring Microsoft Office installation, providing a modern alternative to the legacy Microsoft.Office.Interop.Excel library. Can I export specific worksheets instead of entire workbooks? Yes, access individual worksheets using WorkBook.WorkSheets[index] or WorkBook.GetWorkSheet(name), then use worksheet-specific export methods like SaveAsCsv() on the WorkSheet object. Jacob Mellor Chat with engineering team now Chief Technology Officer Jacob Mellor is Chief Technology Officer at Iron Software and a visionary engineer pioneering C# PDF technology. As the original developer behind Iron Software's core codebase, he has shaped the company's product architecture since its inception, transforming it alongside CEO Cameron Rimington into a 50+ person company serving NASA, Tesla, and global government agencies.Jacob holds a First-Class Honours Bachelor of Engineering (BEng) in Civil Engineering from the University of Manchester (1998–2001). After opening his first software business in London in 1999 and creating his first .NET components in 2005, he specialized in solving complex problems across the Microsoft ecosystem.His flagship IronPDF & IronSuite .NET libraries have achieved over 30 million NuGet installations globally, with his foundational code continuing to power developer tools used worldwide. With 25 years of commercial experience and 41 years of coding expertise, Jacob remains focused on driving innovation in enterprise-grade C#, Java, and Python PDF technologies while mentoring the next generation of technical leaders. Ready to Get Started? Free NuGet Download Total downloads: 1,510,123 View Licenses