jquery data table export pdf, excel and csv col span with header and rows are not working

jquery data table export pdf, excel and csv col span with header and rows are not working

ArsalanQaiserArsalanQaiser Posts: 6Questions: 5Answers: 0
edited November 2018 in Free community support

Hello Everyone i want to add colspan and row span in my exported pdf file. I generate mutliple header grid. but problem is something related to syling when i going to export this it's add line please check the snapshot i want to remove the line the vertical line and add text align in center

i want something like this

Hery is my jquery code

$('#example').DataTable({
        searching: false, paging: false, info: false, ordering: false,
        dom: 'Bfrtip',
        buttons: [
            {
                extend: 'excelHtml5',
                exportOptions: {
                    columns: "thead th:not(.noExport)",
                    rows: function (indx, rowData, domElement) {
                        return $(domElement).css("display") != "none";
                    }
                },
                customize: function (xlsx) {
                    var sheet = xlsx.xl.worksheets['sheet1.xml'];

                    $('row c[r^="C"]', sheet).attr('s', '2');
                }

            },
            {
                extend: 'csvHtml5',
                exportOptions: {
                    columns: "thead th:not(.noExport)",
                    rows: function (indx, rowData, domElement) {
                        return $(domElement).css("display") != "none";
                    }
                }
            },
            {
                orientation : 'landscape',
                pageSize: 'A3',
                extend: 'pdfHtml5',
                exportOptions: {
                    columns: "thead th:not(.noExport)",
                    rows: function (indx, rowData, domElement) {
                        return $(domElement).css("display") != "none";
                    }
                }
                ,
                customize: function (doc) {
                    doc.defaultStyle.alignment = 'center';
                    doc.content[1].table.widths = Array(doc.content[1].table.body[0].length + 1).join('*').split('');
                    var tblBody = doc.content[1].table.body;
                    
                    doc.content[1].layout = {
                        hLineWidth: function (i, node) {
                            return (i === 0 || i === node.table.body.length) ? 2 : 1;
                        },
                    };
                },

            }, {
                extend: 'print',
            }
        ]
    });

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Hi @ArsalanQaiser ,

    Multiple headers aren't supported in the export I'm afraid - there's a few threads on this, such as this one here.

    Cheers,

    Colin

  • Josue MorenoJosue Moreno Posts: 1Questions: 0Answers: 0

    Alguna novedad sobre este tema. o se sigue sin resolver?

  • Hbra2310Hbra2310 Posts: 4Questions: 1Answers: 0

    como sigue este tema, ya se le dio alguna solucion?

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    No, that's still the case.

  • JuJoGuAlJuJoGuAl Posts: 32Questions: 2Answers: 0

    Chicos @Hbra2310 y Jose, en efecto datatable no posee funcion propia para multiple headers, pero en Stackoverflow hay una funcion que te devuelve una matrix del Header, y lo que haces con esa matrix es trabajarla en funcion a lo que necesites (excluir o fusionar)

This discussion has been closed.