Change Align Export Title, Top Message and Bottom Message

Change Align Export Title, Top Message and Bottom Message

conandatatableconandatatable Posts: 5Questions: 1Answers: 0

How do I change align and font style for export title, top message and bottom message? The export title, top message and bottom message keep show in center when I export Excel or PDF file. Here is my code.

buttons: [
       {
              "extend": 'excelHtml5',
              "className": 'btn btn-table-excel',
              "init": function( api, node, config) {
                        $(node).removeClass('dt-button')
              },
              "title": exportTitle,
              "messageTop": exportMessageTop,
              "messageBottom": exportMessageBottom
       }, {
              "extend": 'pdfHtml5',
              "className": 'btn btn-table-pdf',
              "init": function( api, node, config) {
                       $(node).removeClass('dt-button')
              },
              "title": exportTitle,
              "messageTop": exportMessageTop,
              "messageBottom": exportMessageBottom
       }
],

My DataTables version is 1.10.13 and my DataTables Buttons version is 1.6.1

Answers

  • conandatatableconandatatable Posts: 5Questions: 1Answers: 0
    edited January 18

    exportTitle, exportMessageTop, exportMessageBottom is javascript variable

  • colincolin Posts: 8,013Questions: 0Answers: 1,348

    This thread shows how to change the font in the PDF export. For the alignment, you'll need to modify the pdfmake document that has been created (a bit like you already are for the image) to add that padding. The pdfmake documentation would be where to start.

    For Excel, this thread should help.

    Colin

  • conandatatableconandatatable Posts: 5Questions: 1Answers: 0

    Sorry before. I still newbie in datatables and pdfmake. Is that mean I need to install pdfmake so I can customize the alignment and its other style?

    For Excel thread, I found the answer about changing font style. How about the alignment?

  • colincolin Posts: 8,013Questions: 0Answers: 1,348

    Yep, you need PDFmake anyway, so that needs to be in your sources.

    Not sure about alignment in Excel, but again, you'll need to traverse through the document - this thread may help.

    Colin

  • conandatatableconandatatable Posts: 5Questions: 1Answers: 0

    Thank you. I will try it first. :)

  • conandatatableconandatatable Posts: 5Questions: 1Answers: 0

    I successfully changed align of exported excel title, top message and bottom message by adding this code. Thank you for giving me that thread @colin .

    "customize": function(xlsx) {
        var sheet = xlsx.xl.worksheets['sheet1.xml'];
        $('row:eq(0) c', sheet).attr('s','50');
        $('row:eq(1) c', sheet).attr('s','50');
        $('row:last c', sheet).attr('s','50');
    }
    
Sign In or Register to comment.