Skip to footer content
USING IRONXL

Export DataSet to Excel in C# Using IronXL | No Office Required

Exporting a DataSet or DataTable to Excel in C# gives you a reliable way to turn structured in-memory data into professional spreadsheet files -- without depending on Microsoft Office being installed on the target machine. Whether you pull records from a SQL database, build a DataSet programmatically, or work with an existing DataGrid, IronXL handles the entire pipeline through a clean, code-first API. This guide walks through every major scenario -- from a single-table export to multi-sheet workbooks to live database query results -- using top-level C# statements and .NET 10.

Install IronXL once, write a few lines of code, and your data is in an XLSX file without a single Office dependency. The sections below cover installation, core patterns, advanced formatting, and database integration in a way you can copy-paste directly into your own projects.

How Do You Install IronXL for Excel Export?

Before writing any export code, add IronXL to your project through the NuGet Package Manager. Open a terminal in your project root and run the .NET CLI command, or use the Package Manager Console in Visual Studio with the Install-Package command:

dotnet add package IronXL.Excel
# Or in Visual Studio Package Manager Console:
# Install-Package IronXL.Excel
dotnet add package IronXL.Excel
# Or in Visual Studio Package Manager Console:
# Install-Package IronXL.Excel
SHELL

After installation, add a top-level using statement to import the IronXL namespace:

using IronXL;
using System.Data;
using IronXL;
using System.Data;
$vbLabelText   $csharpLabel

IronXL targets .NET 8, .NET 9, and .NET 10 as well as older .NET Framework versions (4.6.2+). No Office installation is required on any machine -- server, desktop, or cloud. Once the package is installed, you can create, read, and write XLSX, XLS, and CSV files entirely in managed code.

For detailed installation options, see the IronXL installation guide and the NuGet package page for version history.

How Do You Export a Single DataTable to an Excel File?

The most common scenario is exporting one DataTable to a single worksheet. IronXL's WorkBook and WorkSheet classes map naturally onto the Excel object model. You create a workbook, add a worksheet, then iterate the DataTable's columns and rows.

The following example creates an in-memory Employees DataTable and writes it to EmployeeData.xlsx:

using IronXL;
using System.Data;

// Build an in-memory DataTable
DataTable dt = new DataTable("Employees");
dt.Columns.Add("ID", typeof(int));
dt.Columns.Add("Name", typeof(string));
dt.Columns.Add("Department", typeof(string));

dt.Rows.Add(1, "John Smith", "Engineering");
dt.Rows.Add(2, "Sarah Jones", "Marketing");
dt.Rows.Add(3, "Mike Wilson", "Sales");

// Create a workbook and a named worksheet
WorkBook workbook = WorkBook.Create(ExcelFileFormat.XLSX);
WorkSheet worksheet = workbook.CreateWorkSheet("Employees");

// Write column headers in row 0
for (int col = 0; col < dt.Columns.Count; col++)
{
    worksheet.SetCellValue(0, col, dt.Columns[col].ColumnName);
}

// Write data rows starting at row 1
for (int row = 0; row < dt.Rows.Count; row++)
{
    for (int col = 0; col < dt.Columns.Count; col++)
    {
        worksheet.SetCellValue(row + 1, col, dt.Rows[row][col].ToString());
    }
}

workbook.SaveAs("EmployeeData.xlsx");
using IronXL;
using System.Data;

// Build an in-memory DataTable
DataTable dt = new DataTable("Employees");
dt.Columns.Add("ID", typeof(int));
dt.Columns.Add("Name", typeof(string));
dt.Columns.Add("Department", typeof(string));

dt.Rows.Add(1, "John Smith", "Engineering");
dt.Rows.Add(2, "Sarah Jones", "Marketing");
dt.Rows.Add(3, "Mike Wilson", "Sales");

// Create a workbook and a named worksheet
WorkBook workbook = WorkBook.Create(ExcelFileFormat.XLSX);
WorkSheet worksheet = workbook.CreateWorkSheet("Employees");

