I am using Laravel Export to export an excel file of some data. When I create my query, and use dd()
to check what the data look like, everything looks good. For example:
dd($result);
array:510 [▼
0 => array:24 [▼
"abc" => "123"
"foo" => "bar"
"key" => "value"
...
"pivot" => array:4 [ …4]
1 => array:24 [▼
...
]
This is what my export method looks like:
Excel::create('my-file', function ($excel) use ($result) {
$excel->sheet('Page1', function ($sheet) use ($result) {
$sheet->fromArray(array($result));
});
})->export('xlsx');
The above generates a completely blank excel file.
I am not sure how else to troubleshoot this. It seems I am passing in good data, but getting an empty sheet back.
Grateful for any suggestions!
Try this -
Reffer this link as well -
http://www.maatwebsite.nl/laravel-excel/docs/export
forCreating a sheet from an array
Hope this will help you.