How to Export Multiple Row Headers in jQuery Datatables?

前端 未结 6 660
挽巷
挽巷 2021-02-10 08:16

Hi I am using jQuery Datatables 1.10. I am trying to export Datatable multiple header rows but not getting. But it is Exporting only second header row. I am using Buttons:

6条回答
  •  青春惊慌失措
    2021-02-10 08:50

    Hi maybe I'm a little late but I hope my answer can help someone else. I exported all rows using an extra library, in my case, table2excel. I just copied the header rows using html() function and getting all the rows with .DataTable() function. The code looks as follows:

    $("#exportExcel").click(function(){
        $('')
        .append(
             $("#table1 thead").html()
         )
         .append(
            $("#table1").DataTable().$('tr').clone()
         )
         .table2excel({
            exclude: "",
            name: "casting",
            filename: "ExportedData.xls" 
         });
        });
    

    It solved the problem in my case.

    提交回复
    热议问题