// Write column headers in row 0
for (int col = 0; col < dt.Columns.Count; col++)
{
    worksheet.SetCellValue(0, col, dt.Columns[col].ColumnName);
}

// Write data rows starting at row 1
for (int row = 0; row < dt.Rows.Count; row++)
{
    for (int col = 0; col < dt.Columns.Count; col++)
    {
        worksheet.SetCellValue(row + 1, col, dt.Rows[row][col].ToString());
    }
}

workbook.SaveAs("EmployeeData.xlsx");
$vbLabelText   $csharpLabel

Output

How to Export Dataset to Excel VB .NET: A Complete Guide with IronXL: Image 1 - Output for exporting a simple DataTable to Excel in VB.NET

SetCellValue accepts int, double, string, and bool -- so you get native Excel cell types without extra casting. The loop pattern works for tables of any size because IronXL writes directly to memory and flushes to disk only when SaveAs is called, keeping the process efficient even for thousands of rows.

For a broader look at reading and writing techniques, the IronXL C# tutorial covers the full range of file operations alongside this export pattern.

How Do You Export a DataSet to Multiple Excel Worksheets?

When a DataSet contains several related tables -- such as Products and Orders -- you can map each DataTable to its own worksheet within one workbook. This lets recipients see all related data in a single file without needing to open multiple documents.

The loop below iterates ds.Tables and creates one sheet per table:

using IronXL;
using System.Data;

// Build a DataSet with two related tables
DataSet ds = new DataSet("CompanyData");

DataTable dtProducts = new DataTable("Products");
dtProducts.Columns.Add("ProductID", typeof(int));
dtProducts.Columns.Add("ProductName", typeof(string));
dtProducts.Columns.Add("Price", typeof(decimal));
dtProducts.Rows.Add(101, "Widget A", 29.99m);
dtProducts.Rows.Add(102, "Widget B", 49.99m);
ds.Tables.Add(dtProducts);

DataTable dtOrders = new DataTable("Orders");
dtOrders.Columns.Add("OrderID", typeof(int));
dtOrders.Columns.Add("Customer", typeof(string));
dtOrders.Columns.Add("Total", typeof(decimal));
dtOrders.Rows.Add(1001, "Acme Corp", 599.90m);
dtOrders.Rows.Add(1002, "Tech Inc", 299.95m);
ds.Tables.Add(dtOrders);

// Create one workbook and iterate each DataTable
WorkBook workbook = WorkBook.Create(ExcelFileFormat.XLSX);

foreach (DataTable table in ds.Tables)
{
    WorkSheet sheet = workbook.CreateWorkSheet(table.TableName);

    // Write headers
    for (int col = 0; col < table.Columns.Count; col++)
    {
        sheet.SetCellValue(0, col, table.Columns[col].ColumnName);
    }

    // Write rows
    for (int row = 0; row < table.Rows.Count; row++)
    {
        for (int col = 0; col < table.Columns.Count; col++)
        {
            sheet.SetCellValue(row + 1, col, table.Rows[row][col].ToString());
        }
    }
}

workbook.SaveAs("CompanyReport.xlsx");
using IronXL;
using System.Data;

// Build a DataSet with two related tables
DataSet ds = new DataSet("CompanyData");

DataTable dtProducts = new DataTable("Products");
dtProducts.Columns.Add("ProductID", typeof(int));
dtProducts.Columns.Add("ProductName", typeof(string));
dtProducts.Columns.Add("Price", typeof(decimal));
dtProducts.Rows.Add(101, "Widget A", 29.99m);
dtProducts.Rows.Add(102, "Widget B", 49.99m);
ds.Tables.Add(dtProducts);

DataTable dtOrders = new DataTable("Orders");
dtOrders.Columns.Add("OrderID", typeof(int));
dtOrders.Columns.Add("Customer", typeof(string));
dtOrders.Columns.Add("Total", typeof(decimal));
dtOrders.Rows.Add(1001, "Acme Corp", 599.90m);
dtOrders.Rows.Add(1002, "Tech Inc", 299.95m);
ds.Tables.Add(dtOrders);

