PHPExcel conditional formatting not quite right

匿名 (未验证) 提交于 2019-12-03 10:24:21

问题:

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' ); 
  1. I'm not sure I understand how to add this condition to every single row and column after row 2...
  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); 


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!