Users are complaining that Excel 2008 (Mac) and 2007 (PC) cannot simply open CSV files exported by 2.6. Doing this causes Excel to think all of the data is part of the first column.

The workaround is to use File->Import and then tell it to use the correct delimiters, but this is cumbersome.

Why is the UTF-8 BOF being prepended to CSV files, anyway? If I use this patch, things work as expected:

--- webform/.svn/text-base/webform_export.inc.svn-base  2009-02-26 16:45:45.0000
00000 -0500
+++ webform/webform_export.inc  2009-04-13 09:54:41.000000000 -0400
@@ -106,11 +106,11 @@ class webform_exporter_delimited extends
   function bof(&$file_handle) {
     $output = '';
 
     // Include at BOM at the beginning of the file for Little Endian.
     // This makes tab-separated imports work correctly in MS Excel.
-    if (function_exists('mb_convert_encoding')) {
+    if (function_exists('mb_convert_encoding') && $this->delimiter == '\t') {
       $output = chr(255) . chr(254);
     }
     @fwrite($file_handle, $output);
   }

Comments

amir simantov’s picture

subscribing

quicksketch’s picture

Version: 6.x-2.6 » 6.x-2.9
Status: Active » Fixed

Thanks Gribnif, I finally got around to testing this and it definitely fixes problems with CSV downloads. I've committed to all branches.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

roball’s picture

I don't understand how this could work since '\t' actually had to be "\t" (see #751670: Encoding problems with non-latin language when exporting results as Excel file).

heine’s picture

Title: UTF-8 BOF in CSV export confuses Excel » UTF-16 LE BOF in CSV export confuses Excel

FF FE is not a UTF-8 Byte Order Mark, but the UTF-16 Byte Order Mark (Little Endian).

heine’s picture

Title: UTF-16 LE BOF in CSV export confuses Excel » UTF-16 LE BOM in CSV export confuses Excel