// Create one workbook and iterate each DataTable
WorkBook workbook = WorkBook.Create(ExcelFileFormat.XLSX);

foreach (DataTable table in ds.Tables)
{
    WorkSheet sheet = workbook.CreateWorkSheet(table.TableName);

    // Write headers
    for (int col = 0; col < table.Columns.Count; col++)
    {
        sheet.SetCellValue(0, col, table.Columns[col].ColumnName);
    }

    // Write rows
    for (int row = 0; row < table.Rows.Count; row++)
    {
        for (int col = 0; col < table.Columns.Count; col++)
        {
            sheet.SetCellValue(row + 1, col, table.Rows[row][col].ToString());
        }
    }
}

workbook.SaveAs("CompanyReport.xlsx");
$vbLabelText   $csharpLabel

Output

How to Export Dataset to Excel VB .NET: A Complete Guide with IronXL: Image 2 - Generated Excel file with the exported DataSet's as separate worksheets

Each worksheet is named after the source DataTable, making navigation inside Excel straightforward. Because WorkBook.Create allocates the workbook in memory, you can keep adding worksheets in the loop without reopening the file -- IronXL builds the entire XLSX structure before writing to disk.

The IronXL WorkBook documentation lists every method available on the WorkBook object, including sheet reordering, password protection, and saving in formats other than XLSX.

How Do You Add Header Formatting to Excel Exports?

Plain data exports are functional, but adding bold headers and column widths makes the output immediately usable in a business context. IronXL exposes cell and range styling through the Style object attached to any WorkSheet range.

The snippet below applies bold font formatting to the header row and auto-sizes columns after writing data:

using IronXL;
using System.Data;

DataTable dt = new DataTable("Sales");
dt.Columns.Add("Region", typeof(string));
dt.Columns.Add("Q1", typeof(decimal));
dt.Columns.Add("Q2", typeof(decimal));
dt.Columns.Add("Q3", typeof(decimal));
dt.Columns.Add("Q4", typeof(decimal));

dt.Rows.Add("North", 120000m, 135000m, 142000m, 158000m);
dt.Rows.Add("South", 98000m, 104000m, 112000m, 121000m);
dt.Rows.Add("East",  87000m, 93000m,  99000m,  108000m);
dt.Rows.Add("West",  145000m, 152000m, 161000m, 174000m);

WorkBook workbook = WorkBook.Create(ExcelFileFormat.XLSX);
WorkSheet sheet = workbook.CreateWorkSheet("Sales");

// Write and style headers
for (int col = 0; col < dt.Columns.Count; col++)
{
    sheet.SetCellValue(0, col, dt.Columns[col].ColumnName);
    sheet["A1:E1"].Style.Font.Bold = true;
    sheet["A1:E1"].Style.Font.Height = 12;
}

// Write data rows
for (int row = 0; row < dt.Rows.Count; row++)
{
    for (int col = 0; col < dt.Columns.Count; col++)
    {
        sheet.SetCellValue(row + 1, col, dt.Rows[row][col]);
    }
}

workbook.SaveAs("SalesReport.xlsx");
using IronXL;
using System.Data;

DataTable dt = new DataTable("Sales");
dt.Columns.Add("Region", typeof(string));
dt.Columns.Add("Q1", typeof(decimal));
dt.Columns.Add("Q2", typeof(decimal));
dt.Columns.Add("Q3", typeof(decimal));
dt.Columns.Add("Q4", typeof(decimal));

dt.Rows.Add("North", 120000m, 135000m, 142000m, 158000m);
dt.Rows.Add("South", 98000m, 104000m, 112000m, 121000m);
dt.Rows.Add("East",  87000m, 93000m,  99000m,  108000m);
dt.Rows.Add("West",  145000m, 152000m, 161000m, 174000m);

WorkBook workbook = WorkBook.Create(ExcelFileFormat.XLSX);
WorkSheet sheet = workbook.CreateWorkSheet("Sales");

