Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automatic Download 2

Status
Not open for further replies.

bigfoot

Programmer
May 4, 1999
1,779
US
Some background:
We have a website where the customers go to see their orders.
They want to be able to download data (the orders) from my SQL database in Excel, or Access, or Text format.
There should be no problem exporting from SQL Server. But that's not why I'm here.

ASP Question:
I have to create a file somewhere, and it needs to be unique to each user, Yes?. How would I create an auto download where the file gets pushed out to the user?

You know, like when yo go download somewhere and the screen comes up and you didn't click on any link, but your download screen comes up asking you to save or open.

This would happen when they clicked on a button that said "Download your orders in Excel Format".

Am I making any sense?

 
in the page_load sub add these 2 lines

Response.AddHeader("content-disposition", "attachment;filename=FileName.xls;")
Response.ContentType = ("application/vnd.ms-excel")

then execute your query and on the front end, format the results into a table (possibly using a datagrid or a repeater).

hth
SonD
 
Thank you. I'll be able to look up the rest. I'll need one for Access, XML, and comma delimited.
 
Sond,

I have used your code

Response.AddHeader("content-disposition", "attachment;filename=FileName.xls;")
Response.ContentType = ("application/vnd.ms-excel")

in a command button when I try to export the datagrid. If I have allow paging on it work and exports the 10 lines on the first page. If I take allow paging off when I click on the command button it will open excell but say unable to read file any idea's
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top