首先引用一个jquery.table2excel.js插件
链接:https://pan.baidu.com/s/1gl3qCY1RcQk4xgbkeHypsQ 密码:w5zy
<button onclick="exportDevLedger()">导出列表</button>
<table id="tableShowAllInfo">
<thead>
</thead>
<tbody >
</tbody>
</table>
js代码
function exportDevLedger() {
$("#tableShowAllInfo").table2excel({
//exclude: ".noExl", //class = "noExl"的不被导出
name: "Excel Document Name",
filename: "数据统计", //生成的文件名
exclude_img: true,
exclude_links: true,
exclude_inputs: true
})
}
详细内容可看 https://blog.csdn.net/cherry_chenrui/article/details/78968789