// Write and style headers
for (int col = 0; col < dt.Columns.Count; col++)
{
    sheet.SetCellValue(0, col, dt.Columns[col].ColumnName);
    sheet["A1:E1"].Style.Font.Bold = true;
    sheet["A1:E1"].Style.Font.Height = 12;
}

// Write data rows
for (int row = 0; row < dt.Rows.Count; row++)
{
    for (int col = 0; col < dt.Columns.Count; col++)
    {
        sheet.SetCellValue(row + 1, col, dt.Rows[row][col]);
    }
}

workbook.SaveAs("SalesReport.xlsx");
$vbLabelText   $csharpLabel

The Style.Font.Bold property applies to the entire header range in a single statement. IronXL also supports background colors (Style.BackgroundColor), border styles (Style.Border), number formats (Style.NumberFormat.FormatCode), and horizontal alignment (Style.HorizontalAlignment). For a full styling reference, see the IronXL cell formatting guide.

How Do You Export Database Query Results to Excel?

Connecting to a SQL database and exporting the results directly to Excel covers a major real-world use case -- scheduled reports, data snapshots, and administrative exports. The approach fills a DataSet using SqlDataAdapter, then maps the resulting DataTable to an IronXL worksheet.

using IronXL;
using System.Data;
using System.Data.SqlClient;

string connectionString = "Server=localhost;Database=SalesDB;Integrated Security=True;";
string query = "SELECT CustomerID, CompanyName, ContactName, Country FROM Customers";

// Fill DataSet from SQL query
DataSet ds = new DataSet();
using (SqlConnection connection = new SqlConnection(connectionString))
{
    SqlDataAdapter adapter = new SqlDataAdapter(query, connection);
    adapter.Fill(ds, "Customers");
}

DataTable dt = ds.Tables["Customers"]!;

// Create workbook and export
WorkBook workbook = WorkBook.Create(ExcelFileFormat.XLSX);
WorkSheet worksheet = workbook.CreateWorkSheet("CustomerData");

// Bold header row
for (int col = 0; col < dt.Columns.Count; col++)
{
    worksheet.SetCellValue(0, col, dt.Columns[col].ColumnName);
}
worksheet["A1:D1"].Style.Font.Bold = true;

// Write rows, handling DBNull values safely
for (int row = 0; row < dt.Rows.Count; row++)
{
    for (int col = 0; col < dt.Columns.Count; col++)
    {
        object cellValue = dt.Rows[row][col];
        worksheet.SetCellValue(row + 1, col,
            cellValue == DBNull.Value ? "" : cellValue.ToString()!);
    }
}

workbook.SaveAs("CustomerExport.xlsx");
Console.WriteLine("Export complete.");
using IronXL;
using System.Data;
using System.Data.SqlClient;

string connectionString = "Server=localhost;Database=SalesDB;Integrated Security=True;";
string query = "SELECT CustomerID, CompanyName, ContactName, Country FROM Customers";

// Fill DataSet from SQL query
DataSet ds = new DataSet();
using (SqlConnection connection = new SqlConnection(connectionString))
{
    SqlDataAdapter adapter = new SqlDataAdapter(query, connection);
    adapter.Fill(ds, "Customers");
}

DataTable dt = ds.Tables["Customers"]!;

// Create workbook and export
WorkBook workbook = WorkBook.Create(ExcelFileFormat.XLSX);
WorkSheet worksheet = workbook.CreateWorkSheet("CustomerData");

// Bold header row
for (int col = 0; col < dt.Columns.Count; col++)
{
    worksheet.SetCellValue(0, col, dt.Columns[col].ColumnName);
}
worksheet["A1:D1"].Style.Font.Bold = true;

// Write rows, handling DBNull values safely
for (int row = 0; row < dt.Rows.Count; row++)
{
    for (int col = 0; col < dt.Columns.Count; col++)
    {
        object cellValue = dt.Rows[row][col];
        worksheet.SetCellValue(row + 1, col,
            cellValue == DBNull.Value ? "" : cellValue.ToString()!);
    }
}

