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
Open your VB.NET programming software.
Click "File" and then "Open Website." Click your VB.NET project file and click "Open" to load the code.
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.
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.
- 20 of the funniest online reviews ever
- 14 Biggest lies people tell in online dating sites
- Hilarious things Google thinks you're trying to search for