Problem with Conditional formatting of cells

Topics: Developer Forum, Project Management Forum, User Forum
Aug 22, 2012 at 9:30 AM
Edited Aug 22, 2012 at 9:34 AM

Hi i have some problem with formatting the background color of cell depending on the values in the cell eg: For whole column c if the values is 3 or 4 the background color of that particular cell should be indicated  in red color. likewise i should check and format the cell background color for all the values in C column.

Here's my code.

$condition_style = array('type' => PHPExcel_Style_Fill::FILL_SOLID, 'endcolor' => array('rgb' => 'ff0000'));
$objConditional = new PHPExcel_Style_Conditional();             

$objConditional->setConditionType(PHPExcel_Style_Conditional::CONDITION_EXPRESSION);    

$objConditional->setOperatorType(PHPExcel_Style_Conditional::OPERATOR_NONE);               

$objConditional->setCondition('C<3');               

$objConditional->getStyle()->getFill()->applyFromArray($condition_style);                              

$conditionalStyles = $objWorksheet_special->getStyle('C')->getConditionalStyles();               

array_push($conditionalStyles, $objConditional);               

$objWorksheet_special->getStyle('C')->setConditionalStyles($conditionalStyles);               

$objWorksheet_special->getStyle('C')->getFill()->applyFromArray($condition_style); 

This above code doesn't work and i don't know what am missing. Can any one help me in figuring this out!!!