Conditonal style doesn't working

Topics: Developer Forum, User Forum
Oct 1, 2010 at 1:06 PM

Hi,

I try to make a very basically conditionnal style (with the source code in the exemple file of PHPExcel), but without success.

 

I'm using the version 1.6.1 (with Symfony) and the following code :

 

 

$objPHPExcel = new PHPExcel();

$objConditional1 = new PHPExcel_Style_Conditional();
$objConditional1->setConditionType(PHPExcel_Style_Conditional::CONDITION_CELLIS);
$objConditional1->setOperatorType(PHPExcel_Style_Conditional::OPERATOR_LESSTHAN);
$objConditional1->setCondition('0');
$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_CELLIS);
$objConditional2->setOperatorType(PHPExcel_Style_Conditional::OPERATOR_GREATERTHANOREQUAL);
$objConditional2->setCondition('0');
$objConditional2->getStyle()->getFont()->getColor()->setARGB(PHPExcel_Style_Color::COLOR_GREEN);
$objConditional2->getStyle()->getFont()->setBold(true);

$conditionalStyles = $objPHPExcel->getActiveSheet()->getStyle('B2')->getConditionalStyles();
array_push($conditionalStyles, $objConditional1);
array_push($conditionalStyles, $objConditional2);
$objPHPExcel->getActiveSheet()->getStyle('B2')->setConditionalStyles($conditionalStyles);

$objPHPExcel->getActiveSheet()->duplicateStyle( $objPHPExcel->getActiveSheet()->getStyle('B2'), 'B3:B7' );


$objWriter = new PHPExcel_Writer_Excel5($objPHPExcel); 
        header('Content-type: application/vnd.ms-excel');
        header('Content-Disposition:inline;filename=export_controle.xls ');
        $objWriter->save('php://output');




So, When I put a value into the B2 cell, the font type is Calibri. But When I put 0 in the cell, font color is still white :(

Do you know why ?

 

Coordinator
Oct 1, 2010 at 1:19 PM

Work Item 11704. Conditional Formatting isn't supported by the Excel5 Writer.

Oct 1, 2010 at 2:10 PM

Thanks for your help