SpartnerNL / Laravel-Excel

🚀 Supercharged Excel exports and imports in Laravel
https://laravel-excel.com
MIT License
12.29k stars 1.92k forks source link

[Bug]: No writer found for type xlsx #3774

Closed skfaisal93 closed 1 year ago

skfaisal93 commented 2 years ago

Is the bug applicable and reproducable to the latest version of the package and hasn't it been reported before?

What version of Laravel Excel are you using?

3.1.44

What version of Laravel are you using?

8.83.25

What version of PHP are you using?

8.0

Describe your issue

I have followed 5 minute quick start from your documentation.

While downloading the excel file I get the following error

Call to undefined method Symfony\Component\HttpFoundation\BinaryFileResponse::header()

To overcome this I have added writerType parameter to Excel::download function. So it looks like as follows

return Excel::download(new UsersExport, 'users.xlsx', 'xlsx');

This gave me following error

PhpOffice\PhpSpreadsheet\Writer\Exception
No writer found for type xlsx

How can the issue be reproduced?

  1. Follow this minute quick start guide from documentation
  2. In UserController.php, export function should look as below
public function export()
{
    return Excel::download(new UsersExport, 'users.xlsx', 'xlsx');
}
  1. Hit the route url in the browser

What should be the expected behaviour?

As per the documentation, the xlsx file should be downloaded in the dowloads folder

Naghal commented 1 year ago

Hi, you need to use 'Xlsx' with a capital X. Otherwise, you can use \Maatwebsite\Excel\Excel::XLSX

stale[bot] commented 1 year ago

This bug report has been automatically closed because it has not had recent activity. If this is still an active bug, please comment to reopen. Thank you for your contributions.