workbook.SaveAs("CustomerExport.xlsx");
Console.WriteLine("Export complete.");
$vbLabelText   $csharpLabel

Key Points for Database Exports

The null guard (cellValue == DBNull.Value ? "" : cellValue.ToString()) prevents exceptions when the database returns NULL values -- a common occurrence with optional columns. Bold formatting on the header row lets report recipients immediately distinguish headers from data.

For more patterns around reading data back from Excel into C# objects, the IronXL DataTable export tutorial shows how to reverse this workflow.

How Do You Compare IronXL to Other Excel Export Approaches?

Before choosing a library, it helps to understand how the main options stack up against each other in the areas that matter most for DataSet export scenarios.

Excel export library comparison for .NET DataSet scenarios
Approach Office Required XLSX Support Styling API Multi-Sheet Performance (large data)
IronXL No Yes Full Yes High
Microsoft Office Interop Yes Yes Full Yes Low
EPPlus No Yes Partial Yes High
ClosedXML No Yes Partial Yes Medium
CSV (manual) No No None No Very high

Microsoft Office Interop works only on Windows machines with Office installed, which rules it out for server deployments and cloud functions. IronXL, EPPlus, and ClosedXML all support server-side generation -- the key differentiator is the breadth of the styling API and licensing model. IronXL's licensing includes commercial use and covers all .NET target frameworks from a single package.

For third-party benchmarks and comparisons, the Microsoft documentation on Excel file formats and the EPPlus project page provide additional context for making the right choice for your project.

How Do You Handle Large DataSets Without Memory Issues?

When exporting DataTables with tens of thousands of rows, keeping memory usage predictable matters. The pattern below streams data from an IDataReader instead of loading the full result set into a DataTable first. This avoids the double-memory cost of holding both the reader buffer and the DataTable simultaneously.

using IronXL;
using System.Data;
using System.Data.SqlClient;

string connectionString = "Server=localhost;Database=InventoryDB;Integrated Security=True;";
string query = "SELECT ProductID, SKU, Description, StockLevel, UnitCost FROM Products";

WorkBook workbook = WorkBook.Create(ExcelFileFormat.XLSX);
WorkSheet sheet = workbook.CreateWorkSheet("Inventory");

using SqlConnection conn = new SqlConnection(connectionString);
conn.Open();

using SqlCommand cmd = new SqlCommand(query, conn);
using SqlDataReader reader = cmd.ExecuteReader();

// Write schema-derived headers
for (int col = 0; col < reader.FieldCount; col++)
{
    sheet.SetCellValue(0, col, reader.GetName(col));
}

// Stream rows directly into IronXL without buffering a DataTable
int excelRow = 1;
while (reader.Read())
{
    for (int col = 0; col < reader.FieldCount; col++)
    {
        sheet.SetCellValue(excelRow, col,
            reader.IsDBNull(col) ? "" : reader.GetValue(col).ToString()!);
    }
    excelRow++;
}

workbook.SaveAs("InventoryExport.xlsx");
Console.WriteLine($"Exported {excelRow - 1} rows.");
using IronXL;
using System.Data;
using System.Data.SqlClient;

string connectionString = "Server=localhost;Database=InventoryDB;Integrated Security=True;";
string query = "SELECT ProductID, SKU, Description, StockLevel, UnitCost FROM Products";

WorkBook workbook = WorkBook.Create(ExcelFileFormat.XLSX);
WorkSheet sheet = workbook.CreateWorkSheet("Inventory");

using SqlConnection conn = new SqlConnection(connectionString);
conn.Open();

using SqlCommand cmd = new SqlCommand(query, conn);
using SqlDataReader reader = cmd.ExecuteReader();

// Write schema-derived headers
for (int col = 0; col < reader.FieldCount; col++)
{
    sheet.SetCellValue(0, col, reader.GetName(col));
}

