Datatables Excel export trying to convert part number to date

If the column has 4519-00-01 as a value, Excel tries to convert it to a date.
JavaScript

Add this to the main Datatable init.

       	columnDefs: [{
       		targets:[1],
       		render: function(data, type, row, meta){
          		if(type === 'sort'){
             		//data = ' ' + data ;
              		return "\u200C" + data ; 
          		}
          	return data ;   
	       }
	    }],

Add orthogonal: 'sort' to the exportOptions of your excel export line

{ text: 'Excel', extend: 'excel', footer: false, className: 'btn btn-sm btn-outline-secondary', exportOptions: { orthogonal: 'sort', columns: ':visible' }, extension: '.xlsx', init: function(api,node,config){ $(node).removeClass('dt-button') } },
			

Written by fbrefere001

Posted by fbrefere001 on Friday January 31, 2025