How to Export GridView Data to Excel on VB.NET

Written by jim campbell
  • Share
  • Tweet
  • Share
  • Email

A GridView control in VB.NET displays rows of data you query from a database server. You may also want to give the user the option to export the data to an Excel file. You use the GridView "Export" function to send the data to an .XLSX file saved on the user's computer or on the server. This function does not apply any formatting to the file, but you do get an Excel file with column headers and the corresponding data.

Skill level:

Other People Are Reading


  1. 1

    Open your VB.NET programming software.

  2. 2

    Click "File" and then "Open Website." Click your VB.NET project file and click "Open" to load the code.

  3. 3

    Double-click the code file in "Solution Explorer" to open the code editor. Double-click the button you want to use to export the GridView.

  4. 4

    Type the following code in the editor:

    GridViewExportUtil.Export("myfile.xls", grid 1);

    Replace "myfile.xls" with the name of your own file and replace "grid1" with the name of the GridView you want to export.

Tips and warnings

  • If you choose to save the file on the user's computer, the user is first prompted to save the file to give you permissions to store the file on the computer.

Don't Miss

  • All types
  • Articles
  • Slideshows
  • Videos
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the site, you consent to the use of cookies. For more information, please see our Cookie policy.