It鈥檚 fine when exporting around 1k rows without enclosure. I'm using queue export and CSV delimiter starting mess up when exporting above 4k rows. Rows and Headings contain space. I'm using Query Builder. I want to export my .csv file without enclosure.
ReportsController
class ReportsController extends Controller
{
public function export()
{
(new ReportsExport)->queue('reports.csv');
return response()->json([
'download_link' => Storage::url('reports.csv')
]);
}
}
ReportsExport
class ReportsExport implements FromQuery, WithMapping, WithHeadings, WithCustomCsvSettings
{
use Exportable;
public function query()
{
// Actually, I'm performing complex query behind the scenes
// and I do not use "get()" as the doc says...
$record = DB::table('reports')->orderBy('id', 'asc');
return $record;
}
public function map($record): array
{
return [
$record->column_1,
...
];
}
public function headings(): array
{
return [
"Heading 1"
...
];
}
public function getCsvSettings(): array
{
return [
'enclosure' => '' // no enclosure
];
}
}
I don't understand what you mean with mess up, can you show the output that you think is wrong
Without Enclosure
around 1k rows
Full Name,First Name,Last Name,Location,Email Address
John Smith Doe,John Smith,Doe,15 Street,[email protected]
Mary Chris Brown,Mary Chris,Brown,15 Aveune,[email protected]
about 4k rows
Full,Name,First,Name,Last,Name,Location,Email,Address
John,Smith,Doe,John,Smith,Doe,15,Street,[email protected],,,,,
Mary,Chris,Brown,Mary,Chris,Brown,15,Aveune,[email protected],,,,,,,
Note: Space disappears and additional commas appear at the end of the rows
Not sure. Think you can better ask on Stackoverflow. We use PhpSpreadsheet behind the scenes and I believe they just use fputcsv. Someone there might be able to explain.
Apparently there was a breaking change in PhpSpreadsheet, our next release will handle empty enclosures again. Hopefully that will also sole your problem.
Most helpful comment
Apparently there was a breaking change in PhpSpreadsheet, our next release will handle empty enclosures again. Hopefully that will also sole your problem.