You are here

protected function WebformSubmissionExportImportImporter::exportValue in Webform 6.x

Same name and namespace in other branches
  1. 8.5 modules/webform_submission_export_import/src/WebformSubmissionExportImportImporter.php \Drupal\webform_submission_export_import\WebformSubmissionExportImportImporter::exportValue()

Export value so that it can be editted in Excel and Google Sheets.

Parameters

string $value: A value.

Return value

string A value that it can be editted in Excel and Googl Sheets.

1 call to WebformSubmissionExportImportImporter::exportValue()
WebformSubmissionExportImportImporter::exportSubmission in modules/webform_submission_export_import/src/WebformSubmissionExportImportImporter.php
Export webform submission as a CSV record.

File

modules/webform_submission_export_import/src/WebformSubmissionExportImportImporter.php, line 1180

Class

WebformSubmissionExportImportImporter
Webform submission export importer.

Namespace

Drupal\webform_submission_export_import

Code

protected function exportValue($value) {

  // Prevent Excel and Google Sheets from convert string beginning with
  // + or - into formulas by adding a space before the string.
  // @see https://stackoverflow.com/questions/4438589/bypass-excel-csv-formula-conversion-on-fields-starting-with-or
  if (is_string($value) && strpos($value, '+') === 0 || strpos($value, '-') === 0) {
    return ' ' . $value;
  }
  else {
    return $value;
  }
}