We have a problem with non standard characters being displayed in Excel after being exported as CSV (using All Export) from WooCommerce. Example below:
However if you open the same file in Notepad, you can see that the characters are actually being exported correctly:
On this page I found that the exported file might be missing something which tells Excel to display the characters correctly, and they provided the below code to fix the issue with their particular plugin.
add_filter( 'tablepress_export_data', 'tablepress_add_bom_to_csv_exports', 10, 4 );
function tablepress_add_bom_to_csv_exports( $export_data, $table, $export_format, $csv_delimiter ) {
if ( 'csv' === $export_format ) {
$export_data = "xEFxBBxBF" . $export_data;
}
return $export_data;
}
Is there a way to modify this code to work with All Export, or with all exports in general, to fix the issue? The above example is German but the file contains all sorts of languages (as we ship globally).
Thanks
3
Answers
Make sure encoding is UTF-8, unicode which supports almost all languages, make sure to change the font that contains all these glyphs for your language.
To resolve this issue make the CSV/Excel file into a UTF-8 encoded format. Read more
I solved this problem but not in wordpress, but in Java/ Spring Webapplication by adding the UTF-8 BOM prior writing the content to the CSV. This “helps” Excel to understand that the .csv is UTF-8 encoded and thus displays “Umlauts” correctly.
If you need Code examples in Java just ask and I will add them here.