我的网页上有一个HTML表格,当我使用JQuery将它导出到Excel时,如果我在表头中有任何id或类标记,它就不能工作。
我使用的JQuery是
//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();
});我用的桌子是
<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>如果您能帮助我\告诉我应该如何调整代码以使其导出,我将不胜感激。
发布于 2015-12-16 10:14:13
我用这种方法解决了这个问题:
$("#btnExport").click(function (e) {
window.open('data:application/vnd.ms-excel,' +'<table>' +$("#SearchTable").html()+ '</table>');
e.preventDefault();
});希望它能帮到你。
https://stackoverflow.com/questions/32525465
复制相似问题