本文转载自:https://blog.csdn.net/plmzaqokn11/article/details/73604705
下载table2Excel插件
<input type="button" id="btn" value="导出" /> <table id="example"> <thead> <tr> <th>Column 1</th> <th>Column 2</th> <th>Column 3</th> <th>Column 4</th> <th>Column 5</th> </tr> </thead> <tbody> <tr> <td colspan="2">1aaa</td> <td>ccc</td> <td>ddd</td> <td>eee</td> </tr> <tr style="background-color:#0f0;"> <td>3aaa</td> <td>34bbb</td> <td>ccc</td> <td>ddd</td> <td>修改</td> </tr> <tr> <td>22bbb</td> <td>22bbb</td> <td>ccc</td> <td>ddd</td> <td>eee</td> </tr> <tr> <td>5aaa</td> <td>55bbb</td> <td>ccc</td> <td>ddd</td> <td>eee</td> </tr> <tr> <td>4aaa</td> <td>44bbb</td> <td>ccc</td> <td>ddd</td> <td>eee</td> </tr> </tbody> </table>
$(function(){ $("#btn").click(function(){ $("#example").table2excel({ // 不被导出的表格行的CSS class类 exclude: ".noExl", // 导出的Excel文档的名称,(没看到作用) name: "Excel Document Name", // Excel文件的名称 filename: "myExcelTable" }); }); });