Conditional Formating with 2 formulas

Topics: Developer Forum
Dec 9, 2011 at 7:53 PM

Hi,

I'm having troubles to set conditional formating of cells with 2 formulas. No matter if I set the formating in template or try to do it via code, the first formula get broken.

Im using 1.7.6 and here is the code to set the Conditional Format:

$objConditional1 = new PHPExcel_Style_Conditional();
$objConditional1->setConditionType(PHPExcel_Style_Conditional::CONDITION_EXPRESSION);
$objConditional1->addCondition('(F21-G21)/F21>=0.05');
$objConditional1->addCondition(TRUE);
$objConditional1->getStyle()->getFont()->getColor()->setARGB(PHPExcel_Style_Color::COLOR_RED);
$objConditional1->getStyle()->getFont()->setBold(true);
$objConditional2 = new PHPExcel_Style_Conditional();
$objConditional2->setConditionType(PHPExcel_Style_Conditional::CONDITION_EXPRESSION);
$objConditional2->addCondition('(F21-G21)/F21<=-0.05');
$objConditional2->addCondition(TRUE);
$objConditional2->getStyle()->getFont()->getColor()->setARGB(PHPExcel_Style_Color::COLOR_GREEN);
$objConditional2->getStyle()->getFont()->setBold(true);
$conditionalStyles = $objPHPExcel->getActiveSheet()->getStyle('G21')->getConditionalStyles();
array_push($conditionalStyles, $objConditional1);
array_push($conditionalStyles, $objConditional2);
$objPHPExcel->getActiveSheet()->getStyle('G21')->setConditionalStyles($conditionalStyles);

Result is that first formula look like (#REF!1-G21)/#REF!1>=0.05

File is being written by
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); 

Is this a bug or am I doing something wrong?

Thank you for your help in advance,
Miso