Vinoth Kumar
Vinoth Kumar

Reputation: 11

How to open excel file using JavaScript code without using ActiveX control?

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");

Upvotes: 0

Views: 14274

Answers (3)

Rupesh Kumar Tiwari
Rupesh Kumar Tiwari

Reputation: 967

I 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>

Upvotes: 2

Alain Couthures
Alain Couthures

Reputation: 1523

It's possible to open .xlsx files with Javascript because they are ZIP packages. This has been experimented with XForms: http://www.w3.org/community/xformsusers/2012/12/19/editing-zip-with-xforms/

Upvotes: 0

tkone
tkone

Reputation: 22758

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.

Upvotes: 1

Related Questions