// Stream rows directly into IronXL without buffering a DataTable
int excelRow = 1;
while (reader.Read())
{
    for (int col = 0; col < reader.FieldCount; col++)
    {
        sheet.SetCellValue(excelRow, col,
            reader.IsDBNull(col) ? "" : reader.GetValue(col).ToString()!);
    }
    excelRow++;
}

workbook.SaveAs("InventoryExport.xlsx");
Console.WriteLine($"Exported {excelRow - 1} rows.");
$vbLabelText   $csharpLabel

This pattern is recommended when the result set may exceed 50,000 rows or when running inside a memory-constrained service. The IronXL performance documentation covers additional memory and throughput tuning options for high-volume exports.

Batch Saving to CSV for Very Large Exports

For exports exceeding 500,000 rows where memory is extremely tight, consider splitting output across multiple workbooks or exporting to CSV format instead:

using IronXL;

// IronXL can save any workbook as CSV
workbook.SaveAs("LargeExport.csv");
using IronXL;

// IronXL can save any workbook as CSV
workbook.SaveAs("LargeExport.csv");
$vbLabelText   $csharpLabel

CSV loses formatting and multi-sheet support but remains valid for downstream ETL processes that consume raw delimited data.

How Do You Save Excel Files to Different Formats and Locations?

IronXL supports saving to file path, MemoryStream, and byte[] -- which matters for ASP.NET applications returning Excel as a download response.

using IronXL;
using System.IO;

WorkBook workbook = WorkBook.Create(ExcelFileFormat.XLSX);
WorkSheet sheet = workbook.CreateWorkSheet("Report");
sheet.SetCellValue(0, 0, "Generated Report");

// Save to file path
workbook.SaveAs("Report.xlsx");

// Save as XLS (legacy format)
workbook.SaveAs("Report.xls");

// Save to MemoryStream for HTTP response
using MemoryStream ms = new MemoryStream();
workbook.SaveAs(ms);
byte[] fileBytes = ms.ToArray();
// fileBytes can be returned from an ASP.NET controller action
using IronXL;
using System.IO;

WorkBook workbook = WorkBook.Create(ExcelFileFormat.XLSX);
WorkSheet sheet = workbook.CreateWorkSheet("Report");
sheet.SetCellValue(0, 0, "Generated Report");

// Save to file path
workbook.SaveAs("Report.xlsx");

// Save as XLS (legacy format)
workbook.SaveAs("Report.xls");

// Save to MemoryStream for HTTP response
using MemoryStream ms = new MemoryStream();
workbook.SaveAs(ms);
byte[] fileBytes = ms.ToArray();
// fileBytes can be returned from an ASP.NET controller action
$vbLabelText   $csharpLabel

For ASP.NET Core, return File(fileBytes, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "Report.xlsx") from your controller action to trigger a browser download. The IronXL ASP.NET Excel guide shows the complete controller integration pattern.

For alternative .NET Excel libraries, the Open XML SDK is the open-source foundation that many libraries build on top of.

Supported Output Formats

IronXL saves to the following formats without any additional dependencies:

  • XLSX -- OpenXML format, compatible with Excel 2007 and later
  • XLS -- Legacy binary format, compatible with Excel 97-2003
  • CSV -- Comma-separated values, universally supported
  • TSV -- Tab-separated values
  • JSON -- Structured data export

Switch formats by changing the file extension in the SaveAs path or by using the overloaded method that accepts an ExcelFileFormat enum value.

How Do You Verify the Exported Excel File Is Correct?

After export, you can read the file back with IronXL to verify row counts, spot-check values, or run automated assertions in a test project:

using IronXL;

WorkBook loaded = WorkBook.Load("EmployeeData.xlsx");
WorkSheet sheet = loaded.WorkSheets[0];

// Verify row count (header row + data rows)
int totalRows = sheet.Rows.Count();
Console.WriteLine($"Rows in file: {totalRows}");

// Spot-check specific cell values
string header = sheet["A1"].StringValue;
string firstEmployee = sheet["A2"].StringValue;

Console.WriteLine($"Header: {header}, First row: {firstEmployee}");
using IronXL;

