The 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);
Generates an excel document and says that the conditional formatting has issues and that it will remove it...
The correct result i'm looking for is when column equals "Bla bla" fill the box in green
The change is instead of addCondition, you have to call setText... Which is hard to infer, 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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With