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?
Open "My Computer" and select "Folder Options" under the "View" menu. Select the "File Types" tab and find the icon that says Microsoft Excel Worksheet in the Registered File types. Check the box in the new window that says "Confirm open after download".
Select Open in Desktop App at the top of your workbook. If you don't see it, there should be a search bar along the top of your workbook. In that search bar, type open, and then select Open in Desktop App.
Only the users machine can "force" it into Excel. That said, 99% of the time if you send the correct mime-type and a user has Excel, then it will open in Excel assuming they approve.
And only the server can send the correct mime-type. The document type you pass to a JavaScript window.open call will have no effect on this. In fact, calling window.open will at best just open a superfluous window.
It's best to just link to the document with <a href="foo.xls">
. And provided your server is sending a mime-type of application/x-excel
or application/x-msexcel
this will almost always nudge the browser into opening a new window with the Excel document.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With