-2

I have tried this code but it does not work in the chrome

var myApp = new ActiveXObject("Excel.Application");
myApp.workbooks.open("test.xls");
user3370649
  • 57
  • 1
  • 8
  • 1
    That snippet shouldn't work in any browser, not even in IE, when called by an arbitrary web page. – Teemu Jan 30 '15 at 18:55
  • 1
    possible duplicate of [ActiveXObject in Firefox or Chrome (not IE!)](http://stackoverflow.com/questions/7022568/activexobject-in-firefox-or-chrome-not-ie) – Lynn Crumbling Jan 30 '15 at 18:57
  • @LynnCrumbling The actual question here is "__How to open excel file using Javascript in chrome__". The ActiveX is just an example what OP has tried, hence not a dup of a post about ActiveXs in some browsers. – Teemu Jan 30 '15 at 19:03
  • In Chrome you can open a new window: `window.open('test.xls', 'excel');`. This won't open an actual window or Excel app, but downloads the file and shows you a button, which you can click and open an .xls file, _if Excel is installed_. You might also need to play with security settings [to access local files](http://stackoverflow.com/a/5664399/1169519). – Teemu Jan 30 '15 at 19:26

2 Answers2

0

ActiveXObjects are only supported by IE. They don't work in Chrome.

0

ActiveXObject is available only on IE browser. So every other useragent will throw an error

On modern browser you could use instead File API or File writer API (currently implemented only on Chrome)

Lessandro
  • 23
  • 6