Style Border Color

Dec 6, 2011 at 4:52 PM

I have had no luck figuring out how to change the color of a set border. I have no issues creating the border, just unable to color it anything but black.

 

Here is the code I use to create the borders, I am not using an array to do so, is there a way to color the border without having to use an array?

 

$objPHPExcel->getActiveSheet()->getStyle('A2:L2')->getBorders()->getAllBorders()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);

Coordinator
Dec 6, 2011 at 9:45 PM
$styleArray = array(
       'borders' => array(
             'outline' => array(
                    'style' => PHPExcel_Style_Border::BORDER_THIN,
                    'color' => array('argb' => 'FFFF0000'),
             ),
       ),
);
$objPHPExcel->getActiveSheet()->getStyle('A2:L2')->applyFromArray($styleArray);

or

 

$objPHPExcel->getActiveSheet()->getStyle('A2:L2')->getBorders()->getAllBorders()->setColor(new PHPExcel_Style_Color(PHPExcel_Style_Color::COLOR_RED));

Personally, I prefer using the applyFromArray() method