From f505648ec5471204cf2fc95650b72463c7577bce Mon Sep 17 00:00:00 2001 From: bolovincev Date: Tue, 19 Nov 2013 22:51:11 +0300 Subject: [PATCH] Update Worksheet.php getStyleByColumnAndRow() http://phpexcel.codeplex.com/discussions/263626 $objPHPExcel->getActiveSheet()->getStyleByColumnAndRow(1, 2, 5, 2)->applyFromArray($styleArray); It is very convenient in cycles --- Classes/PHPExcel/Worksheet.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Classes/PHPExcel/Worksheet.php b/Classes/PHPExcel/Worksheet.php index 3fecc164..35a0bdb1 100644 --- a/Classes/PHPExcel/Worksheet.php +++ b/Classes/PHPExcel/Worksheet.php @@ -1486,11 +1486,20 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable * * @param int $pColumn Numeric column coordinate of the cell * @param int $pRow Numeric row coordinate of the cell + * @param int pColumn2 Numeric column coordinate of the range cell + * @param int pRow2 Numeric row coordinate of the range cell * @return PHPExcel_Style */ - public function getStyleByColumnAndRow($pColumn = 0, $pRow = 1) + public function getStyleByColumnAndRow($pColumn = 0, $pRow = 1, $pColumn2=null, $pRow2=null) { - return $this->getStyle(PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow); + + if(!is_null($pColumn2) && !is_null($pRow2)) + { + $cellRange = PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow . ':' . PHPExcel_Cell::stringFromColumnIndex($pColumn2) . $pRow2; + return $this->getStyle($cellRange); + } + + return $this->getStyle(PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow); } /**