• Resolved sorgiulio

    (@sorgiulio)


    Hi Tobias.
    As you suggested to me in other posts, I’m using this command for my table:

    "order": [[2, 'asc']],"dom": "WlfrtipB","buttons":[{"extend": "excel", "text": "Excel"},{ "extend": "pdf", "text": "PDF"},{ "extend": "print", "text": "Stampa"}],"columnDefs": [ { "visible": false, "targets": [ 2 ] } ]

    There is a hidden columns (2) or other columns (4 and 5) that I would like to hide in the PDF or Excel or Print file.
    How can I do?

    Thank you, you’re so kind.

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    thanks for your post, and sorry for the trouble.

    If I understand https://datatables.net/reference/button/print correctly, you could try adding

    "exportOptions": { "columns": ":visible" }
    

    for every button, as an extra parameter after every of the "extend" commands.

    Regards,
    Tobias

    Thread Starter sorgiulio

    (@sorgiulio)

    Great Tobias!!!
    Looking at the link you put, instead of using “: visible”, I put the number of columns to export.
    Now the code is:

    "order": [[2, 'asc']],"dom": "WlfrtipB","buttons":[{"extend": "excel", "text": "Excel","exportOptions":{"columns":"0,1,3,6"}},{"extend": "pdf", "text": "PDF","exportOptions":{"columns":"0,1,3,6"}},{ "extend": "print", "text": "Stampa","exportOptions":{"columns":"0,1,3,6"}}],"columnDefs": [ { "visible": false, "targets":[2]}]

    I take this opportunity for a last question:
    Is it possible to write the code in column rather than in sequence?
    Example:

    "order": [[2, 'asc']],
        "dom": "WlfrtipB",
           "buttons":[{"extend": "excel", "text": "Excel","exportOptions":{"columns":"0,1,3,6"}}...
                 etc...
                  etc...
                etc...
    etc...
    Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    yes, that’s no problem! ??
    You can even drag the input field bigger to make things better readable.

    Regards,
    Tobias

    Thread Starter sorgiulio

    (@sorgiulio)

    Thanks!!!

    Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    no problem, you are very welcome! ?? Good to hear that this helped!

    Best wishes,
    Tobias

    P.S.: In case you haven’t, please rate TablePress here in the plugin directory. Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Buttons PDF-Excel Hide Columns’ is closed to new replies.