Cannot solid fill a conditional style?

Topics: Developer Forum
Jan 19, 2015 at 4:45 PM

I am trying to zebra stripe some rows, so I've set up a conditional style and when I view the document in Excel I can see that the conditional rule is applied to all of the rows, but the fill color has not been applied. (I can then in Excel tweak the rule to the correct background colour and all of the rows get coloured as I would expect.)

The code snippet looks like this:
        $zebra = new PHPExcel_Style_Conditional();
                'fill' => [
                    'type'  => PHPExcel_Style_Fill::FILL_SOLID,
                    'color' => ['rgb' => 'DDE8F7']
        $condStyles = $sheet->getStyle("A2:{$highCol}{$highRow}")->getConditionalStyles();
        array_push($condStyles, $zebra);
Along with the applyFromArray as above, I've tried narrowing that down so I first getStyle()->getFill() and so on, but still no luck.

Any clues? Am I doing something wrong or is this not supported? I've tried this on PHPExcel 1.7.9 and 1.8.0.

Any help appreciated, thanks!

Jan 20, 2015 at 9:16 AM
OK, I've figured this out. It's simply that it didn't like 'color' but does work with 'endcolor' specified (I had previously tried 'color' and 'startcolor'). So just tweaking the fill to be:
'fill' => [
    'type'  => PHPExcel_Style_Fill::FILL_SOLID,
    'endcolor' => ['rgb' => 'DDE8F7']
worked without changing anything else.
Marked as answer by acollington on 1/20/2015 at 2:16 AM