Always export all rows to Excel

Always export all rows to Excel

FeraudFeraud Posts: 20Questions: 6Answers: 0

Hi,

I want to export all rows to Excel. Even if a row is selected. Documentation here says it is possible:

https://datatables.net/reference/api/buttons.exportData()

Quote: "set the selected option of the modifier object to be false. It will then include all rows in the export, regardless of any rows being selected"

I do so:

            buttons: [{
                extend: 'excel',
                ...
                exportOptions: {
                    columns: ':visible',
                    orthogonal: 'excel',
                    modifier: {
                        order: 'current',
                        page: 'all',
                        selected: false,
                    },
                ...
                },
            },

But the selected row is still not exported to Excel. Select style of the table is set to 'single'. Components used are:

JSZip 2.5.0, DataTables 1.10.18, Buttons 1.5.4, Column visibility 1.5.4, Flash export 1.5.4, HTML5 export 1.5.4, Print view 1.5.4, ColReorder 1.5.0, FixedColumns 3.2.5, KeyTable 2.5.0, Select 1.2.6

Any idea?

This question has an accepted answers - jump to answer

Answers

  • rognalesrognales Posts: 8Questions: 3Answers: 1

    can you try remove line 5?

  • allanallan Posts: 63,471Questions: 1Answers: 10,467 Site admin
    Answer ✓

    selected: false

    should be:

    selected: null

    Otherwise it will only export the rows that are not selected.

    If that doesn't resolve it, please link to a test case showing the issue.

    Allan

  • FeraudFeraud Posts: 20Questions: 6Answers: 0

    Thank you both for your help.

    Allan was right. Setting selected to null works.

    Maybe it's my bad English, but to me the documentation told me to set selected to false:

    "If this behaviour is not what you desire, set the selected option ... to be false. It will then include all rows in the export, regardless of any rows being selected."

    Anyway: great support. Thank you!

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Hi @Feraud ,

    Good spot, thanks - I'll update the docs. Oddly, it's correct here, but wrong here!

    Cheers,

    Colin

This discussion has been closed.