I'm making a script that is supposed to export a html table to an xls file. I'm using Chrome when testing and it's no requirement that it's working on IE.
The problem is that the file that gets downloaded when clicking the export button is a text file.
Snippet from text file:
<table><tr><th>Mail</th><th>Telefonnummer</th></tr><td>asdasd@asdasd.com </td><td></td></tr><td>test@company.com </td><td></td></tr><td>asd@adsasd.com
My code:
var export_data = '';
var objTable = document.getElementById('table');
export_data += '<table><tr>';
for(var i = 0; i < objTable.rows.length; i++){
export_data += objTable.rows[i].innerHTML + '</tr>';
}
export_data += '</table>';
sa = window.open('data:application/vnd.ms-excel,' + encodeURIComponent(export_data));
return sa;