The views_data_export.module does not output multivalue fields cleanly in .xls and .csv files. Mostly these values are separated into several lines or appended without any separator.
A final fix in the module is not available (at least for Drupal 6) in the current state. So here's a simple workaroud providing a lot of flexibility:
Simply export as .xls (Excel) - you can easily export as .csv via Excel later on. Group multiple values using the checkbox in the field (for example taxonomy value).
Rename the exported .xls file to .html - it contains simple HTML.
Open the file in your Browser (in my case Firefox) and add jQuery (I'm using the FireQuery Extensions "jQueryfi" functionality as one-click solution).
Simply execute the following jQuery script in the browsers console. If you'd like to use a different separator simply change the variable value.
Copy the resulting table into excel. Now you can save it as .csv or whatever you'd like to :)
var valSeparator = '|';
jQuery('tr').each(function(){
var $row = $(this);
jQuery('td').each(function(){
var $rowcol = $(this);
var $content = $(this).find('div.field-item');
if($(this).find('div.field-item').length > 0){
$content.each(function(){
var fieldtext = $(this).text();
$rowcol.append(fieldtext + valSeparator);
$(this).remove();
});
// Remove ending separatorts
if($rowcol.text().substr(-1,1)==valSeparator){
$rowcol.text($rowcol.text().substr(0,$rowcol.text().length - 1));
}
}
});
});
Happy coding!
PS: If you want to remove all HTML elements, this snippet may help:
var valSeparator = '|';
jQuery('tr').each(function(){
var $row = $(this);
jQuery('td').each(function(){
var $rowcol = $(this);
var $content = $(this).find('div.field-item');
if($content.find('div.field-item').length > 0){
$content.each(function(){
var fieldtext = $(this).text();
$rowcol.append(fieldtext + valSeparator);
$(this).remove();
});
// Remove ending separatorts
if($rowcol.text().substr(-1,1)==valSeparator){
$rowcol.text($rowcol.text().substr(0,$rowcol.text().length - 1));
}
}
var $paragraph = $(this).find('*');
if($paragraph.find('*').length > 0){
$paragraph.each(function(){
var fieldtext = $(this).text();
$rowcol.append(fieldtext + valSeparator);
$(this).remove();
});
// Remove ending separatorts
if($rowcol.text().substr(-1,1)==valSeparator){
$rowcol.text($rowcol.text().substr(0,$rowcol.text().length - 1));
}
}
$(this).text($(this).text().replace(/(\r\n|\n|\r)/gm,"").trim());
});
});