I've created an array out of an object that I'm dumping to excel with Laravel excel/PHPExcel, but I 've made an array that stores the count of rows for the top level of the $allGroupResult
array so that I can individually style those rows.
The row numbers stored in $boldRows
are the rows that I want bold and to have a different width on those cells.
How can I apply the row count from $boldRows
so that I can apply unique styling to those rows only?
$allgroupResult= array();
$rowCount = 2;
$boldRows = array();
foreach($prices->groups as $group){
//creating array items omitted
array_push($allgroupResult, $groupItem);
array_push($boldRows, $rowCount++);
foreach($group->skus as $sku){
//creating array items omitted
array_push($allgroupResult, $skuItem);
$rowCount++;
}
}
$name = 'File Export';
$build = Excel::create($name, function ($excel) use ($allgroupResult) {
$excel->setTitle('File Export');
$excel->sheet('File Export', function ($sheet) use ($allgroupResult) {
$sheet->fromArray($allgroupResult);
// Not sure how to use $boldRows count here to make bold, wider cells, etc.
$sheet->getStyle('A1:'.$sheet->getHighestColumn().'1')->getFont()->setBold(true);
}