jquery.table2excel.min.js下载地址
https://github.com/rainabba/jquery-table2excel
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>html 表格导出道</title>
<script src="js/jquery-1.8.3.min.js"></script>
<script src="js/jquery.table2excel.min.js"></script>
<script language="JavaScript" type="text/javascript">
$(document).ready(function () {
$("#btnExport").click(function () {
$("#tableExcel").table2excel({
exclude : ".noExl", //过滤位置的 css 类名
filename : "文件名称" + new Date().getTime() + ".xlsx", //文件名称
name: "Excel Document Name.xlsx",
exclude_img: true,
exclude_links: true,
exclude_inputs: true
});
});
});
</script>
</head>
<body>
<div >
<button type="button" id="btnExport" >导出Excel</button>
</div>
<div id="myDiv">
<table id="tableExcel" width="100%" border="1" cellspacing="0" cellpadding="0">
<tr style="text-align: center;">
<th rowspan="2">姓名</th>
<th colspan="2">一月</th>
<th colspan="2">二月</th>
</tr>
<tr style="text-align: center;">
<th>收入</th>
<th>支出</th>
<th>收入</th>
<th>支出</th>
</tr>
<tr style="text-align: center;">
<td>张三</td>
<td>10元</td>
<td>20元</td>
<td>15元</td>
<td>25元</td>
</tr>
<tr style="text-align: center;">
<td>李四</td>
<td>100元</td>
<td>200元</td>
<td>150元</td>
<td>250元</td>
</tr>
</table>
</div>
</body>
</html>