I've got a javascript for converting the data and save it as a csv file. It looks like this:
function downloadCSV(args) {
var data, filename, link;
var type = args.type;
var fields = Object.keys(json_for_export[0]);
var csv = json_for_export.map(function(row){
return fields.map(function(fieldName){
return '"' + (row[fieldName] || '') + '"';
});
});
csv.unshift(fields);
csv = csv.join('\r\n')
if (csv == null) return;
filename = 'csv' + '_' + args.filename || 'export.csv';
if (!csv.match(/^data:text\/csv/i)) {
csv = 'data:text/csv;charset=utf-8,' + '\uFEFF' + csv;
}
data = encodeURI(csv);
link = document.createElement('a');
link.setAttribute('href', data);
link.setAttribute('download', filename);
link.click();
}
It works fine in Chrome Browser but doesn't work in Firefox. What can be a cause of the problem? A check into the console and the data is formatted well into a csv type.