Here’s a little code snippet to export an HTML table to MS Excel through utilising ActiveXObject(“Excel.Application”) from Internet Explorer.
The JavaScript (in this case utilising Microsoft’s JScript) runs over the table displayed pulling out the relevant data and exporting into the instantiated copy of Excel. This is a working example based loosely on Microsoft’s http://support.microsoft.com/kb/234774 Knowledgebase Article “How to automate Excel from an HTML Web page by using JScript”.
Worth noting is that the garbage collection between the JScript and MS Excel doesn’t work too well and more often than not one can be left with the instantiated copy of MS Excel still in memory (see it in the Task Manager). One must manually remove these instances.
Perhaps dynamically inputting a module to clean up from within MS Excel on the workbook deactivating might clear this up – not tried this though!?




Recent Comments