EasyXLS

How to export DataTable to Excel file in C# and VB.NET

Concept

EasyXLS™ library allows you to export a DataTable to an Excel file. The data in cells can be formatted using predefined formats or user-defined formats.

EasyXLS can be successfully used inclusively to export large Excel files having big volume of data with fast exporting time.

The source code samples can be integrated in:
- ASP.NET web pages
- Windows applications
- Windows Forms (WinForms)
- Console applications
- Windows service applications
- ASP.NET MVC web applications

EasyXLS permits you to export Excel files without Excel installed, without Interop or any other additional software installed.

Concept in action

Step 1: Download and install EasyXLS Excel Library for .NET

To download the trial version of EasyXLS Excel Library, press the below button:

Download EasyXLS™ Excel Library for .NET

If you already own a license key, you may login and download EasyXLS from your account.

Step 2: Create a C# or VB.NET project

If don't have a project, create one as ASP.NET web application, windows forms app, console application, class library or service.

Step 3: Include EasyXLS library into project

EasyXLS.dll must be added as reference to your project. EasyXLS.dll can be found after installing EasyXLS, in "Dot NET version" folder.

Add EasyXLS reference

Step 4: Run C# or VB.NET code that exports DataTable to Excel

The below example shows how to export DataTable to Excel in C# and VB.NET.

Source code sample

C#.NET
VB.NET

Export DataTable to Excel file with multiple sheets

For an Excel file having multiple sheets, the DataTable can be inserted using ExcelWorksheet.easy_insertDataSet method and the Excel file must be exported using ExcelDocument.easy_WriteXLSXFile method.

Formatting cells

EasyXLS™ enables you to format cells, rows and columns in order to set the fonts and colors.

Export DataTable to XLSX, XLSB, XLSM and XLS files

This code sample shows how to export a DataTable to XLSX file. Similarly, you can export a DataTable to XLS file using ExcelDocument.easy_WriteXLSFile_FromDataSet method or export DataTable to XLSB file using ExcelDocument.easy_WriteXLSBFile_FromDataSet method.

Getting started with EasyXLS Excel library

To download the trial version of EasyXLS Excel Library, press the below button:

Download EasyXLS™ Excel Library for ASP.NET

If you already own a license key, you may login and download EasyXLS from your account.

After installation, you will need to create a C# or VB.NET project and add a reference to EasyXLS.dll.



Available for: Professional, Excel Writer, Express Excel Writer
Go to top

EasyXLS Excel libraries:

.NET
.NET Excel Library
full .NET version to import, export or convert Excel files
.NET Excel Writer
.NET version to create and export Excel files
.NET Express Excel Writer
limited .NET version to create and export Excel files in predefined formats
Download EasyXLS™ Excel Library for .NET

File formats:

MS Excel 97 - 2003
MS Excel 2007 - 2010
MS Excel 2013
MS Excel 2016
MS Excel 2019
XLSX XLSM XLSB XLS
XML HTML CSV TXT