Search code examples
javascriptexport-to-excelhtml-table

Why is Export to Excel and CSV javascript function not working?


I am trying to export an html table to excel using JavaScript. However I keep getting the following error.

ActiveXObject is not defined
[Break On This Error] var ExcelApp = new ActiveXObject("Excel.Application"); 

Here is a link to my code in JSFiddle:

http://jsfiddle.net/BxV9E/


Solution

  • I presume you are receiving the following JavaScript error (or similar - I captured in IE9)?

    SCRIPT429: Automation server can't create object

    I believe you'll find that the script works fine when run locally, but not from a remote location. This is a restriction in your IE settings. Not sure what you need to change, but check for OLE Automation or some other scripting permission setting.