Numbers are being displayed as 19e+32234 while using data table export to excel button
When you export a data table using export to excel button, long numbers in that table will be shown as 19e+32234, but don't worry we can resolve that issue right away, just follow below steps
Check where the data table buttons have been initialized and change the code from
buttons: { buttons: [ { extend: 'copy', className: 'btn btn-primary' }, { extend: 'csv', className: 'btn btn-primary' }, { extend: 'excel', className: 'btn btn-primary'}, { extend: 'print', className: 'btn btn-primary' } ] }
to
buttons: { buttons: [ { extend: 'copy', className: 'btn btn-primary' }, { extend: 'csv', className: 'btn btn-primary' }, { extend: 'excel', className: 'btn btn-primary', exportOptions: { orthogonal: 'sort' }, customizeData: function ( data ) { for (var i=0; i<data.body.length; i++){ for (var j=0; j<data.body[i].length; j++ ){ data.body[i][j] = '\u200C' + data.body[i][j]; } } } }, { extend: 'print', className: 'btn btn-primary' } ] }
now just try downloading the excel file again and you will see numbers being displayed properly
Tagged: