Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

198
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda