我正在使用 phpexcel 生成一个 excel 工作表,当使用条件格式时(搜索文本或其一部分),我在尝试打开生成的工作表时遇到验证错误。与数字完美搭配,与文字搭配更是如此。
这是我的代码:
//conditional formatting
$objConditional1 = new PHPExcel_Style_Conditional();
$objConditional1->setConditionType(PHPExcel_Style_Conditional::CONDITION_CONTAINSTEXT)
->setOperatorType(PHPExcel_Style_Conditional::OPERATOR_CONTAINSTEXT)
->addCondition('X');
$objConditional1->getStyle()->getFont()->getColor()->setARGB(PHPExcel_Style_Color::COLOR_YELLOW);
$objConditional3 = new PHPExcel_Style_Conditional();
$objConditional3->setConditionType(PHPExcel_Style_Conditional::CONDITION_CELLIS)
->setOperatorType(PHPExcel_Style_Conditional::OPERATOR_GREATERTHANOREQUAL)
->addCondition('0');
$objConditional3->getStyle()->getFont()->getColor()->setARGB(PHPExcel_Style_Color::COLOR_GREEN);
$conditionalStyles = $objPHPExcel->getActiveSheet()->getStyle('B2')->getConditionalStyles();
array_push($conditionalStyles, $objConditional3);
array_push($conditionalStyles, $objConditional1);
$objPHPExcel->getActiveSheet()->getStyle('B2')->setConditionalStyles($conditionalStyles);
有谁知道如何解决这个问题?我做错什么了吗?谢谢。