Print Page | Close Window

Need to export Gridview results to Excel

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=29741
Printed Date: 05 June 2023 at 8:35am
Software Version: Web Wiz Forums 12.06 - https://www.webwizforums.com


Topic: Need to export Gridview results to Excel
Posted By: luwandui
Subject: Need to export Gridview results to Excel
Date Posted: 07 September 2011 at 7:42am
I have a very simple asp page that shows the results of an SQL query in gridview. I would like to place button on the page that will allow the user to extract the data to excel. I need to do this in either asp or vb. Any suggestions would be appreciated.

Thanks


-------------
http://www.rsdisnow.com/rosetta-stone-spanish-c-5.html" rel="nofollow - Rosetta Stone Spanish



Replies:
Posted By: s93ncer
Date Posted: 17 April 2012 at 8:23am
You could add a button to the page to postback to itself with a parameter

You could then check to that parameter and add something like

if request("parameter") = "excel" then response.ContentType="application/vnd.ms-excel"
Then just write out your gridview - as long as the columns line up correctly it should work

I seem to remember if the user has excel installed then it will just open, otherwise it will ask the user to save the file

...Spence



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.06 - https://www.webwizforums.com
Copyright ©2001-2023 Web Wiz Ltd. - https://www.webwiz.net