EasyXLS

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

EasyXLS™ library allows you to export data 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.

Source code sample

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 to Excel file

The below example is a common code about how to export to Excel file in C# and VB.NET. After that, best techniques about exporting data from various standard data structures like DataTable, GridView, DataGridView, DataSet, DataGrid and List are shown.

C#.NET
VB.NET

1. Export DataTable to Excel in C# and VB.NET

EasyXLS allows exporting DataTable to Excel with formatting. The DataTable can be the result of a SQL database query, the data source of a GridView, DataGridView, DataGrid or any other data structure.

2. Export GridView to Excel in C# and VB.NET from ASP.NET

EasyXLS allows exporting GridView to Excel with formatting from ASP.NET web applications. The exported Excel file can have multiple sheets.

3. Export DataGridView to Excel in C# and VB.NET

EasyXLS allows exporting DataGridView to Excel with formatting from windows applications and windows forms. The exported data can be with headers or without. The exported Excel file can have multiple sheets.

4. Export DataSet to Excel in C# and VB.NET

EasyXLS allows exporting DataSet to Excel with formatting from windows applications, ASP.NET pages or console applications. The exported Excel file can have multiple sheets.

5. Export List to Excel in C# and VB.NET

EasyXLS allows exporting a list of data to Excel with formatting. It can be a ListView, ArrayList or any other list that contains values that must be exported to Excel.

6. Export DataGrid to Excel in C# and VB.NET

EasyXLS allows exporting DataGrid to Excel with formatting from windows applications and windows forms. The exported data can be with headers or without. The exported Excel file can have multiple sheets.

7. Export data to XLSX file in C# and VB.NET

EasyXLS allows exporting data to XLSX file with formatting from windows applications or ASP.NET pages. Similarly, as shown in the above code sample, you can export data to XLSX file using ExcelDocument.easy_WriteXLSXFile method.

8. Export data to XLSB file in C# and VB.NET

EasyXLS allows exporting data to XLSB file with formatting from windows applications or ASP.NET pages. Similarly, as shown in the above code sample, you can export data to XLSB file using ExcelDocument.easy_WriteXLSBFile method.

9. Export data to XLSM file in C# and VB.NET

EasyXLS allows exporting data to XLSM file with formatting from windows applications or ASP.NET pages. The first step is to create an XLSM or XLTM file in Microsoft Excel that has the macro code defined. The Excel file can be empty or already filled with sheets and some data like report header. This will be the Excel template file that will be loaded using ExcelDocument.easy_LoadXLSXFile method. Now, the data can be added to the Excel file similarly, as shown in the above code sample. When the Excel file is completely filled, you can export data to XLSM file using ExcelDocument.easy_WriteXLSXFile method, but the exported Excel file must have XLSM file extension.

10. Export data to XLS file in C# and VB.NET

EasyXLS allows exporting data to XLS file with formatting from windows applications or ASP.NET pages. Similarly, as shown in the above code sample, you can export data to XLS file using ExcelDocument.easy_WriteXLSFile method.

11. Export password protected Excel file in C# and VB.NET

EasyXLS allows exporting encrypted Excel file. The Excel file can be password protected.

Formatting cells

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

Getting started with EasyXLS Excel library

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.

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
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 - 2019
MS Excel 2021
Office 365
XLSXXLSMXLSBXLS
XMLHTMLCSVTXT