PHPExcel条件格式不太正确

时间:2014-07-09 11:26:36

标签: php phpexcel

我正在尝试在满足此条件的第2行之后的每一行中的所有单元格的底部添加边框:

$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. 我不确定我是否理解如何将此条件添加到第2行...
  2. 之后的每一行和每列
  3. 其次,边框没有按预期添加...在excel格式化中说(无)......
  4. 我可以帮忙解决这个问题吗?

    目标是这样: enter image description here

1 个答案:

答案 0 :(得分:2)

添加是在最后一行!做了工作.. 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);