Set Style by Column And Row for applyFromArray

Topics: Developer Forum
Jul 1, 2011 at 11:01 PM

I am trying to set the style by passing the Column and Row numbers without having to specify each cell one by one. So instead of doing the below

$objPHPExcel->getActiveSheet()->getStyleByColumnAndRow(1, 2)->applyFromArray($styleArray);
$objPHPExcel->getActiveSheet()->getStyleByColumnAndRow(2, 2)->applyFromArray($styleArray);
$objPHPExcel->getActiveSheet()->getStyleByColumnAndRow(3, 2)->applyFromArray($styleArray);
$objPHPExcel->getActiveSheet()->getStyleByColumnAndRow(4, 2)->applyFromArray($styleArray);
$objPHPExcel->getActiveSheet()->getStyleByColumnAndRow(5, 2)->applyFromArray($styleArray);

I could just write something like the following which is just like the mergeCellsByColumnAndRow function (which if it has this support, I just cant find it).

$objPHPExcel->getActiveSheet()->getStyleByColumnAndRow(1, 2, 5, 2)->applyFromArray($styleArray);