skip to Main Content

We have a problem with non standard characters being displayed in Excel after being exported as CSV (using All Export) from WooCommerce. Example below:

enter image description here

However if you open the same file in Notepad, you can see that the characters are actually being exported correctly:

enter image description here

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


  1. 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.

    Login or Signup to reply.
  2. To resolve this issue make the CSV/Excel file into a UTF-8 encoded format. Read more

    Login or Signup to reply.
  3. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search