protected function WebformSubmissionExportImportImporter::exportValue in Webform 8.5
Same name and namespace in other branches
- 6.x 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 1186
Class
- WebformSubmissionExportImportImporter
- Webform submission export import manager.
Namespace
Drupal\webform_submission_export_importCode
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;
}
}