Export to excel or csv with Greek Letter
Export to excel or csv with Greek Letter
sarooptrivedi
Posts: 62Questions: 19Answers: 2
I have special Greek letter in my table header.
<th>Total Eff α</th>
in csv export alpha and beta replace with garbage value with Total Eff α
How to render the special greek character in header
you can find the HTML entity for the greek letter alpha on below link
javascripter.net/faq/greekletters.htm
HTML code for alpha
https://w3schools.com/charsets/tryit.asp?deci=945&ent=alpha
My Jquery Code
{
extend: 'csv',
titleAttr: 'csv',
autoFilter: true,
sheetName: 'Exported data',
exportOptions: {
columns: ':visible',
charset: 'UTF-8',
format: {
header: function (data, row, column, node) {
if (data == "Total α") {
return data.replace("α","α");
}
}
}
}
},
This question has an accepted answers - jump to answer
Answers
I found the issue as well.
In Buttons.html5.js lines 968 to 972 line
_saveAs(
new Blob( [output], {type: 'text/csv'+charset} ),
info.filename,
true
);
Hi,
I'm not entirely clear on what the issue with the code there is (i.e. how did you identify that as the problem)? I'm wondering if it would work if you had
charset: '; charset=UTF-8'
?Allan
I tried this and its worked
The
bom
option is what made the difference? Surprising! What text editor are you using?Allan
Guys, I can confirm that. I don't have Greek but special German letters such as ä ö ü Ä Ö Ü ß.
For the CSV export I use this. I definitely needed the "bom" option to make it work. (The value of the field separator and the filename depend on the user language.)
How interesting! I used to have the BOM option enabled by default, but got lots of complaints because some editors actually tried to render it rather than correctly seeing it as a BOM. The whole BOM handling is just a mess!
I tend to use VSCode and it picks up text files as UTF-8 by default for me (with or without a BOM).
Allan
I am using Visual studio 2022
My users are opening those csv files with MS Excel. For that to work the BOM option was required.