Automatically Saving Excel file
Hi,
Is there any mechanism for saving an excel file automatically. The Code which i used for Generting Excel file is
[CODE]
HttpContext.Current.Response.Clear()
HttpContext.Current.Response.ClearContent()
HttpContext.Current.Response.ClearHeaders()
HttpContext.Current.Response.Charset = ""
HttpContext.Current.Response.Buffer = True
HttpContext.Current.Response.ContentType = "application/vnd.ms-excel"
HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + lstrExcelFileName)
HttpContext.Current.Response.Write(_strBuild)
HttpContext.Current.Response.Flush()
[CODE]
_strBuild contains the information to be displayed in the excel
The above code when i use it prompts user for open/save an excel file. Is the any mechanism for saving an excel file automatically
Thanks in Advance
Re: Automatically Saving Excel file
Web browsers do not have the ability to display the contents of the excel file directly in the browser, which means you would need to either offer it as a download like you currently are or display it in a GridView or some other table yourself on the web page.
As for offering it for download, there's no way to force the file to download to their computer, but in Firefox you can have the end user(s) configure it to automatically accept excel file downloads to a specific folder, but then they might not be aware of when one gets downloaded, if they dont see the FF download window then they'd have to go look in that folder to see if a new one has been downloaded/updated.
Re: Automatically Saving Excel file
Personally i would be really pissed if something started to save files on it's own.
Re: Automatically Saving Excel file
Quote:
Originally Posted by
sapator
Personally i would be really pissed if something started to save files on it's own.
Agreed! Doing this, without the permission of the logged in user would be a security risk, and as such, is not allowed. Unless explicitly handled by the browser in the case of Firefox, however, you can't rely on this being available.
The best option would be to present the user with the Open/Save dialog, and let them decide what they want to do.
Gary