I had troubles getting correct csv export with our special german and french chars like äöü éè etc. to display correctly in output
So i changed following in code and it works for me perfectly, but as i am absolutely drupal beginner, I hope any of you professionals can review it.

file webform_report.inc
~line 865: required other delimiter for my excel2010 to recognize automatically
$output .= implode(',', $tmp) . "\n";
to new
$output .= implode(';', $tmp) . "\n";

~line 862-864: required to convert characters correctly
foreach($row as $cell) {
$tmp[] = _webform_report_format_csv_column(strip_tags($cell['data']));
}
to new
foreach($row as $cell) {
if (function_exists('mb_convert_encoding')) {
$tmp[] = _webform_report_format_csv_column(strip_tags(mb_convert_encoding($cell['data'], 'UTF-16LE', 'UTF-8')));
}
else {
$tmp[] = _webform_report_format_csv_column(strip_tags($cell['data']));
}
}

~line 857: same for header
$output .= implode(',', $tmp) . "\n";
to new
$output .= implode(';', $tmp) . "\n";

~line 854-856
foreach($headers as $header) {
$tmp[] .= _webform_report_format_csv_column($header['data']);
}
to new
foreach($headers as $header) {
if (function_exists('mb_convert_encoding')) {
$tmp[] .= _webform_report_format_csv_column(mb_convert_encoding($header['data'], 'UTF-16LE', 'UTF-8'));
}
else {
$tmp[] .= _webform_report_format_csv_column($header['data']);
}
}

CommentFileSizeAuthor
#5 945396.patch15.64 KBjimbullington

Comments

jimbullington’s picture

Thank you for contributing this patch - it looks good. However, I do not have experience nor the test environment to review this - perhaps others more qualified will review it.
Also, I would like to see if we can come up with some sort of administrative setup for this behavior - instead of hard coding the delimiter.

sw3b’s picture

Version: 6.x-2.0-beta4 » 6.x-2.0-rc1
Category: feature » bug
Priority: Minor » Normal

Hey any news on this issue ! The patch does not work ! The special charaters does not follow in Excel on export.

Thanks !

sw3b’s picture

Status: Needs review » Patch (to be ported)

OK, we got a correction for you !

On line 1218
Replace:
$tmp[] .= _webform_report_format_csv_column($header['data']);
By:
$tmp[] .= _webform_report_format_csv_column(mb_convert_encoding($header['data'], 'UTF-16LE', 'UTF-8'));

On line 1233
Replace:
$data = strip_tags($cell['data']);
By:
$data = strip_tags(mb_convert_encoding($cell['data'], 'UTF-16LE', 'UTF-8'));

jimbullington’s picture

Thank you for the export code. However, I think this needs to be an option (plain text, or excel) similar to what is done in webforms. I will try to come up with the option form in the next couple of days.

jimbullington’s picture

Status: Patch (to be ported) » Needs review
StatusFileSize
new15.64 KB

Try the attached patch.

sw3b’s picture

Wow ! Nice work ! It work great !

I think you should put this in DEV !

Thanks !

jimbullington’s picture

Status: Needs review » Fixed

Committed to CVS - should be available in the next dev build.

Status: Fixed » Closed (fixed)

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