Export CSV on Safari Saving as extension .css despite all my efforts

Export CSV on Safari Saving as extension .css despite all my efforts

nsheltonnshelton Posts: 1Questions: 1Answers: 0

Hello,

I am using the Buttons extension to export a table to csv. It works great on Chrome and Firefox, but on Safari, when it opens in a new tab, I right click and it saves as the extension .css and ignores my filename that I set. It saves as unknown.css. This happens with or without me setting the extension. Any way to fix this? My code is below. I'm sorry I don't have a live version of this yet, but I might in the morning. Any help you can provide would be great!

Best,
Nichole

var table = $('#uber-matrix').removeAttr('width').DataTable(
{
scrollX: true,
scrollCollapse: true,
'bpaginate': false,
'bFilter': false,
paging: false,
orderFixed: [ 0, 'asc' ],
columnDefs: [
{ targets: [ 0 ], visible: false },
{ targets: [ 1 ], orderable: false, width: 200 },
{ width: 130, targets: '_all' }
],
fixedColumns: true,
buttons: [
{
extend: 'csv',
//extension: '.csv',
filename: 'Badge_Matrix',
text: '<span class="excel">Export </span><i class="fa fa-share"></i>',
exportOptions: {
stripHtml: true,
columns: [':visible' ],
format: {
header: function ( data, columnIdx ) {
var ptName = $('span[data-header-col="'+columnIdx+'"]').html();
if(typeof(ptName) == 'string') {
return ptName;
} else {
return data;
}
},
body: function ( data, column, row ) {
var txt = data.replace(/<(?:.|\n)*?>/gm, '');
switch(txt)
{
case '4---':
txt = 'Not Submitted';
break;
case '3':
txt = 'Assigned';
break;
case '2':
txt = 'Submitted';
break;
case '1':
txt = 'Badge';
break;
}
return txt;
}
}
}
}

    ]
});

Answers

  • allanallan Posts: 61,795Questions: 1Answers: 10,115 Site admin

    Unfortunately I suspect there is no way to resolve this at the moment. Safari is seriously lacking in its ability to create local files due to this webkit bug.

    The good news is that there has been some movement on that bug int he last few days, so hopefully it will be resolved soon and Safari can work like all the other browsers :-)

    Allan

This discussion has been closed.