工做中遇到一需求,要将后台的表格导出到excel后的表格样式该如何修改呢?
其实表格导出首先须要了解两个插件:jquery.table2excel.js和tableExport.jsjquery
一、第一步,写一个导出按钮button插件
<button>导出</button>
二、第二步,初始化jsexcel
$('button').click(function(){ $("#datatable").table2excel({ exclude: ".noExl", name: "Excel Document Name", filename: "myFileName", //此处为导出的文件名 exclude_img: true, exclude_links: true, exclude_inputs: true ///////此处的配置项能够根据需求配置 }); })
$("button").click(function(){ $('#stats_datatable').tableExport({ type:'excel', escape:'false', fileName: 'myFileName'//此处为导出的文件名 ///////此处的配置项能够根据需求配置 }); });
三、若是导出的表格的样式没法导出到excel,须要本身在js里写,以下图
四、最后在HTML文件中引入相对应的js文件便可。code