solid fill with custom color

Topics: User Forum
Oct 31, 2008 at 9:24 AM

Hi, been struggling w/ filling a cell with custom color.... can anybody put me into this? thanx

Developer
Oct 31, 2008 at 9:39 AM
Try this to fill cells B1:D10 with red color.

$excel = new PHPExcel();
$sheet = $excel->getActiveSheet();

$sheet->duplicateStyleArray(
    array(
        'fill' => array(
            'type' => PHPExcel_Style_Fill::FILL_SOLID,
            'startcolor' => array(
                'rgb' => 'FF0000',
            ),
        )
    ),
    'B1:D10'
);

$writer = new PHPExcel_Writer_Excel2007($excel);
$writer->save('test.xlsx');


Oct 31, 2008 at 9:59 AM

oh. thanx. so it is STARTCOLOR - i've read a bit of source and seen "color" parameter - startcolor seems quite confusing, when its the only color in the fill :))

thanx for swift reply, koyama!