I have implemented jquery datatable in my application.
But the problem is when I export the excel from datatable , then by default the type of all columns is text/General.
Is there any option to change the format of the column from string to date (MM/dd/YYYY) before export the excel?
This is our client requirement and I am not able to do that .
Please help me to resolve this .
Below are my sample code.
$(document).ready(function () {
$.fn.dataTable.moment('D/MM/YYYY');
$('#assetleakage').on('init.dt', function () {
$("#assetleakage").wrap("<div class='table-wraper'></div>");
}).dataTable({
"columnDefs": [
{
targets: [16, 17],
orderable: false
},
{
targets: [0, 1, 2, 3, 4, 9, 14],
searchable: false
}],
dom: 'lBfrtip',
buttons: [
{
extend: 'csv',
exportOptions: {
columns: [6, 7, 8, 9, 2, 11, 12, 13, 14, 3, 5, 16]
}
},
{
extend: 'excel',
exportOptions: {
columns: [6, 7, 8, 9, 2, 11, 12, 13, 14, 3, 5, 16]
}
},
{
extend: 'pdf',
pageSize: 'A2',
exportOptions: {
columns: [6, 7, 8, 9, 2, 11, 12, 13, 14, 3, 5, 16]
}
}],
"language": {
"lengthMenu": "Display records per page _MENU_",
"zeroRecords": "No records available",
"infoEmpty": "No records available",
"infoFiltered": "(filtered from _MAX_ total records)"
}
});
});
Thanks in advance.