php - Laravel export xls cell style dependent of value -


i trying export xls laravel using "maatwebsite / excel": "~ 2.1.0".

the first thing query oventer data

$disponibilidadi = db::table('users_dis')->select('*', 'users.id idu', 'users_dis.id idr' )->where('users_dis.semana','=',$semana)->where('users_dis.nr','!=',777)->where('users.categoria','=',1)->where('users_dis.nr','!=',888)->where('users_dis.nr','!=',999)->join('users', 'users.numero', '=','users_dis.nr')->orderby('nr')->get(); 

then foreach transform them array this:

  if($disponibilidadi !="[]")   foreach ($disponibilidadi $disponibilidad){     $i[] = array(       "1"=> $disponibilidad->nombre." ".$disponibilidad->apellido,       "2" => $disponibilidad->lunes,       "3"=> $disponibilidad->martes,       "4"=> $disponibilidad->miercoles,       "5"=> $disponibilidad->jueves,       "6"=> $disponibilidad->viernes,       "7"=> $disponibilidad->sabado_m,       "8"=> $disponibilidad->sabado_t,       "9"=> $disponibilidad->sabado_n,       "10"=> $disponibilidad->domingo_m,       "11"=> $disponibilidad->domingo_t,       "12"=> $disponibilidad->domingo_n,     );   }   else{     $i = [];    } 

and lastly export it:

excel::create('disponibilidad-'.$semana, function($excel) use ($i,$semana) {         $excel->sheet('sad', function($sheet) use ($i) {           $head = array('nombre','l','m','mi','j','v','s(m)','s(t)','s(n)','d(m)','d(t)','d(n)');           $data = array($head);           $sheet->fromarray($data, null, 'a1', false, false);           $sheet->setborder('a2:l2', 'thin');           $sheet->cell('a1:l1', function($cell) {             $cell->setbackground('#009150');             $cell->setfontcolor('#ffffff');             $cell->setfontsize(16);           });             $head2 = array('internacionales','','','','','','','','','','','');           $data2 = array($head2);           $sheet->fromarray($data2, null, 'a2', false, false);           $sheet->mergecells('a2:l2');           $sheet->setborder('a2:l2', 'thin');           $sheet->cell('a2:l2', function($cell) {             $cell->setfontweight('bold');             $cell->setalignment('center');             $cell->setvalignment('center');             $cell->setfontsize(14);           });             foreach($i $value) {             $sheet->cell('a1', function($cell) use ($value) {             $cell->setvalue($value);             $cell->setbackground('#ff5300');               });             }         });       })->download('xls');     } 

i want when value of cell = 1 put style , value different value 1 style.

it possible thanks.


Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -