IRONSOFTWAREHOME
Export Excel Spreadsheets in C#
using IronXL;

// Create new Excel WorkBook document
WorkBook workBook = WorkBook.Create();

// Create a blank WorkSheet
WorkSheet workSheet = workBook.CreateWorkSheet("new_sheet");

// Add data and styles to the new worksheet
workSheet["A1"].Value = "Hello World";
workSheet["A2"].Style.BottomBorder.SetColor("#ff6600");

// Save the excel file as XLS, XLSX, XLSM, CSV, TSV, JSON, XML, HTML
workBook.SaveAs("sample.xls");
workBook.SaveAs("sample.xlsx");
workBook.SaveAs("sample.tsv");

// Save the excel file as CSV
workBook.SaveAsCsv("sample.csv");

// Save the excel file as JSON
workBook.SaveAsJson("sample.json");

// Save the excel file as XML
workBook.SaveAsXml("sample.xml");

// Export the excel file as HTML
workBook.ExportToHtml("sample.html");
Imports IronXL

' Create new Excel WorkBook document
Dim workBook As WorkBook = WorkBook.Create()

' Create a blank WorkSheet
Dim workSheet As WorkSheet = workBook.CreateWorkSheet("new_sheet")

' Add data and styles to the new worksheet
workSheet("A1").Value = "Hello World"
workSheet("A2").Style.BottomBorder.SetColor("#ff6600")

' Save the excel file as XLS, XLSX, XLSM, CSV, TSV, JSON, XML, HTML
workBook.SaveAs("sample.xls")
workBook.SaveAs("sample.xlsx")
workBook.SaveAs("sample.tsv")

' Save the excel file as CSV
workBook.SaveAsCsv("sample.csv")

' Save the excel file as JSON
workBook.SaveAsJson("sample.json")

' Save the excel file as XML
workBook.SaveAsXml("sample.xml")

' Export the excel file as HTML
workBook.ExportToHtml("sample.html")
NuGet Download
PM > Install-Package IronXL.Excel
Export Excel Spreadsheets in C#

Export Excel Spreadsheets in C#

IronXL makes it easy to save Excel files in different formats, making it a useful tool for sharing and integrating data. Developers can handle various reporting needs quickly and without hassle. It removes the need for complex conversions with support for multiple formats. It allows creating well-structured, styled files that work with many applications using minimal code. Exporting to formats like HTML or JSON also simplifies integrating Excel data into web apps and APIs. This streamlines the process, saves time, and boosts productivity for developers.

The WorkBook.Create method initializes a blank Excel workbook, serving as the foundation for data manipulation. A new worksheet titled "new_sheet" is added, and the value "Hello World" is set in cell A1. This showcases the ability to programmatically populate data into specific cells, which is essential for generating dynamic reports or templates.

Next, the background color of cell A1 is customized using the Style.BackgroundColor property, adding visual emphasis. This step highlights IronXL's powerful styling capabilities, allowing developers to enhance the readability of the presentation of their Excel files.

The SaveAs method is then used to save the workbook in .xlsx format, ensuring compatibility with Excel and other spreadsheet applications. Lastly, the ExportToHtml method converts the workbook into an HTML file, making the data accessible for web-based reports or dashboards. This streamlined process combines flexibility and efficiency, showcasing IronXL's versatility in handling Excel operations.

Click here to view the How-to Guide, including examples, sample code, and files
.

View on GitHub

Ready to Get Started?

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

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