2016-12-09 3 views
1

Wie festgelegt Stil für jede Zelle oder bestimmte Zelle in Laravel Excel exportieren?Laravel Excel-Export jeder Zelle Stil

mein Code wie diese

Excel::create('Output', function($excel) use ($records) { 
    $excel->sheet('Records', function($sheet) use ($records) { 
    $i = 0; 
    foreach ($records as $key => $record) { 
     $sheet->row($i, $record); 
     $sheet->row($i, function ($row) { 
     $row->setFontWeight('bold'); 
     $row->setBackground('#FF5300'); 
     }); 
     $i++; 
    } 
    }); 
})->export('xls'); 

Durch diese i-Stil für die Zeilen festlegen. Aber ich möchte Stil für jede Zelle festlegen.

Antwort

0

Bedarf Stil

Excel::create('Output', function($excel) use ($records) { 
     $excel->sheet('Records', function($sheet) use ($records) { 
     $i = 1; 
     foreach ($records as $record) { 
      $j = 'A'; 
      foreach($record as $value) { 
       $sheet->cell($j.$i, function($cell) use ($value) { 
        $cell->setValue($value); 
        $cell->setBackground('#FF5300'); 
       }); 
       $j++; 
      } 
      $i++; 
     } 
     }); 
    })->export('xls'); 
für jede Zelle zu setzen
0

Bitte versuchen Sie, diese Arbeit für mich

$sheet->cell('A1', function($cell) 
{ 

    $cells->setFontWeight('bold'); 

}); 
Verwandte Themen