IronXL How-Tos C# Export to Excel C# Export to Excel: Complete Developer Guide Jacob Mellor Updated:July 28, 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. 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: using IronXL; namespace ExcelExportExample { class Program { static void Main() { // Load an existing .xls workbook WorkBook workbook = WorkBook.Load("XlsFile.xls"); // Save as modern .xlsx format workbook.SaveAs("newFile.xlsx"); // Custom path example // workbook.SaveAs(@"E:\ExcelExports\ModernFormat.xlsx"); } } } using IronXL; namespace ExcelExportExample { class Program { static void Main() { // Load an existing .xls workbook WorkBook workbook = WorkBook.Load("XlsFile.xls"); // Save as modern .xlsx format workbook.SaveAs("newFile.xlsx"); // Custom path example // workbook.SaveAs(@"E:\ExcelExports\ModernFormat.xlsx"); } } } Imports IronXL Namespace ExcelExportExample Friend Class Program Shared Sub Main() ' Load an existing .xls workbook Dim workbook As WorkBook = WorkBook.Load("XlsFile.xls") ' Save as modern .xlsx format workbook.SaveAs("newFile.xlsx") ' Custom path example ' workbook.SaveAs(@"E:\ExcelExports\ModernFormat.xlsx"); End Sub End Class End Namespace $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. How to Export Excel to XLS Format? Legacy systems sometimes require the older .xls format. IronXL handles this conversion seamlessly: using IronXL; namespace XlsExportExample { class Program { static void Main() { // Load a modern .xlsx workbook WorkBook workbook = WorkBook.Load("XlsxFile.xlsx"); // Export to legacy .xls format workbook.SaveAs("legacyFormat.xls"); } } } using IronXL; namespace XlsExportExample { class Program { static void Main() { // Load a modern .xlsx workbook WorkBook workbook = WorkBook.Load("XlsxFile.xlsx"); // Export to legacy .xls format workbook.SaveAs("legacyFormat.xls"); } } } Imports IronXL Namespace XlsExportExample Friend Class Program Shared Sub Main() ' Load a modern .xlsx workbook Dim workbook As WorkBook = WorkBook.Load("XlsxFile.xlsx") ' Export to legacy .xls format workbook.SaveAs("legacyFormat.xls") End Sub End Class End Namespace $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. 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: using IronXL; namespace CsvExportExample { class Program { static void Main() { // Load Excel workbook (supports .xlsx, .xls, .xlsm) WorkBook workbook = WorkBook.Load("sample.xlsx"); // Export all worksheets to CSV files workbook.SaveAsCsv("exportedData.csv"); // Optional: Specify custom delimiter // workbook.SaveAsCsv("exportedData.csv", ","); } } } using IronXL; namespace CsvExportExample { class Program { static void Main() { // Load Excel workbook (supports .xlsx, .xls, .xlsm) WorkBook workbook = WorkBook.Load("sample.xlsx"); // Export all worksheets to CSV files workbook.SaveAsCsv("exportedData.csv"); // Optional: Specify custom delimiter // workbook.SaveAsCsv("exportedData.csv", ","); } } } Imports IronXL Namespace CsvExportExample Friend Class Program Shared Sub Main() ' Load Excel workbook (supports .xlsx, .xls, .xlsm) Dim workbook As WorkBook = WorkBook.Load("sample.xlsx") ' Export all worksheets to CSV files workbook.SaveAsCsv("exportedData.csv") ' Optional: Specify custom delimiter ' workbook.SaveAsCsv("exportedData.csv", ","); End Sub End Class End Namespace $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. How to Export Excel Data to XML? XML export enables structured data exchange with enterprise systems. IronXL simplifies this process: using IronXL; namespace XmlExportExample { class Program { static void Main() { // Load Excel workbook WorkBook workbook = WorkBook.Load("sample.xlsx"); // Export all worksheets to XML format workbook.SaveAsXml("dataExport.xml"); } } } using IronXL; namespace XmlExportExample { class Program { static void Main() { // Load Excel workbook WorkBook workbook = WorkBook.Load("sample.xlsx"); // Export all worksheets to XML format workbook.SaveAsXml("dataExport.xml"); } } } Imports IronXL Namespace XmlExportExample Friend Class Program Shared Sub Main() ' Load Excel workbook Dim workbook As WorkBook = WorkBook.Load("sample.xlsx") ' Export all worksheets to XML format workbook.SaveAsXml("dataExport.xml") End Sub End Class End Namespace $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. How to Generate JSON from Excel Files? Modern web applications often require JSON format for data exchange. IronXL provides direct JSON export functionality: using IronXL; namespace JsonExportExample { class Program { static void Main() { // Load Excel workbook WorkBook workbook = WorkBook.Load("sample.xlsx"); // Export worksheets to JSON format workbook.SaveAsJson("dataExport.json"); } } } using IronXL; namespace JsonExportExample { class Program { static void Main() { // Load Excel workbook WorkBook workbook = WorkBook.Load("sample.xlsx"); // Export worksheets to JSON format workbook.SaveAsJson("dataExport.json"); } } } Imports IronXL Namespace JsonExportExample Friend Class Program Shared Sub Main() ' Load Excel workbook Dim workbook As WorkBook = WorkBook.Load("sample.xlsx") ' Export worksheets to JSON format workbook.SaveAsJson("dataExport.json") End Sub End Class End Namespace $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. 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,487,525 View Licenses