Custom header while exporting to excel

Custom header while exporting to excel

karthiklalkarthiklal Posts: 2Questions: 1Answers: 0

I need to have a custom header for the export excel, how to do it ?

Answers

  • colincolin Posts: 15,118Questions: 1Answers: 2,583

    See if this helps,

    Colin

  • karthiklalkarthiklal Posts: 2Questions: 1Answers: 0
    edited December 2020

    I have found the solution

    buttons: [
                {extend: 'excelHtml5',
                title: 'Report',
                text:'<i class="fa fa-table fainfo" aria-hidden="true" ></i>',
                titleAttr: 'Export Excel',
                "oSelectorOpts": {filter: 'applied', order: 'current'},
                exportOptions: {
                        modifier: {
                        page: 'all'
                        },
                            format: {
                                header: function ( data, columnIdx ) {
                                    if(columnIdx==1){
                                    return 'column_1_header';
                                    }
                                    else{
                                    return data;
                                    }
                                }
                            }
                    }
                ]
    
This discussion has been closed.