I am trying to create a JavaScript function that will export a HTML table to Excel. The code below works in Chrome, but in IE, I receive a popup saying "No apps are installed to open this type of link (data)." I need the export to happen on the client and using ActiveXObject is not an option. Any help on making this work in both IE and Chrome would be greatly appreciated.
var uri = "data:application/vnd.ms-excel;base64,"
var template = "<!DOCTYPE html><html xmlns:o='urn:schemas-microsoft-com:office:office' xmlns:x='urn:schemas-microsoft-com:office:excel' xmlns='http://www.w3.org/TR/REC-html40'> " +
"<head> " +
" <meta http-equiv=Content-Type content='text/html;charset=windows-1252'><meta name=Generator content='Microsoft Excel 11'> " +
" <meta name=ProgId content=Excel.Sheet> <meta name=Generator content='Microsoft Excel 11'> " +
"<style> " +
"<!--table @page{}-->" +
"</style>" +
"<!--[if gte mso 9]><xml> <x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet> <x:Name>Sheet1</x:Name> <x:WorksheetOptions><x:Panes> " +
"</x:Panes></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets><x:ExcelWorkbook></xml><![endif]--> " +
"</head>" +
"<body><form method='POST' action='PRJEdetail-ClientExportTest.asp' name='frmExcel'></form>" +
tableHTML +
"</body>" +
"</html>"
var base64 = function (s) { return window.btoa(unescape(encodeURIComponent(s))) }
window.location.href = uri + base64(template)