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.
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.