Excel export of huge number of rows

Excel export of huge number of rows

guilhermemaranhaoguilhermemaranhao Posts: 38Questions: 11Answers: 0

Hi everybody,

I have to export a table containing almost 25 thousands rows to excel. I've initialized the Excel button with these parameters:

dom: 'Bfrtip',
            buttons: [ {
                extend: 'excelHtml5',
                exportOptions: {
                    columns: [ 1, 2, ':visible' ]
                },
                className: 'bt-default',
                filename: 'myfilename',
                title: 'mytitle'
            } ]

When I select it, I got "Page not responding" error from my browser and the file is not downloaded. How do you suggest I proceed with that?

If I create multiple sheets in the customize section, each of them with 4 thousands rows approximately, would fix that? Is it possible to do something like that?

Or is it a technology limitation, which I simply can't export a table like that?

Thank you,

Guilherme

Answers

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

    Hi @guilhermemaranhao ,

    I suspect you're reaching the end of the technology as you suggested. I don't think splitting it into sheets would help, since the time would still be the same which would kill the browser.

    You could split it into chunks using the exportOptions row-selector - see here (it's only exporting first 25 rows).

    Hopefully that could do the trick,

    Cheers,

    Colin

  • guilhermemaranhaoguilhermemaranhao Posts: 38Questions: 11Answers: 0

    Thank you, @colin ! I'll take a look at it.

  • guilhermemaranhaoguilhermemaranhao Posts: 38Questions: 11Answers: 0

    Hi @colin ,

    In my application, there is a filter of states, that the user can filter the data.
    I was thinking on forcing the user to choose a state before exporting the table (if there is no state chosen).
    The problem with my solution is that I would be overwriting the 'action' method. Is there another way i could alert the user? Or with I make a custom button, how can I invoke the excel exporting functionality?

    dom: 'Bfrtip',
                buttons: [ {
                    extend: 'excelHtml5',
                    exportOptions: {
                        columns: [ 1, 2, ':visible' ]
                    },
                    className: 'bt-default',
                    filename: 'myfilename',
                    title: 'mytitle',
                     action: function ( e, dt, node, config ) {
                        if (there is no selected state)
                        {
                            alert('You must chose at least a state!');
                        }
                    }
                } ]
    
  • guilhermemaranhaoguilhermemaranhao Posts: 38Questions: 11Answers: 0

    Or at least, can I define a tooltip in my button?

  • guilhermemaranhaoguilhermemaranhao Posts: 38Questions: 11Answers: 0

    I've found it.

    titleAttr:
    

    property.

    But if I could do it with the action method, like I suggested before, would be much better.

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

    Hi @guilhermemaranhao ,

    Yep, you can call the standard action in the button you extend, for example here.

    Cheers,

    Colin

  • guilhermemaranhaoguilhermemaranhao Posts: 38Questions: 11Answers: 0

    Great, @colin !!

    That's what I need!

    Thank you very much!

    Guilherme

This discussion has been closed.