Im working on IE9, and I have the following code to download a html table as an excel spreadsheet:
<a id="toExcel" onclick="window.open('data:application/vnd.ms-excel,' + document.getElementById('resultsTable').outerHTML.replace(/ /g, '%20'));e.preventDefault();" href="javascript:void(0);">Excel</a>
This works in other browsers such as chrome, but not in IE9. It just opens up a new tab with the code in the url bar.
How do I get this to work in IE9?
I have tried putting the onclick event in another element such as a button it didnt work.
With datatables the library it seems it is adding a lot of other stuff to the table, i only want this feature.
Footnote for bounty:
Must work on IE9.
Please do not suggest https://datatables.net. For internal reason we cannot use this suggestion.
- Am happy to vere from my what we have already tried (see code snippet earlier) as long as it works
- Must download as xlsx and must open properly on excel 2010.
- The project is using Sharepoint 2013 and a custom js/jquery webpart. We have dynamically generated a html table and need to be able to export to excel as above.
Thanks for any help
atag with a button (buttonorinput type="button"for correct semantics.