工做中遇到一需求,要將後臺的表格導出到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