Index: components/hidden.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/webform/components/hidden.inc,v
retrieving revision 1.19
diff -u -r1.19 hidden.inc
--- components/hidden.inc	14 Jan 2010 06:12:47 -0000	1.19
+++ components/hidden.inc	23 Jan 2010 22:52:05 -0000
@@ -169,7 +169,7 @@
 /**
  * Implementation of _webform_csv_data_component().
  */
-function _webform_csv_headers_hidden($component) {
+function _webform_csv_headers_hidden($component, $export_options) {
   $header = array();
   $header[0] = '';
   $header[1] = '';
@@ -180,6 +180,6 @@
 /**
  * Implementation of _webform_csv_data_component().
  */
-function _webform_csv_data_hidden($component, $value) {
+function _webform_csv_data_hidden($component, $export_options, $value) {
   return empty($value[0]) ? '' : $value[0];
 }
Index: components/textarea.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/webform/components/textarea.inc,v
retrieving revision 1.18
diff -u -r1.18 textarea.inc
--- components/textarea.inc	14 Jan 2010 06:12:47 -0000	1.18
+++ components/textarea.inc	23 Jan 2010 22:52:06 -0000
@@ -224,7 +224,7 @@
 /**
  * Implementation of _webform_csv_headers_component().
  */
-function _webform_csv_headers_textarea($component) {
+function _webform_csv_headers_textarea($component, $export_options) {
   $header = array();
   $header[0] = '';
   $header[1] = '';
@@ -235,6 +235,6 @@
 /**
  * Implementation of _webform_csv_data_component().
  */
-function _webform_csv_data_textarea($component, $value) {
+function _webform_csv_data_textarea($component, $export_options, $value) {
   return empty($value[0]) ? '' : $value[0];
 }
Index: components/file.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/webform/components/file.inc,v
retrieving revision 1.13
diff -u -r1.13 file.inc
--- components/file.inc	21 Jan 2010 20:11:08 -0000	1.13
+++ components/file.inc	23 Jan 2010 22:52:05 -0000
@@ -557,7 +557,7 @@
 /**
  * Implementation of _webform_csv_headers_component().
  */
-function _webform_csv_headers_file($component) {
+function _webform_csv_headers_file($component, $export_options) {
   $header = array();
   // Two columns in header.
   $header[0] = array('', '');
@@ -569,7 +569,7 @@
 /**
  * Implementation of _webform_csv_data_component().
  */
-function _webform_csv_data_file($component, $value) {
+function _webform_csv_data_file($component, $export_options, $value) {
   $file = webform_get_file($value[0]);
   return empty($file->filename) ? array('', '') : array(webform_file_url($file->filepath), (int) ($file->filesize/1024));
 }
Index: components/time.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/webform/components/time.inc,v
retrieving revision 1.21
diff -u -r1.21 time.inc
--- components/time.inc	14 Jan 2010 06:12:47 -0000	1.21
+++ components/time.inc	23 Jan 2010 22:52:06 -0000
@@ -320,7 +320,7 @@
 /**
  * Implementation of _webform_csv_headers_component().
  */
-function _webform_csv_headers_time($component) {
+function _webform_csv_headers_time($component, $export_options) {
   $header = array();
   $header[0] = '';
   $header[1] = '';
@@ -331,7 +331,7 @@
 /**
  * Implementation of _webform_csv_data_component().
  */
-function _webform_csv_data_time($component, $value) {
+function _webform_csv_data_time($component, $export_options, $value) {
   if (drupal_strlen($value[0]) > 0 && drupal_strlen($value[1]) > 0) {
     $timestamp = strtotime($value[0] .':'. $value[1] . $value[2]);
     if ($component['extra']['hourformat'] == '24-hour') {
Index: components/date.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/webform/components/date.inc,v
retrieving revision 1.21
diff -u -r1.21 date.inc
--- components/date.inc	14 Jan 2010 06:12:47 -0000	1.21
+++ components/date.inc	23 Jan 2010 22:52:05 -0000
@@ -364,7 +364,7 @@
 /**
  * Implementation of _webform_csv_headers_component().
  */
-function _webform_csv_headers_date($component) {
+function _webform_csv_headers_date($component, $export_options) {
   $header = array();
   $header[0] = '';
   $header[1] = '';
@@ -375,7 +375,7 @@
 /**
  * Implementation of _webform_csv_data_component().
  */
-function _webform_csv_data_date($component, $value) {
+function _webform_csv_data_date($component, $export_options, $value) {
   if (drupal_strlen($value[0]) > 0 && drupal_strlen($value[1]) > 0 && drupal_strlen($value[2]) > 0) {
     $timestamp = strtotime($value[0] .'/'. $value[1] .'/'. $value[2]);
     $format = webform_date_format('short');
Index: components/grid.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/webform/components/grid.inc,v
retrieving revision 1.8
diff -u -r1.8 grid.inc
--- components/grid.inc	14 Jan 2010 06:12:47 -0000	1.8
+++ components/grid.inc	23 Jan 2010 22:52:05 -0000
@@ -322,7 +322,7 @@
 /**
  * Implementation of _webform_csv_headers_component().
  */
-function _webform_csv_headers_grid($component) {
+function _webform_csv_headers_grid($component, $export_options) {
   $header = array();
   $header[0] = array('');
   $header[1] = array($component['name']);
@@ -345,7 +345,7 @@
 /**
  * Implementation of _webform_csv_data_component().
  */
-function _webform_csv_data_grid($component, $value) {
+function _webform_csv_data_grid($component, $export_options, $value) {
   $questions = array_keys(_webform_grid_options($component['extra']['questions']));
   $return = array();
   foreach ($questions as $key => $question) {
Index: components/select.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/webform/components/select.inc,v
retrieving revision 1.31
diff -u -r1.31 select.inc
--- components/select.inc	23 Jan 2010 06:25:09 -0000	1.31
+++ components/select.inc	23 Jan 2010 22:52:06 -0000
@@ -459,14 +459,14 @@
 /**
  * Implementation of _webform_csv_headers_component().
  */
-function _webform_csv_headers_select($component) {
+function _webform_csv_headers_select($component, $export_options) {
   $headers = array(
     0 => array(),
     1 => array(),
     2 => array(),
   );
 
-  if ($component['extra']['multiple']) {
+  if ($component['extra']['multiple'] && $export_options['select_format'] == 'separate') {
     $headers[0][] = '';
     $headers[1][] = $component['name'];
     $items = _webform_select_options($component['extra']['items'], TRUE);
@@ -492,16 +492,16 @@
 /**
  * Implementation of _webform_csv_data_component().
  */
-function _webform_csv_data_select($component, $value) {
+function _webform_csv_data_select($component, $export_options, $value) {
   $options = _webform_select_options($component['extra']['items'], TRUE);
   $return = array();
 
   if ($component['extra']['multiple']) {
     foreach ($options as $key => $item) {
       if (in_array($key, (array) $value) === TRUE) {
-        $return[] = 'X';
+        $return[] = ($export_options['select_format'] == 'separate') ? 'X' : $key;
       }
-      else {
+      elseif ($export_options['select_format'] == 'separate') {
         $return[] = '';
       }
     }
@@ -509,6 +509,11 @@
   else {
     $return = $value[0];
   }
+
+  if ($component['extra']['multiple'] && $export_options['select_format'] == 'compact') {
+    $return = implode(',', (array) $return);
+  }
+
   return $return;
 }
 
Index: components/textfield.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/webform/components/textfield.inc,v
retrieving revision 1.18
diff -u -r1.18 textfield.inc
--- components/textfield.inc	14 Jan 2010 06:12:47 -0000	1.18
+++ components/textfield.inc	23 Jan 2010 22:52:06 -0000
@@ -246,7 +246,7 @@
 /**
  * Implementation of _webform_csv_headers_component().
  */
-function _webform_csv_headers_textfield($component) {
+function _webform_csv_headers_textfield($component, $export_options) {
   $header = array();
   $header[0] = '';
   $header[1] = '';
@@ -257,6 +257,6 @@
 /**
  * Implementation of _webform_csv_data_component().
  */
-function _webform_csv_data_textfield($component, $value) {
+function _webform_csv_data_textfield($component, $export_options, $value) {
   return !isset($value[0]) ? '' : $value[0];
 }
Index: components/email.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/webform/components/email.inc,v
retrieving revision 1.25
diff -u -r1.25 email.inc
--- components/email.inc	14 Jan 2010 06:12:47 -0000	1.25
+++ components/email.inc	23 Jan 2010 22:52:05 -0000
@@ -244,7 +244,7 @@
 /**
  * Implementation of _webform_csv_headers_component().
  */
-function _webform_csv_headers_email($component) {
+function _webform_csv_headers_email($component, $export_options) {
   $header = array();
   $header[0] = '';
   $header[1] = '';
@@ -255,6 +255,6 @@
 /**
  * Implementation of _webform_csv_data_component().
  */
-function _webform_csv_data_email($component, $value) {
+function _webform_csv_data_email($component, $export_options, $value) {
   return empty($value[0]) ? '' : $value[0];
 }
Index: webform.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/webform/webform.module,v
retrieving revision 1.161
diff -u -r1.161 webform.module
--- webform.module	23 Jan 2010 06:25:09 -0000	1.161
+++ webform.module	23 Jan 2010 22:52:04 -0000
@@ -542,6 +542,10 @@
       'arguments' => array('form' => NULL),
       'file' => 'includes/webform.report.inc',
     ),
+    'webform_results_download_select_format' => array(
+      'arguments' => array('element' => NULL),
+      'file' => 'includes/webform.report.inc',
+    ),
     // webform.submissions.inc
     'webform_submission_page' => array(
       'arguments' => array('submission' => NULL, 'submission_navigation' => NULL, 'submission_information' => NULL),
Index: webform_hooks.php
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/webform/webform_hooks.php,v
retrieving revision 1.4
diff -u -r1.4 webform_hooks.php
--- webform_hooks.php	21 Jan 2010 22:58:22 -0000	1.4
+++ webform_hooks.php	23 Jan 2010 22:52:05 -0000
@@ -470,11 +470,13 @@
  *
  * @param $component
  *   A Webform component array.
+ * @param $export_options
+ *   An array of options that may configure export of this field.
  * @return
  *   An array of data to be displayed in the first three rows of a CSV file, not
  *   including either prefixed or trailing commas.
  */
-function _webform_csv_headers_component($component) {
+function _webform_csv_headers_component($component, $export_options) {
   $header = array();
   $header[0] = array('');
   $header[1] = array($component['name']);
@@ -502,6 +504,8 @@
  *
  * @param $component
  *   A Webform component array.
+ * @param $export_options
+ *   An array of options that may configure export of this field.
  * @param $value
  *   An array of information containing the submission result, directly
  *   correlating to the webform_submitted_data database schema.
@@ -510,7 +514,7 @@
  *   will be another column within the file. This function is called once for
  *   every row of data.
  */
-function _webform_csv_data_component($component, $value) {
+function _webform_csv_data_component($component, $export_options, $value) {
   $questions = array_keys(_webform_select_options($component['extra']['questions']));
   $return = array();
   foreach ($questions as $key => $question) {
Index: webform.css
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/webform/webform.css,v
retrieving revision 1.8
diff -u -r1.8 webform.css
--- webform.css	23 Jan 2010 06:25:09 -0000	1.8
+++ webform.css	23 Jan 2010 22:52:03 -0000
@@ -29,6 +29,15 @@
   height: 12px;
   margin: 0 2px 2px;
 }
+.webform-select-list-format table {
+  border: 1px solid;
+  width: auto;
+  font-size: 90%;
+}
+.webform-select-list-format td,
+.webform-select-list-format th {
+  border: 1px solid;
+}
 .webform-checkbox {
   text-align: center;
   width: 40px;
Index: includes/webform.report.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/webform/includes/webform.report.inc,v
retrieving revision 1.12
diff -u -r1.12 webform.report.inc
--- includes/webform.report.inc	23 Jan 2010 06:25:09 -0000	1.12
+++ includes/webform.report.inc	23 Jan 2010 22:52:06 -0000
@@ -350,6 +350,25 @@
     ),
   );
 
+  $form['select_options'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Select list options'),
+    '#collapsible' => TRUE,
+    '#collapsed' => TRUE,
+  );
+
+  $form['select_options']['select_format'] = array(
+    '#type' => 'radios',
+    '#title' => t('Select list format'),
+    '#options' => array(
+      'separate' => t('Separate'),
+      'compact' => t('Compact'),
+    ),
+    '#default_value' => 'separate',
+    '#attributes' => array('class' => 'webform-select-list-format'),
+    '#theme' => 'webform_results_download_select_format',
+  );
+
   $csv_components = array(
     '' => t('Submission information'),
     'serial' => '-' . t('Submission Number'),
@@ -384,6 +403,7 @@
   $options = array(
     'delimiter' => $form_state['values']['delimiter'],
     'components' => array_keys(array_filter($form_state['values']['components'])),
+    'select_format' => $form_state['values']['select_format'],
   );
   webform_results_download($form_state['values']['node'], $form_state['values']['format'], $options);
 }
@@ -398,6 +418,44 @@
 }
 
 /**
+ * Theme the output of the select list format radio buttons.
+ */
+function theme_webform_results_download_select_format($element) {
+  drupal_add_css(drupal_get_path('module', 'webform') .'/webform.css', 'theme', 'all', FALSE);
+
+  $output = '';
+
+  // Build an example table for the separate option.
+  $header = array(t('Option A'), t('Option B'), t('Option C'));
+  $rows = array(
+    array('X', '', ''),
+    array('X', '', 'X'),
+    array('', 'X', 'X'),
+  );
+
+  $element['separate']['#description'] = theme('table', $header, $rows);
+  $element['separate']['#description'] .= t('Separate options are more suitable for building reports, graphs, and statistics in a spreadsheet application.');
+  $output .= drupal_render($element['separate']);
+
+  // Build an example table for the compact option.
+  $header = array(t('My select list'));
+  $rows = array(
+    array('Option A'),
+    array('Option A,Option C'),
+    array('Option B,Option C'),
+  );
+
+  $element['compact']['#description'] = theme('table', $header, $rows);
+  $element['compact']['#description'] .= t('Compact options are more suitable for importing data into other systems.');
+  $output .= drupal_render($element['compact']);
+
+  $element['#type'] = 'markup';
+  $element['#value'] = $output;
+
+  return $output;
+}
+
+/**
  * Generate a Excel-readable CSV file containing all submissions for a Webform.
  *
  * The CSV requires that the data be presented in a flat file.  In order
@@ -445,6 +503,7 @@
     $options = array(
       'delimiter' => variable_get('webform_csv_delimiter', '\t'),
       'components' => array_keys($submission_information) + array_keys(webform_component_list($node, 'csv', TRUE)),
+      'select_format' => 'separate',
     );
   }
   else {
@@ -478,7 +537,7 @@
       $component = $node->webform['components'][$cid];
 
       // Let each component determine its headers.
-      if ($component_header = webform_component_invoke($component['type'], 'csv_headers', $component)) {
+      if ($component_header = webform_component_invoke($component['type'], 'csv_headers', $component, $options)) {
         $header[0] = array_merge($header[0], (array) $component_header[0]);
         $header[1] = array_merge($header[1], (array) $component_header[1]);
         $header[2] = array_merge($header[2], (array) $component_header[2]);
@@ -524,7 +583,7 @@
         $component = $node->webform['components'][$cid];
         // Let each component add its data.
         $raw_data = isset($submission->data[$cid]['value']) ? $submission->data[$cid]['value'] : NULL;
-        $data = webform_component_invoke($component['type'], 'csv_data', $component, $raw_data);
+        $data = webform_component_invoke($component['type'], 'csv_data', $component, $options, $raw_data);
         if ($data !== NULL) {
           if (is_array($data)) {
             $row = array_merge($row, array_values($data));
