Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

phpspreadsheet setcellvalue row background color

$spreadsheet = new Spreadsheet();

$spreadsheet->getActiveSheet()->getStyle('A1:F1')->applyFromArray([
    'fill' => [
            'fillType' => Fill::FILL_SOLID,
            'startColor' => [
                'rgb' => 'FFDBE2F1',
            ]           
    ],
]);


Or for single row//

$spreadsheet = new Spreadsheet();
 $sheet = $spreadsheet->getActiveSheet();
 { inside Loop
 $sheet->setCellValue('A1', 'ID');
 $sheet->setCellValue('B1', 'Data di caricamento');
 $sheet->setCellValue('C1', 'Via');
 $sheet->setCellValue('D1', 'Municipio 
$sheet->getStyle("A$cellIndex:I$cellIndex")->getFill()->setFillType(PhpOfficePhpSpreadsheetStyleFill::FILL_SOLID)->getStartColor()->setARGB($color);
          }// end loop here  
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #phpspreadsheet #setcellvalue #row #background #color
ADD COMMENT
Topic
Name
5+7 =