Skip to content
Advertisement

Export array to Excelwith MaatwebsiteExcel

I am beginner web developer. I make my project with use Laravel 8 and Maatwebsite Excel.

I make this code to prepare data to save to excel file:

JavaScript

Generate data work fine.

My debug return this:

JavaScript

I have problem with save my data to excel file. When I run my code I have downloaded empty file (without my data).

How can I make repair it?

Please help me.

Advertisement

Answer

Try to remove your filename and content type :

JavaScript

EDIT: according to the official documentation, the only way you can export is via FromCollection :

The easiest way to start an export is to create a custom export class. We’ll use an invoices export as example.

JavaScript

In your controller we can now download this export:

JavaScript

If you try to export any other way you will get an empty set.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement