Bootstrap之导出Excel表格
一.导包
<script src="static/js/plugin/table_export/table-export.js"></script>
<script src="static/js/plugin/table_export/tableExport.js"></script>
<script src="static/js/plugin/table_export/jquery.base64.js"></script>
<script src="static/js/plugin/table_export/main.js"></script>
下载地址:
链接:https://pan.baidu.com/s/1EqsqvNPQvGQEUj7mnd8l\_w
提取码:i86p
二.导出Excel
表格
<!-- bootstrap-table -->
<table id="tableGrid" data-height="488" data-mobile-responsive="true">
</table>
初始化加入
TableExport.init();
(1) 通过点击事件自定义导出Excel
<button class="btn btn-default" type="button" onclick="outExcel()" >导出Excel
</button>
导出
function outExcel() {
$('#tableGrid').tableExport({
type: 'excel',
escape: 'true',
fileName: 'Excel统计表', //导出Excel的名称
ignoreColumn: [0, 1] //删除第0,1列
})
}
(2) 默认绑定事件
<button class="export-excel btn btn-default" data-table="#tableGrid" type="button" >导出Excel
</button>
注意:需要申明calss属性 export-excel 以及绑定data-table即表格table的id
还没有评论,来说两句吧...