最近公司改后台管理系统。要求导出台账项目等等为excel表格,找半天还真有,他是通过query.table2excel.js 实现,原谅我原生不会弄这个当然大家有可以给我留言。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<table class="table"> //表格
<tr class="noExl"> //加class是为了有些你不想导出用来选则
<th>Header</th>
<th>111</th>
</tr>
<tr>
<td>Data</td>
<td>222</td>
</tr>
</table>
<button id="btn">导出</button>
<script src="js/jquery-1.11.0.min.js" type="text/javascript" charset="utf-8"></script>//引入jquery
<script src="js/jquery.table2excel.js" type="text/javascript" charset="utf-8"></script> //引入jquer插件
<script type="text/javascript">
$("#btn").click(function(){ //点击按钮执行导出
$(".table").table2excel({ //选取导出的表格
exclude: ".noExl", //写你不想都想导出的
name: "Excel Document Name",
filename: "项目", //导出的文件名
exclude_img: true, //是否导出图片
exclude_links: true,
exclude_inputs: true
});
})
</script>
</body>
</html>