This is:
- [x] a bug report
- [ ] a feature request
- [x] **not** a usage question
When enclosure is set to empty string, no enclosure should be written to CSV.
Empty enclosure is changed to double quotes in PhpOffice\PhpSpreadsheet\Writer\Csv::setEnclosure(). Code was recently changed from
if ($pValue == '') {
$pValue = null;
}
$this->enclosure = $pValue;
to
$this->enclosure = $pValue ? $pValue : '"';
and now changes empty string to double quotes.
<?php
require __DIR__ . '/vendor/autoload.php';
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
$writer = new \PhpOffice\PhpSpreadsheet\Writer\Csv($spreadsheet);
$writer->setEnclosure('');
1.13.0
Change has not been documented in the Changelog.
My apologies - it was my pull request that introduced this change. It did not break any existing tests. and I don't understand your use case. Can you please give me a testable example of how you are using this so that I can revert this behavior and add an appropriate test.
I am actually using Laravel Excel, where the CSV configuration parameters are only passed to phpspreadsheet.
Basically all I want to do is generate a CSV file without enclosures, such as this:
2020-06-03;000123;06.53;14.22
2020-06-03;000234;07.12;15.44
...
I used to achieve this using $writer->setEnclosure('');, but this now sets enclosure to " and I get such content:
"2020-06-03";"000123";"06.53";"14.22"
"2020-06-03";"000234";"07.12";"15.44"
...
_CSV files that my app generates are imported in another app. That app doesn't allow enclosures so files can't be imported. I know ..._ :roll_eyes:
@oleibman are there any plans to merge it back any time soon?
I would love an update for plans to merge for this as well.
Temporarily downgrading to 1.12.0 solves the issue
$ composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 0 installs, 1 update, 0 removals
Most helpful comment
@oleibman are there any plans to merge it back any time soon?