首先:下载
table2excel.js
<!--用这个div把想要下载的table包起来,下面的button是按照id触发事件的,如果有多个表格下载按钮,换成class触发,因为id不能有重复-->
<
div
class
="table-responsive table2excel"
data-tableName
="Test Table 1">
<table>...</table>
</div>
<
button
id
="btn"
class
="btn btn-primary">
导出
</
button
>
<!--
下载当前页面的表格为
excel
格式功能
-->
{#<script>window.jQuery || document.write('<script src="../../static/jquery-1.11.0.min.js"><\/script>')</script>#}
<
script
src=
"../../static/jquery.table2excel.js"
></
script
>
<
script
>
$
(
function
()
{
$
(
"#btn"
)
.
click
(
function
()
{
$
(
".
table2excel
"
)
.
table2excel
(
{
exclude
:
".noExl"
,
name
:
"Apptoapi Excel"
,
filename
:
"domain"
,
exclude_img
:
true
,
exclude_links
:
true
,
exclude_inputs
:
true
}
)
;
}
)
;
}
)
;
</
script
>
借鉴自:http://www.cnblogs.com/xionggeclub/p/6196331.html