Hi,
I have quite a complex ASP page that builds an HTML table. I want to save this output in a format readable by Excel on the local machine automatically WITHOUT having to open it in Excel first.
At the moment my header is :
Response.ContentType="application/xls"
Response.AddHeader "Content-Disposition", " filename= report.xls"
Which opens in excel just fine but is there an easy way to save the file without having to Save it from Excel?
Thanks in advance!
With your current Content-Disposition, windows clients will check the registry to see if the user prefers to auto-open files of that type after it's downloaded.
You can change the option by opening a Windows Explorer window and going to Tools>Folder Options>File Types, find XLS and click advanced and check "Confirm open after download". This will make it prompt to open or save again until you click a box to always open on the save dialog.
Now if you want it to force a open/save dialog for every user regardless of that setting, you can force it to prompt by adding "attachment;" before the filename= like so:
Response.AddHeader "Content-Disposition", "attachment;filename=report.xls"