Export to excel/csv with footer

Export to excel/csv with footer

averma06averma06 Posts: 2Questions: 1Answers: 0

How can we export data in datatable to excel or csv format which includes footer information also. Currently, footer gets exceluded. However, on setting footer as true for pdf I am able to get in PDF format.

PDF FOOTER EXPORT WORKS:

                        extend: 'pdfHtml5',
                        footer: true

EXCEL / CSV FOOTER EXPORT DOES NOT WORK tried setting footer same as above for extend: 'excel'

Answers

  • averma06averma06 Posts: 2Questions: 1Answers: 0

    Below is the settings for button, please advice what is missing for for footer export in excel format:

                    buttons: [
                        'copy', 'csv',
                        {
                            orientation: 'portrait',
                            pageSize: 'LEGAL',
                            extend: 'excel',
                            footer: true,
                            title: reportName + " " + searchCriteriaText
                        },
                        {
                            orientation: 'portrait',
                            pageSize: 'LEGAL',
                            extend: 'pdfHtml5',
                            footer: true,
                            title: reportName + "\n" + searchCriteriaText,
                            //message: '',
                            customize: function (doc) {
                                doc.content[1].layout = "Borders";
                                ];
                            }
                        },                        
                        {
                            orientation: 'portrait',
                            extend: 'print',
                            footer: true,
                            message: '<p style="text-align:center;">' + searchCriteriaText + '</p>',
                            customize: function (win) {
                                $body = $(win.document.body);
                                $body.find('h1').css('text-align', 'center');
                            }
                        }
                    ],
    
  • jw2jw2 Posts: 2Questions: 0Answers: 0

    I am using 1.10.16 and can confirm that exporting footer for csv does not work

    Here is my configuration:

    buttons: [{
        extend: 'csvHtml5',
        text: '<span class="fa fa-download"></span> CSV',
        filename: 'My_File',
        footer: true
    }],...
    
  • kthorngrenkthorngren Posts: 21,167Questions: 26Answers: 4,921

    Seems to work here for both CSV and Excel:
    http://live.datatables.net/vocivoji/1/edit

    What version of buttons are you using?

    Kevin

  • jw2jw2 Posts: 2Questions: 0Answers: 0

    I am using the most recent version of buttons 1.5.1

    I did a couple of experiments and found that the footer isn't exported bc i add it dynamically using footerCallback; When I removed that and added a footer to the table before initializing the datatable it exported correctly.

  • allanallan Posts: 63,205Questions: 1Answers: 10,415 Site admin

    That would do it. You need to add the footer before you initialise the DataTable in order for Buttons to be able to export it.

    Allan

This discussion has been closed.