What happened?
Description
I needed to change the delimiter for the CSV exporter from comma to semicolon, because it was messing up the data imports into Excel. I could find some reference to this issue by reading this file vendor/craftcms/cms/src/web/Response.php
Steps to reproduce
- create the file
config/app.web.php with this content:
<?php
use craft\helpers\App;
use craft\helpers\ArrayHelper;
use craft\web\Response;
return [
'components' => [
'response' => fn() => Craft::createObject(ArrayHelper::merge(
App::webResponseConfig(),
[
'defaultFormatters' => [
Response::FORMAT_CSV => [
'delimiter' => ';',
],
],
]
)),
],
];
- go to control panel to an element index and export data as CSV
Note: the issue could be related to the cms/src/web/CsvResponseFormatter.php line 108
if ($this->includeHeaderRow) {
fputcsv($fp, $headers, ',');
}
instead, it should probably be:
if ($this->includeHeaderRow) {
fputcsv($fp, $headers, $this->delimiter);
}
Expected behavior
Both the headers and data rows are delimited by the same delimiter char (a semicolon in my case).
Actual behavior
The header is still using a commas as delimiter.
Craft CMS version
4.8.10
PHP version
8.1
Operating system and version
No response
Database type and version
No response
Image driver and version
No response
Installed plugins and versions
What happened?
Description
I needed to change the delimiter for the CSV exporter from comma to semicolon, because it was messing up the data imports into Excel. I could find some reference to this issue by reading this file
vendor/craftcms/cms/src/web/Response.phpSteps to reproduce
config/app.web.phpwith this content:Note: the issue could be related to the cms/src/web/CsvResponseFormatter.php line 108
instead, it should probably be:
Expected behavior
Both the headers and data rows are delimited by the same delimiter char (a semicolon in my case).
Actual behavior
The header is still using a commas as delimiter.
Craft CMS version
4.8.10
PHP version
8.1
Operating system and version
No response
Database type and version
No response
Image driver and version
No response
Installed plugins and versions