I want to download excel file from array with Laravel
Library:
use Maatwebsite\Excel\Facades\Excel;
This is my code:
$ex = [
['one', 'name'],
['two', 'family']
];
return Excel::download(new TestExport([$ex]), 'test.xlsx');
My class:
class TestExport
{
protected $arrays;
public function __construct(array $arrays)
{
$this->arrays = $arrays;
}
public function array(): array
{
return $this->arrays;
}
}
But this code download empty xlsx file
Maatwebsite\Excel\Facades\Excel;