footer row is not getting exported in excel, pdf, csv and html

footer row is not getting exported in excel, pdf, csv and html

hardickhardick Posts: 7Questions: 2Answers: 0
edited September 2021 in Buttons

i have added footer: true in my buttons and i have fnFooterCallback in my js and footer row is not exported in any of my format

example code

$('#haddy).DataTable({  
"buttons": [
            {
                extend: 'copyHtml5',
                text: '<i class="fa fa-files-o"></i>',
                titleAttr: 'Copy',
                title: ReportTitle,
                exportOptions: {
                    columns: ':visible'
                },
                footer: true
            },
            {
                extend: 'excelHtml5',
                text: '<i class="fa fa-file-excel-o"></i>',
                titleAttr: 'Excel',
                title: ReportTitle,
                footer: true,
                exportOptions: {
                    columns: ':visible'
                },
                customizeData: function (data) {
                    for (var i = 0; i < data.body.length; i++) {
                        for (var j = 0; j < data.body[i].length; j++) {
                            var ColInfo = $.grep(dataColumn, function (value, index) {
                                return value.DisplayName == data.header[j];
                            });
                                data.body[i][j] = '\u200C' + data.body[i][j];
                        }
                    }
                }   
            }
],
"fnFooterCallback": function (tfoot, data, start, end, display) {
var api = this.api();
                var footer = '<tfoot id="rptFooter"><tr class="dataFooter">';
var outvalue = api.column(i).data().reduce(function (a, b) { return a + b; }, 0);
footer = footer + '<th class="' + cclass + '">' + outvalue + '</th>';
footer = footer + '<th></th>';
$(this).append(footer + '</tr></tfoot>');
});

Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

Answers

Sign In or Register to comment.