目前,我正在使用laravel 5.6中的maatwebs3.1export导出一个excel表格。我正在使用phpspreadsheet概念进行条件格式化。
$conditional_fico = new \PhpOffice\PhpSpreadsheet\Style\Conditional(); $conditional_fico->setConditionType(\PhpOffice\PhpSpreadsheet\Style\Conditional::CONDITION_CELLIS) ->setOperatorType(\PhpOffice\PhpSpreadsheet\Style\Conditional::OPERATOR_LESSTHAN) ->addCondition('700'); $conditional_fico->getStyle()->getFont()->getColor()->setARGB(\PhpOffice\PhpSpreadsheet\Style\Color::COLOR_RED); $conditionalStyles = $event->sheet->getStyle('G:G')->getConditionalStyles(); $conditionalStyles[] = $conditional_fico; $event->sheet->getStyle('G:G')->setConditionalStyles($conditionalStyles);
现在我想改变A:A的颜色,如果相应的G:G小于700。示例:
如果G1 <700,则将A1设置为红色;如果G2 <700,则将A2设置为红色,依此类推。
请共享对应的条件格式规则
发布于 2020-09-02 22:11:29
我想通了,
$styleArray = array( 'font' => array( // 'bold' => true, 'color' => array('rgb' => 'FF0000'), $highestRow = $event->sheet->getHighestRow(); $highestColumn = $event->sheet->getHighestColumn(); $highestColumnIndex = \PhpOffice\PhpSpreadsheet\Cell\Coordinate::columnIndexFromString($highestColumn);