Open dfe-dev opened 2 years ago
This is the function from the Livewire component:
public function queryExport($format) { if($format == 'Xlsx') {
// Export all
return (new FastExcel(Sello::all()))->download('sellos.xlsx');
}
}
Now I get a download, but the file has another name: download.txt, instead of "sellos.xlsx"
try this:
return response()->streamDownload(function () { return (new FastExcel(Sello::all())) ->export('php://output'); }, sprintf('sellos-%s.xlsx', date('Y-m-d')));
try this:
return response()->streamDownload(function () { return (new FastExcel(Sello::all())) ->export('php://output'); }, sprintf('sellos-%s.xlsx', date('Y-m-d')));
But CSV download seems so unfortunately not possible
try this:
return response()->streamDownload(function () { return (new FastExcel(Sello::all())) ->export('php://output'); }, sprintf('sellos-%s.xlsx', date('Y-m-d')));
the same problem with download.txt
$list = collect([
[ 'id' => 1, 'name' => 'Jane' ],
[ 'id' => 2, 'name' => 'John' ],
]);
return response()->streamDownload(function () {
return (new FastExcel($list))
->export('php://output');
}, sprintf('leads-%s.xlsx', date('Y-m-d')));
google chrome return ERR_INVALID_RESPONSE
Laravel v10.17.1 (PHP v8.1.9) "livewire/livewire": "^2.12", "rap2hpoutre/fast-excel": "^5.2"
try this: return response()->streamDownload(function () { return (new FastExcel(Sello::all())) ->export('php://output'); }, sprintf('sellos-%s.xlsx', date('Y-m-d')));
the same problem with download.txt
$list = collect([ [ 'id' => 1, 'name' => 'Jane' ], [ 'id' => 2, 'name' => 'John' ], ]); return response()->streamDownload(function () { return (new FastExcel($list)) ->export('php://output'); }, sprintf('leads-%s.xlsx', date('Y-m-d')));
google chrome return ERR_INVALID_RESPONSE
Laravel v10.17.1 (PHP v8.1.9) "livewire/livewire": "^2.12", "rap2hpoutre/fast-excel": "^5.2"
return response()->streamDownload(function () {
$list = collect([
[ 'id' => 1, 'name' => 'Jane' ],
[ 'id' => 2, 'name' => 'John' ],
]);
return (new FastExcel($list))
->export('php://output');
}, sprintf('leads-%s.xlsx', date('Y-m-d')));
solved
I'm using fast-excel 3.2.0 and Laravel v8.28.1. When I try the basic code to export all users, nothing happens. No file downloaded. I'm calling the class from a Livewire component. Should I add something else to make this component work?
Best regards.