DATATABLES EXPORT ALL TO EXCEL (Server-Side) - BIG DATA (ORACLE)

Viewed 37

I'm using Datatables Server-Side Processing due to the pagination Big Data. I've created buttons to export current page to excel,csv and copy. I want also to export all data at least to excel, which I tried and work for small data. but I have more than 3 millions records. Here is my

$(document).ready(function(e)

arr1 = [10,50,100,500,1000,5000];
arr2 = [10,50,100,500,1000,5000];
$(document).ready(function(e) {
    $('#table_list').dataTable({
            "bProcessing": true,
            "serverSide": true,
            "language": {
                "url": "Polish.json"
            },
            "ajax": {
                    url: "dataList.php",
                    type: "POST",
                    error: function(data) {
                        alert("some error occured please try again.")
                    }
            },
            "sSearch":false,
            "fixedHeader": {header: true,},
            "scrollY" :"50vh",
            "scrollX":"50vw",
            "lengthMenu": [arr1, arr2],
            "sPaginationType": "input", 
            dom: 'lBfrtip',
            buttons: [{ extend: 'excel', text: 'EXCEL' }, 
                    { extend: 'csv', text: 'CSV' }, 
                    { extend: 'copy', text: 'KOPIUJ DO SCHOWKA' },
                    {"extend": 'excel', "text": 'Excel (All)',"action": newexportaction},
                    ],

        });

    function newexportaction(e, dt, button, config) {
        var self = this;
        var oldStart = dt.settings()[0]._iDisplayStart;
        dt.one('preXhr', function (e, s, data) {
            // Just this once, load all data from the server...
            data.start = 0;
            data.length = 2888888888888888888888888888888888888888888888888888888;
            dt.one('preDraw', function (e, settings) {
                // Call the original action function
                if (button[0].className.indexOf('buttons-copy') >= 0) {
                    $.fn.dataTable.ext.buttons.copyHtml5.action.call(self, e, dt, button, config);
                } else if (button[0].className.indexOf('buttons-excel') >= 0) {
                    $.fn.dataTable.ext.buttons.excelHtml5.available(dt, config) ?
                         $.fn.dataTable.ext.buttons.excelHtml5.action.call(self, e, dt, button, config) :
                         $.fn.dataTable.ext.buttons.excelFlash.action.call(self, e, dt, button, config);
                } else if (button[0].className.indexOf('buttons-csv') >= 0) {
                    $.fn.dataTable.ext.buttons.csvHtml5.available(dt, config) ?
                         $.fn.dataTable.ext.buttons.csvHtml5.action.call(self, e, dt, button, config) :
                         $.fn.dataTable.ext.buttons.csvFlash.action.call(self, e, dt, button, config);
                }  
                dt.one('preXhr', function (e, s, data) {
                    // DataTables thinks the first item displayed is index 0, but we're not drawing that.
                     // Set the property to what it was before exporting.
                     settings._iDisplayStart = oldStart;
                     data.start = oldStart;
                 });
                 // Reload the grid with the original page. Otherwise, API functions like table.cell(this) don't work properly.
                 setTimeout(dt.ajax.reload, 0);
                 // Prevent rendering of the full data to the DOM
                 return false;
             });
         });
         // Requery the server with the new one-time export settings
         dt.ajax.reload();
     }

After clicking export all it's out of memory or something like that for big data (it works for small data like 1k rows). How can I skip it?

0 Answers
Related