PHPExcel conditional formatting when cell is equal to row

Following:

$objConditional1 = new PHPExcel_Style_Conditional(); $objConditional1->setConditionType(PHPExcel_Style_Conditional::CONDITION_CONTAINSTEXT) ->setOperatorType(PHPExcel_Style_Conditional::OPERATOR_CONTAINSTEXT) ->addCondition("Bla bla"); $objConditional1->getStyle()->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID)->getEndColor()->setARGB(PHPExcel_Style_Color::COLOR_GREEN); $conditionalStyles = $sheet->getStyle('I2')->getConditionalStyles(); array_push($conditionalStyles, $objConditional1); $sheet->getStyle('I$2:I$10000')->setConditionalStyles($conditionalStyles); 

Creates an excel document and says that conditional formatting has problems and that it will delete it ...

The correct result I'm looking for is equal to the "Bla bla" column filling the field with green

+6
source share
1 answer

This is a change instead of addCondition, you have to call setText ... Which is hard to do, but whatever ... cool, I got it to work.

 $objConditional1 = new PHPExcel_Style_Conditional(); $objConditional1->setConditionType(PHPExcel_Style_Conditional::CONDITION_CONTAINSTEXT) ->setOperatorType(PHPExcel_Style_Conditional::OPERATOR_CONTAINSTEXT) ->setText("Bla bla"); $objConditional1->getStyle()->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID)->getEndColor()->setARGB(PHPExcel_Style_Color::COLOR_GREEN); $conditionalStyles = $sheet->getStyle('I2')->getConditionalStyles(); array_push($conditionalStyles, $objConditional1); $sheet->getStyle('I$2:I$10000')->setConditionalStyles($conditionalStyles); 
+9
source

Source: https://habr.com/ru/post/971976/


All Articles