My subject line says most of what I\'m asking. I\'ve got a web site that outputs reports in various formats (HTML, CSV, TSV, Excel, etc). Whenever possible, I\'d like thes
You may have resolved this already, but if not I may have an answer (for future people with the same issue, this also drove me nuts!)
This behavior can be overwritten on the client, using the following:
The mechanism used to implement the preview / download functionality is via the use of the “content-disposition” header, usually using MimeType “application/”. This basically tells the local client to open the application using the specified application, however the above settings for the application can overwrite the requested delivery format.
Check that your server is serving the correct MIME type for the CSV and Excel files. In order to treat them properly, even a browser which recognises their type and has a file type handler/plugin for them will need the correct MIME type.
You will probably want the MIME type of both to be application/vnd.ms-excel
If you are serving these with your web server as regular files, then the relevant setting in Apache is the mime.types file.
application/vnd.ms-excel xls csv
If you are serving these files from your application, then you'll need to add the Content-Type: application/vnd.ms-excel header yourself.
Note that for some users, you may never get it to work as expected - for example anyone who doesn't have Microsoft Office installed, or even anyone using an alternative browser or who has messed with their file type associations.
(for your interest, this article describes the procedure - it happens to be able Plone/Zope but the idea is the same).