I've been using laravel excel to download array data for a few weeks and all of a sudden today, the download won't open.
It gives an incorrect extension type (xlsx) and says it may be corrupted.
There is no whitespace before my <?php
tag and there is no closing tag at all. No changes have been made to the file and the downloads were working otherwise. Is there a reason this would occur now? Is it possible it has to do with the output buffer?
I really don't want to store and return download but I want to keep it as Excel.
Maybe there's something that's clear here
public function exportCatalog($id, $company){
$allgroupResult= array();
$rowCount = 2;
$boldRows = array();
$name = 'Export For ' . $id . ' Company ' . $company;
$build = Excel::create($name, function ($excel) use ($allgroupResult) {
$excel->setTitle('Catalog Export');
$excel->sheet('Catalog Export', function ($sheet) use ($allgroupResult) {
$sheet->fromArray($allgroupResult);
foreach ( $boldRows as $row ) {
$cell_name = excelColumnFromNumber($row)."1";
$sheet->getStyle( $cell_name )->getFont()->setBold( true );
}
// freeze the header row
$sheet->freezeFirstRow();
// set header names
$sheet->row(1, [
'Product Images',
'Product Images',
'Product Images',
'Product Images',
'Product Images',
'Product Images',
'Product Images',
'Product Images',
'Product Images',
]); // column headers
// set the width for the columns that are used
$sheet->setWidth('A', 10);
$sheet->setWidth('B', 15);
$sheet->setWidth('C', 10);
$sheet->setWidth('D', 10);
$sheet->setWidth('E', 10);
$sheet->setWidth('F', 10);
$sheet->setWidth('G', 10);
$sheet->setWidth('H', 60);
$sheet->setWidth('I', 10);
});
})->download('xlsx');
}