表格导出到excel的样式消失该如何修改

工作中遇到一需求,要将后台的表格导出到excel后的表格样式该如何修改呢?
其实表格导出首先需要了解两个插件:jquery.table2excel.js和tableExport.js

1、第一步,写一个导出按钮button

<button id="datatable">导出</button>

2、第二步,初始化js

①jquery.table2excel.js

$('button').click(function(){   
        $("#datatable").table2excel({  
           exclude: ".noExl",  
           name: "Excel Document Name",  
           filename: "myFileName",  //此处为导出的文件名
           exclude_img: true,  
           exclude_links: true,  
           exclude_inputs: true  
           ///////此处的配置项可以根据需求配置
        });  
        }) 

②tableExport.js

$("button").click(function(){
        $('#datatable').tableExport({
        type:'excel',
        escape:'false',
        fileName: 'myFileName'//此处为导出的文件名
        ///////此处的配置项可以根据需求配置
        });
    });

3、如果导出的表格的样式无法导出到excel,需要自己在js里写,如下图

4、最后在HTML文件中引入相对应的js文件即可。

原文地址:https://www.cnblogs.com/shemingxin/p/11837189.html