How to export filename with special char as "&"?
How to export filename with special char as "&"?
markzzz
Posts: 49Questions: 8Answers: 1
Hi all,
I'm trying to export a file with "Mark & Tables Associated" as filename:
$(document).ready(function() {
var dataSet = [
[ "Tiger Nixon", "System Architect", "Edinburgh", "5421", "2011/04/25", "$320,800" ],
[ "Garrett Winters", "Accountant", "Tokyo", "8422", "2011/07/25", "$170,750" ],
[ "Ashton Cox<<<<<<<<", "Junior Technical Author", "San Francisco", "1562", "2009/01/12", "$86,000" ]
];
$('#example').DataTable( {
dom: 'Bfrtip',
data: dataSet,
columns: [
{ title: "Name" },
{ title: "Position" },
{ title: "Office" },
{ title: "Extn." },
{ title: "Start date" },
{ title: "Salary" }
],
buttons: {
buttons: [
{
extend: 'excel',
title: null,
text: "Export Company",
filename: function () {
return "Mark & Tables Associated";
}
}
]
}
});
});
but it seems it truncate the "&" char.
I'm on Windows. It shouldn't be denied as char.
How can I do it?
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Hi @markzzz ,
I'd strongly recommend against that Ampersands have special meaning on UNIX, it's really best to avoid special characters in file names (I even avoid spaces) if you want your code to be portable.
That said, try a backslash, something like "a\&b" may do the trick,
Cheers,
Colin