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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Export RS as excel

Status
Not open for further replies.

emissions

Technical User
Mar 17, 2002
68
0
0
GB
i have generated a table recordset in web page using asp code. i need to take this step further, and when the user click's a button to export to excel the report(recordset) in the web page should automatically export to excel file and it should save itself with filename having currentdate as like "141105.xls" within a specified directory.

One thing it shud not prompt the user to give the file name to save in excel.

i have used
Response.ContentType = "application/vnd.ms-excel"
but system prompting user to enter the file name to save the file in excel.

thanks advanced


 
Try this:

Response.ContentType = "application/vnd.ms-excel"
response.AddHeader "Content-Disposition", "attachment; filename="&[red]BuildTheDateStringHere[/red]&".xls"

let me know if you have any problems in building the date string...you can do it using simple date functions...

-DNG
 
DNG,

From what I understand, that will simply pop up the save dialog but with the filename already in the save field. Please correct me if I'm worng.

Will
 
Yes Will...you are correct...it just opens up a dialog box with the date as the name of the file...havent looked at his requirement to automatically export...

but that shudnt be hard...and i think the link you suggested already as the answer for it...

-DNG
 
correct, that only prompts the user, but with the correct filename 141105.xls
 
I've read the link, finally... but confused, doesn't explain any thing about auto export..
 
Okay followed both instructions on this page, and on the link page... I'm about a third there, I have a link to the page which creates itself into a .xls file... cool...

But not really what I'm looking for. I have a page that already has create the recordset/query, I want the user to click a button and have the results 'only' save in a excel file, without the page formatting, just the table data...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top