without - window.open excel file javascript




How do you get a spreadsheet to open Excel instead of a browser window? (2)

If you call javascript window.open and pass a url to a .xls file it open on some machines in the browser window. How can you force it into Excel?


AFAIK you can't do this with JavaScript alone. If you have some sort of scripting language on the server's side you can alter the header to force a download.

Here's a simple tutorial in PHP, but you can easily find one in your favorite language.


If it's just a static file, and you're using Apache on Linux, check for a file called /etc/mime.types, and ensure that it has the following line in there to associate the .xls file extension with the correct MIME type:

application/vnd.ms-excel    xls

I'm guessing the location of that file might vary across systems, but it's in /etc/mime.types on my server which is running RHEL4.







url