how to remove spaces between text in columns in excel export.
how to remove spaces between text in columns in excel export.
deepak2309
Posts: 1Questions: 1Answers: 0
how to remove spaces between text in columns in excel export. please find the attachments.
$(document).ready(function() { var buttonCommon = { exportOptions: { format: { body: function ( data, row, column, node ) { // Strip $ from salary column to make it numeric return column === 5 ? data.replace( /[$,]/g, ' ' ) : data; } } } }; $('#mytable').DataTable( { dom: 'Bfrtip', "bDestroy": true, buttons: [ $.extend( true, {}, buttonCommon, { extend: 'excelHtml5' } ) ]**** } ); } );This discussion has been closed.
Answers
Here is an example for a custom button that also uses exportOptions to format what is being exported. You can also use exportOptions in the table definition itself ... and hence get rid of your spaces or whatever you would like to do before exporting the data.
In this example I had to get rid of local number formatting and a couple of columns. I also had to change a percentage into a fraction etc. The customize piece makes sure that everything gets formatted according to the standards of the respective user's Excel installation.
https://datatables.net/extensions/buttons/examples/print/columns
What spaces? Can you link to a test case showing the issue if @rf1234's reply doesn't help to resolve it.
Allan