var prodajax = "<?php echo admin_url('admin-ajax.php?action=skap_prod_table');?>";
var prodtable = $('#product-table').DataTable({
dom: 'Blfrtip',
pageLength: 20,
ajax: prodajax,
rowId: 'id',
columns: [
{ "data": "product_number" },
{ "data": "name" },
{ "data": "product_tab" },
{ "data": "purchase_price" },
{ "data": "no_price" },
{ "data": "nor_price_tax" },
{ "data": "product_status" },
{ "data": "producturl"},
{ "data": "producturl2"},
{
"className": 'details-control-2',
"orderable": false,
"data": null,
"defaultContent": '<a href="#" class="edit-prod">'+
'<i class="fa fa-pencil"></i>'+
'</a>'+
'<a href="#" class="quick-view"><i class="fa fa-chevron-circle-down" aria-hidden="true"></i></a>'
}
],
buttons: [ {
extend: 'excelHtml5',
exportOptions: {
columns: [ 0, 1, 2, 4,7,8 ]
},
title: '',
customize: function( xlsx ) {
var sheet = xlsx.xl.worksheets['sheet1.xml'];
$('row c', sheet).each( function () {
if ( $('is t', this).text().indexOf("http") === 0 ) {
$(this).append('<f>' + 'HYPERLINK("'+$('is t', this).text()+'","'+$('is t', this).text()+'")'+ '</f>');
$(this).attr( 's', '2' );
}
});
}
} ],
columnDefs: [
{
"targets": [ 7 ],
"visible": false,
},
{
"targets": [ 8 ],
"visible": false
}, { type: numbersType, targets: 0 }
],
order: [[0, 'asc']]
});
As it can be seen there seems to be a parsing error with file whenever I open it in MS excel (works fine in WPS, google sheets). I have some URLs in my file that the client wants directly clickable as they are just strings/text otherwise. So I included the customize function which seems to be the cause of the issue, because if i comment out that function, it works and opens up fine.