Level 12
What's in $codeArray prior to creating the excel doc?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I'm trying to use Laravel Excel to export an array into an excel file. However, if there are 10 elements in the array Laravel Excel exports the excel file with the 10 items, but an empty row in between each one. I can't seem to figure out what I'm doing wrong.
Here is my code for exporting the excel file:
Excel::create($filename, function($excel) use ($codeArray){
$excel->sheet('Sheetname', function($sheet) use ($codeArray){
foreach($codeArray as $key => $code)
{
$sheet->fromArray(array(
array($code)
));
}
});
})->download('xls');
Thank you in advance for the help.
What's in $codeArray prior to creating the excel doc?
Please or to participate in this conversation.