I am generating a query through laravel excel but my problem is that I need to set the color of the font to the first cell and all the examples I have seen are to set the type of font, background, alignment, size, etc. . I appreciate your help, I leave the code of my query in laravel excel
if (count($request->parametros) != 0){
$Consolidacion = Precebo::select(
'año_traslado',
DB::raw('avg(edad_destete) as edad_inicial'),
DB::raw("avg(edad_final - edad_destete) as dias_permanecia"),
DB::raw('avg(edad_final) as edad_final'),
DB::raw('sum(numero_inicial) as t_numero_inicial'),
DB::raw('sum(numero_final) as numero_final'),
DB::raw('sum(numero_muertes) as numero_muertes'),
DB::raw('sum(numero_descartes) as numero_descartes'),
DB::raw('avg(porciento_mortalidad) as promedio_mortalidad'),
DB::raw('sum(peso_ini) as total_peso_ini'),
DB::raw('sum(peso_fin) as total_peso_fin'),
DB::raw('avg(peso_promedio_ini) as promedio'),
DB::raw('avg(peso_promedio_fin) as total_peso_promedio_fin'),
DB::raw('sum(ato_promedio_fin) as total_ato_promedio_fin'),
DB::raw('avg(ato_promedio_dia_fin) as total_ato_promedio_dia_fin'),
DB::raw("avg(peso_fin - peso_ini) as total_ganancia_lote"),
DB::raw('sum(cons_total) as total_cons_total'),
DB::raw('avg(cons_promedio_dia) as total_cons_promedio_dia'),
DB::raw('avg(cons_promedio_dia_ini) as total_cons_promedio_dia_ini'),
DB::raw('avg(conversion_ajust_fin) as total_conversion_ajust_fin')
)
->where('granja_id',$request->granja)
->where('año_traslado',[$request->ano])
->whereIn('mes_traslado',$request->parametros)
->get();
$Consolidacion=json_decode(json_encode($Consolidacion),true);
$titulo = 'Consolidacon Mensual Precebo';
Excel::create($titulo, function($excel) use ($titulo, $Consolidacion){
$excel->setTitle($titulo);
$excel->setDescription('Tabla de las granjas');
$excel->sheet('Granjas', function($sheet) use ($titulo, $Consolidacion){
$sheet->fromArray($Consolidacion, null, 'A1', true);
$sheet->setAutoSize(true);
$sheet->setFontSize(13);
$sheet->setFreeze('A2');
$sheet->row(1, array(
'Año Traslado','EDAD INICIAL', 'DIAS DE PERMANENCIA', 'EDAD FINAL','N° INICIAL DE ANIMALES','N° FINAL DE ANIMALES','N° MUERTOS DE ANIMALES','N° DESCARTES DE ANIMALES','% MORTALIDAD','PESO TOTAL INICIAL','PESO PROMEDIO INICIAL(KG)','PESO TOTAL FINAL(KG)','PESO PROMEDIO FINAL (KG)','GANANCIA DE PESO TOTAL DEL LOTE','GANANCIA DE PESO TOTAL POR ANIMAL','GANANCIA DE PESO POR ANIMAL DIA','CONSUMO TOTAL DEL LOTE','CONSUMO TOTAL POR ANIMAL','CONSUMO TOTAL POR ANIMAL DIA',
));
$sheet->row(1, function($row) {
$row->setBackground('#df0101');
$row->setFontWeight('bold');
$row->setAlignment('center');
});
});
})->export("xls");
}else{
$Consolidacion = Precebo::select(
'año_traslado',
DB::raw('avg(edad_destete) as edad_inicial'),
DB::raw("avg(edad_final - edad_destete) as dias_permanecia"),
DB::raw('avg(edad_final) as edad_final'),
DB::raw('sum(numero_inicial) as t_numero_inicial'),
DB::raw('sum(numero_final) as numero_final'),
DB::raw('sum(numero_muertes) as numero_muertes'),
DB::raw('sum(numero_descartes) as numero_descartes'),
DB::raw('avg(porciento_mortalidad) as promedio_mortalidad'),
DB::raw('sum(peso_ini) as total_peso_ini'),
DB::raw('sum(peso_fin) as total_peso_fin'),
DB::raw('avg(peso_promedio_ini) as promedio'),
DB::raw('avg(peso_promedio_fin) as total_peso_promedio_fin'),
DB::raw('sum(ato_promedio_fin) as total_ato_promedio_fin'),
DB::raw('avg(ato_promedio_dia_fin) as total_ato_promedio_dia_fin'),
DB::raw("avg(peso_fin - peso_ini) as total_ganancia_lote"),
DB::raw('sum(cons_total) as total_cons_total'),
DB::raw('avg(cons_promedio_dia) as total_cons_promedio_dia'),
DB::raw('avg(cons_promedio_dia_ini) as total_cons_promedio_dia_ini'),
DB::raw('avg(conversion_ajust_fin) as total_conversion_ajust_fin')
)
->where('granja_id',$request->granja)
->where('año_traslado',[$request->ano])
->get();
$Consolidacion=json_decode(json_encode($Consolidacion),true);
$titulo = 'Consolidacion Anual de Precebo';
Excel::create($titulo, function($excel) use ($titulo, $Consolidacion){
$excel->setTitle($titulo);
$excel->setDescription('Tabla de las granjas');
$excel->sheet('Granjas', function($sheet) use ($titulo, $Consolidacion){
$sheet->fromArray($Consolidacion, null, 'A1', true);
$sheet->setAutoSize(true);
$sheet->setFontSize(13);
$sheet->setFreeze('A2');
$sheet->row(1, array(
'Año Traslado','EDAD INICIAL', 'DIAS DE PERMANENCIA', 'EDAD FINAL','N° INICIAL DE ANIMALES','N° FINAL DE ANIMALES','N° MUERTOS DE ANIMALES','N° DESCARTES DE ANIMALES','% MORTALIDAD','PESO TOTAL INICIAL','PESO PROMEDIO INICIAL(KG)','PESO TOTAL FINAL(KG)','PESO PROMEDIO FINAL (KG)','GANANCIA DE PESO TOTAL DEL LOTE','GANANCIA DE PESO TOTAL POR ANIMAL','GANANCIA DE PESO POR ANIMAL DIA','CONSUMO TOTAL DEL LOTE','CONSUMO TOTAL POR ANIMAL','CONSUMO TOTAL POR ANIMAL DIA',
));
$sheet->row(1, function($row) {
$row->setBackground('#df0101');
$row->setFontWeight('bold');
$row->setAlignment('center');
});
});
})->export("xls");
}