WorkBook loaded = WorkBook.Load("EmployeeData.xlsx");
WorkSheet sheet = loaded.WorkSheets[0];

// Verify row count (header row + data rows)
int totalRows = sheet.Rows.Count();
Console.WriteLine($"Rows in file: {totalRows}");

// Spot-check specific cell values
string header = sheet["A1"].StringValue;
string firstEmployee = sheet["A2"].StringValue;

Console.WriteLine($"Header: {header}, First row: {firstEmployee}");
$vbLabelText   $csharpLabel

This verification pattern is particularly useful in integration test suites where export correctness must be confirmed before sending files to external systems. The IronXL read tutorial shows the full range of read operations available after loading a file.

For further reading on DataSet and DataTable patterns in .NET, the Microsoft DataSet documentation covers the ADO.NET object model in depth.

What Are Your Next Steps?

You now have working patterns for every major DataSet-to-Excel export scenario in C# -- from a single DataTable to multi-sheet workbooks, database-driven exports, formatted headers, and large-data streaming. Here is how to take the next step based on your goal:

  • Try IronXL free -- Start with a free trial license and run the examples above against your own data before committing to production.
  • Read the full API reference -- The IronXL object reference covers every method on WorkBook, WorkSheet, and cell ranges.
  • Explore related export tutorials -- The C# DataTable to Excel guide covers the reverse workflow -- reading Excel back into DataTable objects.
  • Review formatting options -- The IronXL cell formatting documentation shows number formats, borders, background colors, and alignment options.
  • Check licensing -- For production deployments, see the IronXL licensing page to choose between Developer, Organization, and Royalty-Free options.
  • Compare with other Iron Software tools -- If your project also needs PDF generation or OCR, the Iron Software product suite lets you bundle multiple libraries at a reduced price.

Building on the patterns covered here, you can layer in scheduled task automation, ASP.NET Core download endpoints, and multi-format output pipelines entirely in managed C# -- no Office, no COM, no runtime dependencies beyond the NuGet package.

Frequently Asked Questions

How can I export a DataSet to Excel in C#?

You can export a DataSet to Excel in C# using the IronXL library, which provides a code-first API to create, edit, and manipulate Excel files without needing Microsoft Office.

Do I need Microsoft Office installed to use IronXL?

No, IronXL does not require Microsoft Office to be installed on the machine to export or manipulate Excel files.

What types of data can I export using IronXL?

IronXL allows you to export structured data such as DataTables and DataSets to Excel files, as well as data from SqlDataReader and other ADO.NET sources.

Can IronXL handle Excel file creation and editing?

Yes, IronXL provides functionality to create, edit, and manipulate Excel files programmatically in C#.

Is IronXL suitable for server-side and cloud applications?

Yes, IronXL is ideal for server-side applications and cloud functions that need to generate Excel files without any Office installation.

What are the benefits of using IronXL for exporting DataSets?

IronXL handles Excel file creation and manipulation without external dependencies like Microsoft Office, supports XLSX, XLS, and CSV formats, and works across all .NET target frameworks.

Can IronXL be used in ASP.NET Core to return an Excel download?

Yes, IronXL can save workbooks to a MemoryStream, and the resulting byte array can be returned from an ASP.NET Core controller action as a file download.

Does IronXL support large DataSets?

Yes, IronXL can stream data directly from SqlDataReader without buffering a full DataTable, keeping memory usage predictable for large result sets.

What Excel formats does IronXL support for saving?

IronXL supports saving to XLSX, XLS, CSV, TSV, and JSON formats without any additional dependencies.

Can I apply formatting like bold headers when exporting to Excel?

Yes, IronXL provides a Style API on cell ranges for bold font, background colors, borders, number formats, and alignment.

Jordi Bardia
Software Engineer
Jordi is most proficient in Python, C# and C++, when he isn’t leveraging his skills at Iron Software; he’s game programming. Sharing responsibilities for product testing, product development and research, Jordi adds immense value to continual product improvement. The varied experience keeps him challenged and engaged, and he ...
Read More