I have a table in HTML on my webpage, and when using JQuery to export it to Excel, it will not work if I have any id or class tags in the table header.
the JQuery i am using is
//wont work unless the table has no class or id
$("#btnExport").click(function (e) {
window.open('data:application/vnd.ms-excel,' + $("#tableForExcel").html());
e.preventDefault();
});
The table I am using is
<table id='SearchTable' class='table table-bordered table-striped table-hover table blue '>
<tr>
<th class='ReportManager'>Report Manager</th>
<th class='ReportDetail'>Report Detail</th>
<th class='Form'>Form</th>
</tr>
<tr>
<td class='ReportManager'></td>
<td class='ReportDetail'></td>
<td class='Form'></td>
</tr>
<tr>
<td class='ReportManager'></td>
<td class='ReportDetail'></td>
<td class='Form'></td>
</tr>
</table>
I would be grateful if you could help me \ show me how i should adjust my code to get this to export.
window.openpiece is just plain JavaScript. Thedata:protocol is handled by your browser and OS. The only thing jQuery is doing here is grabbing the table HTML. If the class names are causing issues, you could clone the table, remove the classes, and pass that along instead.'with").