Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

205
Views
Datatables - Export different data to what is shown in the table?

I have a script which adds an export to Excel button to my datatables:

$(document).ready(function() {
    
      $('#table_id').DataTable( {
        dom: 'Brtip',
        buttons: [
            {
              extend: 'excel',
          filename: function(){
                    var today = new Date();
            var date = today.getFullYear()+'-'+(today.getMonth()+1)+'-'+today.getDate();
            var time = today.getHours() +':'+ today.getMinutes()+':'+today.getSeconds();
            var dateTime = date+' '+time;                
            return 'Query ' + dateTime;
                },
              customize: function ( xlsx ) {
                var sheet = xlsx.xl.worksheets['sheet1.xml'];
                $('c[r=A1] t', sheet).text( '{{foo_query}}' );
            $('c[r=A2] t', sheet).text( '' );
                $('row:first c', sheet).attr( 's', '2' ); // first row is bold
              }
            }
        ]
      } );
    
    });

This works fine:

enter image description here

However, I am only showing the top 200 hits in the datatable, as the actual dataframe is 35,000+ and takes too long to load.

When I click the Excel button it sends the data that is in the table, but ideally I want it to export the original data which I hold as a global variable called 'dataHold'

Is there any way do do this?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!