IronXL How-Tos Convert Spreadsheet File Types How to Convert Spreadsheet File Types ByChaknith Bin April 4, 2023 Updated June 22, 2025 Share: View the IronXL YouTube Playlist Introduction IronXL supports the conversion of spreadsheet files between various formats, including XLS, XLSX, XLSM, XLTX, CSV, TSV, JSON, XML, and HTML. It also provides support for inline code data types such as HTML string, Binary, Byte array, Data set, and Memory stream. The Load method is used to open a spreadsheet file, and the SaveAs method is used to export the spreadsheet to the desired file type. How to Convert and Export (XLSX, XLS, XLSM, XLTX, CSV) in C# Install the C# library for converting Excel files to other file formats Use the WorkBook class to load or create new XLS or XLSX View, add, or modify data in the Excel spreadsheet using C# Utilize the methods in the WorkBook class to export the spreadsheet Check the exported file in the specified directory Get started with IronXL Start using IronXL in your project today with a free trial. First Step: Start for Free Convert Spreadsheet Type Example The process of converting spreadsheet types involves loading a file in one supported format and exporting it to another format using IronXL's intelligent data restructuring capabilities. While the SaveAs method can be used to export to CSV, JSON, XML, and HTML, it is recommended to use the dedicated methods for each file format: SaveAsCsv SaveAsJson SaveAsXml ExportToHtml Please noteFor CSV, TSV, JSON, and XML file formats, a separate file will be created for each worksheet. The naming convention follows the format fileName.sheetName.format. In the example below, the output for the CSV format would be sample.new_sheet.csv. // Example C# code to convert an Excel spreadsheet to different formats using IronXL using IronXL; class SpreadsheetConversion { static void Main() { // Load the Excel spreadsheet WorkBook workbook = WorkBook.Load("sample.xlsx"); // Convert and save as CSV workbook.SaveAsCsv("sample.csv"); // Convert and save as JSON workbook.SaveAsJson("sample.json"); // Convert and save as XML workbook.SaveAsXml("sample.xml"); // Convert and export to HTML workbook.ExportToHtml("sample.html"); // The files will be saved in the project's directory with the specified formats } } // Example C# code to convert an Excel spreadsheet to different formats using IronXL using IronXL; class SpreadsheetConversion { static void Main() { // Load the Excel spreadsheet WorkBook workbook = WorkBook.Load("sample.xlsx"); // Convert and save as CSV workbook.SaveAsCsv("sample.csv"); // Convert and save as JSON workbook.SaveAsJson("sample.json"); // Convert and save as XML workbook.SaveAsXml("sample.xml"); // Convert and export to HTML workbook.ExportToHtml("sample.html"); // The files will be saved in the project's directory with the specified formats } } ' Example C# code to convert an Excel spreadsheet to different formats using IronXL Imports IronXL Friend Class SpreadsheetConversion Shared Sub Main() ' Load the Excel spreadsheet Dim workbook As WorkBook = WorkBook.Load("sample.xlsx") ' Convert and save as CSV workbook.SaveAsCsv("sample.csv") ' Convert and save as JSON workbook.SaveAsJson("sample.json") ' Convert and save as XML workbook.SaveAsXml("sample.xml") ' Convert and export to HTML workbook.ExportToHtml("sample.html") ' The files will be saved in the project's directory with the specified formats End Sub End Class $vbLabelText $csharpLabel Advanced In the previous section, we explored the most common file formats for conversion. However, IronXL has the capability to convert spreadsheets to many more formats. Explore all the available options for loading and exporting spreadsheets. Load XLS, XLSX, XLSM, and XLTX CSV TSV Export XLS, XLSX, and XLSM CSV and TSV JSON XML HTML Inline code data types: HTML string Binary and Byte array Data set: Exporting Excel into System.Data.DataSet and System.Data.DataTable objects allows easy interoperability or integration with DataGrids, SQL, and EF. Memory stream The inline code data types can be sent as a RESTful API response or used with IronPDF to convert them into a PDF document. // Advanced example: converting an XLSX file to multiple formats using IronXL using IronXL; class AdvancedSpreadsheetConversion { static void Main() { // Load the Excel spreadsheet WorkBook workbook = WorkBook.Load("advanced_sample.xlsx"); // Convert and save to various formats workbook.SaveAs("advanced_sample.xlsm"); workbook.SaveAsCsv("advanced_sample.csv"); workbook.SaveAsJson("advanced_sample.json"); workbook.SaveAsXml("advanced_sample.xml"); workbook.ExportToHtml("advanced_sample.html"); // You can also convert to binary or byte array for advanced uses byte[] excelAsByteArray = workbook.ToBinaryData(); } } // Advanced example: converting an XLSX file to multiple formats using IronXL using IronXL; class AdvancedSpreadsheetConversion { static void Main() { // Load the Excel spreadsheet WorkBook workbook = WorkBook.Load("advanced_sample.xlsx"); // Convert and save to various formats workbook.SaveAs("advanced_sample.xlsm"); workbook.SaveAsCsv("advanced_sample.csv"); workbook.SaveAsJson("advanced_sample.json"); workbook.SaveAsXml("advanced_sample.xml"); workbook.ExportToHtml("advanced_sample.html"); // You can also convert to binary or byte array for advanced uses byte[] excelAsByteArray = workbook.ToBinaryData(); } } ' Advanced example: converting an XLSX file to multiple formats using IronXL Imports IronXL Friend Class AdvancedSpreadsheetConversion Shared Sub Main() ' Load the Excel spreadsheet Dim workbook As WorkBook = WorkBook.Load("advanced_sample.xlsx") ' Convert and save to various formats workbook.SaveAs("advanced_sample.xlsm") workbook.SaveAsCsv("advanced_sample.csv") workbook.SaveAsJson("advanced_sample.json") workbook.SaveAsXml("advanced_sample.xml") workbook.ExportToHtml("advanced_sample.html") ' You can also convert to binary or byte array for advanced uses Dim excelAsByteArray() As Byte = workbook.ToBinaryData() End Sub End Class $vbLabelText $csharpLabel The code above loads an ordinary XLSX file, then converts and exports it to several formats. The Spreadsheet We Will Convert XLSX file The various files exported are shown below. TSV File Export CSV File Export JSON File Export XML File Export HTML File Export Frequently Asked Questions What file formats can spreadsheets be converted to? IronXL can convert spreadsheets to various formats including XLS, XLSX, XLSM, XLTX, CSV, TSV, JSON, XML, and HTML. How do you load a spreadsheet file? You can load a spreadsheet file using the `Load` method of the `WorkBook` class in IronXL. Which method is used to export a spreadsheet to different file types? The `SaveAs` method is used to export spreadsheets to various file types such as CSV, JSON, XML, and HTML. Dedicated methods like `SaveAsCsv`, `SaveAsJson`, `SaveAsXml`, and `ExportToHtml` are recommended for specific formats. Can the library handle inline code data types? Yes, IronXL can handle inline code data types including HTML string, Binary, Byte array, Data set, and Memory stream. What is the purpose of the `WorkBook` class? The `WorkBook` class is used to load or create new XLS or XLSX files, view, add, or modify data, and export spreadsheets to various formats. How can I check if the exported files are saved correctly? After exporting, you can check the specified directory for the exported files to ensure they are saved correctly. Is it possible to convert a spreadsheet to multiple formats at once? Yes, you can convert a spreadsheet to multiple formats at once by calling the respective methods for each format on the `WorkBook` object. Can the library export to JSON or XML? Yes, IronXL can export to JSON and XML using the `SaveAsJson` and `SaveAsXml` methods respectively. What are the prerequisites for using the library in a project? You need to install the IronXL C# library, which can be done through NuGet, to use it in your project for converting Excel files to other file formats. What is the benefit of using the library for spreadsheet conversion? IronXL provides a simple and efficient way to convert spreadsheets between various formats with support for inline data types and advanced options such as exporting to a memory stream or byte array for further processing. Chaknith Bin Chat with engineering team now Software Engineer Chaknith is the Sherlock Holmes of developers. It first occurred to him he might have a future in software engineering, when he was doing code challenges for fun. His focus is on IronXL and IronBarcode, but he takes pride in helping customers with every product. Chaknith leverages his knowledge from talking directly with customers, to help further improve the products themselves. His anecdotal feedback goes beyond Jira tickets and supports product development, documentation and marketing, to improve customer’s overall experience.When he isn’t in the office, he can be found learning about machine learning, coding and hiking. Ready to Get Started? Start Free Trial Total downloads: 1,446,926 View Licenses >