Excel button export column not in table but inside source data

Excel button export column not in table but inside source data

alzamboalzambo Posts: 38Questions: 17Answers: 1

Hi,
I need to add a field in my exported excel file.
I don't have this field (column) displayed in the table but it is contained in table source data array.
How can I include it in my export button configuration column selector?

This is my code portion:

[...]
"data": datiTabella,
buttons: [
            {
                extend: 'excel',
                text: 'Esporta Excel',
                className: 'btn btn-default',
                exportOptions: {
                    modifier: {
                        page: 'current'
                    },
                    columns: [ 3,4,5,6,7,8,9,10,11,12,13,14 ], // I don't know how to select data that is not on table
                    format: {
                        body: function ( data, column, row ) {
                           // here I have some column formatting...
                        }
                    }
                }
            }
        ]
[...]

Thank you,
alex

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,431Questions: 1Answers: 10,048 Site admin
    Answer ✓

    Hi Alex,

    The file export options of Buttons will only export the data from the columns. As such you would need to include it in the table's columns. But you could simply set the column's visibly to false (columns.visible) if you don't want the column to be visible.

    Allan

  • alzamboalzambo Posts: 38Questions: 17Answers: 1
    edited May 2016

    Perfect, thank you Allan.

This discussion has been closed.