How to open an Excel document using JavaScript code and without using an ActiveX control object like:
var myApp = new ActiveXObject("Excel.Application");
myApp.workbooks.open("test.xls");
How to open an Excel document using JavaScript code and without using an ActiveX control object like:
var myApp = new ActiveXObject("Excel.Application");
myApp.workbooks.open("test.xls");
Share
Improve this question
edited Dec 10, 2017 at 13:15
Cœur
38.8k25 gold badges205 silver badges277 bronze badges
asked Jan 4, 2012 at 15:42
Vinoth KumarVinoth Kumar
111 gold badge1 silver badge4 bronze badges
3 Answers
Reset to default 2I tried below option and it worked. Just prepend ms-excel:ofe|u
before the url of xlsx
file. It works in IE, Chrome
other browsers I have not tested. This is what Microsoft One Drive online portal uses for opening encrypted xlxs files on client machines.
<a onclick="window.open('ms-excel:ofe|u|http://localhost/iis-server/test.xlsx')"> Open Excel </a>
I don't think this is possible. JavaScript, when running in the browser, should be sandboxed to the browser's process and not able to launch other applications.
You might try relying on the browser knowing that .XLS files are opened by Excel and have it change window.location
to a URL that is an Excel file. But the user would have had to set up their browser and tell it that Excel files are opened by Excel and, yes, when I go to an Excel file, please open it in Excel rather than saving it to disk.
It's possible to open .xlsx files with Javascript because they are ZIP packages. This has been experimented with XForms: http://www.w3/munity/xformsusers/2012/12/19/editing-zip-with-xforms/