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!

Export to excel

Status
Not open for further replies.

AppzDev

MIS
Oct 9, 2002
57
US
I have a dataset/datagrid that i want to export to excel. I have successfully done this using the included code, however, when i click the button to "Export to Excel" it brings up a "save as" dialog box in which i have to choose where to save it. What i'd like to do is automatically save this file to a designated location without having the user intervene. So, when they click the button it simply saves the datagrid (or dataset) to a directory (whether local or network) as an excel spreadsheet. Any help is appreciated.

Here is the code that works but as stated, brings up a dialog box to "save as"

Response.Clear()
Response.AddHeader("content-disposition", "attachment;filename=FileName.xls")
Response.Charset = ""
Response.Cache.SetCacheability(HttpCacheability.NoCache)
Response.ContentType = "application/vnd.xls"
Dim stringWrite as new System.IO.StringWriter()
Dim htmlWrite as new HtmlTextWriter(stringWrite)
myDataGrid.RenderControl(htmlWrite)
Response.Write(stringWrite.ToString())
Response.End()


Thanks.
 
You don't have control of what to do with the file once iot has been streamed to the client (imagine if you did and you could just save a file to anywhere you liked without the users permission! That would be a very large security hole!).


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Thats a major No-No in Web Applications for security reasons.

Would you access web pages which could acess, update or save files to your machine without checking with you?

Rhys
Gene Roddenberry was a legendary pioneer of thought-provoking, futuristic science fiction. George Lucas created Jar Jar Binks
 
I should have mentioned that this is for an in-house process that is not accessed by anyone outside of the network and will be used by only one person. Security aside, can it be done?
 
Nope. It's still server vs client.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Ah well, was worth a try. It's not going to be that difficult to show one person where to save a file, but i was hoping to make it as easy as possible.

Thanks for the input.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top