Level 51
There are a few ways you could go about this.. here's one possible way:
Build an array that holds the row numbers for each group:
$excelRows = [];
foreach($prices->groups as $group){
$excelRows[] = [
$group->group_code,
$group->group_name,
$group->group_desc,
];
// add the row number to the array
$skuHeaderRows[] = count($excelRows);
...
}
After the sheet is populated with fromArray(), style the group category lines:
$excel->sheet('File Export', function ($sheet) use ($excelRows) {
$sheet->fromArray($excelRows);
// bold the column headers
$sheet->cell('A1:Z1', function ($cells) {
$cells->setFontWeight('bold');
});
foreach ($skuHeaderRows as $row)
{
$sheet->row($row, function($cells) {
// apply bold
$cells->setFontWeight('bold');
// apply background colour
$cells->setBackground('#FF0000');
});
}
...
})->download('xlsx');