EasyXLS

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

Concept

EasyXLS™ library allows you to export a GridView to an Excel file. The exported data in cells can be formatted.

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

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

Concept in action

The below example shows how to export GridView to Excel in C# and VB.NET from ASP.NET web application.

Source code sample

The source code that export the GridView is split in 3 sections. The first section contains the ASP.NET web page. The second one is the class behind the HTML web page. The third one is the method that exports data from GridView to Excel file.

ASP.NET web page source code
The web page contains the GridView and a button that exports GridView data to Excel file.

C#.NET
VB.NET


ASP.NET source code behind
The class behind ASP.NET page contains the method that bind the GridView and the method that exports the GridView to Excel file.
The GridView is populated with some custom data, but it also can be data from a SQL database.

C#.NET
VB.NET


Export GridView to Excel button source code
The method export the GridView data to Excel file and also the formatting for header and cells is kept.

C#.NET
VB.NET

Formatting cells

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

Export GridView to XLSX, XLSB, XLSM and XLS files

This code sample shows how to export a GridView to XLS file. In a similar way, you can export a GridView to XLSX file using ExcelDocument.easy_WriteXLSXFile_FromDataSet method or export GridView to XLSB file using ExcelDocument.easy_WriteXLSBFile_FromDataSet method.

Export GridView to Excel file with multiple sheets

For an Excel file having multiple sheets, the DataSet can be inserted using ExcelWorksheet.easy_insertDataSet method and the Excel file must be exported using ExcelDocument.easy_WriteXLSFile 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
ASP.NET Excel Library
full .NET version to import, export or convert Excel files
ASP.NET Excel Writer
.NET version to create and export Excel files
ASP.NET Express Excel Writer
limited .NET version to create and export Excel files in predefined formats
Download EasyXLS™ Excel Library for ASP.NET

File formats:

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