问题
I'm trying to add a border to the bottom of all cells in every row after row 2 that satisfies this condition:
$objConditional1 = new PHPExcel_Style_Conditional();
$objConditional1->setConditionType(PHPExcel_Style_Conditional::CONDITION_EXPRESSION)
->setOperatorType(PHPExcel_Style_Conditional::OPERATOR_EQUAL)
->addCondition('AND((B2<>B3),B2<>"")');
$objConditional1->getStyle()->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
$conditionalStyles = $sheet->getStyle('B2')->getConditionalStyles();
array_push($conditionalStyles, $objConditional1);
$sheet->getStyle('B2')->setConditionalStyles($conditionalStyles);
$sheet->duplicateConditionalStyle(
$sheet->getStyle('B2')->getConditionalStyles(),
'B3:B9999'
);
- I'm not sure I understand how to add this condition to every single row and column after row 2...
- Second of all, the border is not being added as expected... In excel the formatting says (none)...
Can I have some help with this?
The goal is to look like this:

回答1:
The addition is in the last line! Did the job.. ta da
$objConditional1 = new PHPExcel_Style_Conditional();
$objConditional1->setConditionType(PHPExcel_Style_Conditional::CONDITION_EXPRESSION)
->setOperatorType(PHPExcel_Style_Conditional::OPERATOR_EQUAL)
->addCondition('AND((B2<>B3),B2<>"")');
$objConditional1->getStyle()->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
$conditionalStyles = $sheet->getStyle('B2')->getConditionalStyles();
array_push($conditionalStyles, $objConditional1);
$sheet->getStyle('A$2:$U$10000')->setConditionalStyles($conditionalStyles);
来源:https://stackoverflow.com/questions/24652458/phpexcel-conditional-formatting-not-quite-right