Skip to content

Commit a4c7a71

Browse files
authored
Merge pull request #2796 from nextcloud/backport/2772/stable4
[stable4] fix: properly set string values in exports to escape formulas
2 parents 788f76d + 753dadb commit a4c7a71

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

lib/Service/SubmissionService.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -318,11 +318,12 @@ private function exportData(array $header, array $data, string $fileFormat, ?Fil
318318
->getAlignment()
319319
->setWrapText(true);
320320
} else {
321-
$activeWorksheet->setCellValue([$column, $row], $value);
322-
323-
// Quote cell values that start with '=' to prevent evaluation of formulas
321+
// Explicitly set the type of the value to string for values that start with '=' to prevent it being interpreted as formulas
324322
if (is_string($value) && str_starts_with($value, '=')) {
325-
$activeWorksheet->getCell([$column, $row])->getStyle()->setQuotePrefix(true);
323+
$activeWorksheet->getCell([$column, $row])
324+
->setValueExplicit($value);
325+
} else {
326+
$activeWorksheet->setCellValue([$column, $row], $value);
326327
}
327328
}
328329
}

0 commit comments

Comments
 (0)