以下内容:
$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);
生成一个excel文档,并说条件格式有问题,并且会删除它......
我正在寻找的正确结果是当列等于" Bla bla"填写绿色框
答案 0 :(得分:9)
更改不是addCondition,你必须调用setText ...这很难推断,但无论如何......很酷我让它工作。
$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);