excel export with multiple sheets consider filder and render

excel export with multiple sheets consider filder and render

dascocodascoco Posts: 9Questions: 4Answers: 0

I'm using the solution from @you2525 for excel export with multiple sheets
The export works very well but exports all blank data and doesn't consider render and filter used on the datatable. Is there a way to export that as shown in the table?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,133Questions: 1Answers: 10,399 Site admin

    In the getTableData function the table.rows().every( part could be changed to be:

    table.rows({search: ‘applied’}).every(
    

    to get just the filtered data. The code following that could also be modified if you want to get rendered data rather than the raw data for the row.

    Allan

  • dascocodascoco Posts: 9Questions: 4Answers: 0

    Thanks works very well.

    Do you also have a short example for rendered data? And I also have a multiple selection on the datatable when I select some rows in PDF export only that ones are exported. Is it also possible for Excel export?

  • allanallan Posts: 63,133Questions: 1Answers: 10,399 Site admin
    Answer ✓

    You are largely reimplement what Buttons already has here - I'd suggest looking at using the buttons.exportData() method (it wasn't available back when the example you are working off was originally created). It can be used to orthogonal export and getting selected rows only.

    Allan

  • dascocodascoco Posts: 9Questions: 4Answers: 0

    Thank you for suggestion. It gave me the hint what needs to be change.

    I changed in the getTableDatafunction the table.rows().every( part to:

        table.rows({ search: 'applied', selected: table.rows('.selected').any() }).every(function (rowIdx, tableLoop, rowLoop) {
            var renderedData = table.cells(rowIdx, '').render('display');
            var aData = [];
    
            excelExportLayout()[tableID].forEach(function (colID) {
                aData.push(renderedData[colID]);
            });
            ws += buildRow(aData, rowNum, '');
    
            rowNum++;
        });
    
This discussion has been closed.