
Hello,
For PHPExcel, is their a dynamic row function for formatting the dynamic data in a border with a and background colour or whatever, etc.. ?
for example
My spread sheet will have multiple instances of dynamic rows,, so I may have 1 row or 50 rows of data at the top.. i want to wrap a border around it without having to write this for every row (mostly because I wont know how many rows I have)
$objPHPExcel>getActiveSheet()>setCellValue('E3', 'Total');
$objPHPExcel>getActiveSheet()>getComment('E3')>getFillColor()>setRGB('EEEEEE');
$styleThinBlackBorderOutline = array(
'borders' => array(
'outline' => array(
'style' => PHPExcel_Style_Border::BORDER_THIN,
'color' => array('argb' => 'FF000000'),
),
),
);
$objPHPExcel>getActiveSheet()>getStyle('E3:E10')>applyFromArray($styleThinBlackBorderOutline);
I dont even know if the data will be on row E
or if we will repeat the output to row
here is an example of a blank worksheet before data is entered
ROW A  Static text
ROW B  Static text
ROW C  Static text  Headings for dynamic data
ROW D  Dynamic text  could be 1 or 50 rows of this (wrap border around this and make bg colour yellow)
ROW (E )  Dynamic text totals
ROW F  Static text
ROW G  Static text  Headings for dynamic data
ROW H  Dynamic text  could be 1 or 50 rows of this
ROW (I)  Dynamic text totals
ROW J  Static text
ROW K  Static text  Headings for dynamic data
ROW L  Dynamic text  could be 1 or 50 rows of this
ROW (M)  Dynamic text totals



At the time where you write data, you know the number of rows of columns, you can then apply the style on this basis:
$FirstColumn = 'G'; $FirstRow = 5;
$LastColumn = 'G'; $LastRow = 5;
//[...] Write data. $LastColumn and $LastRow change in the procedure ($FirstColumn and $FirstRow too, if you need)
$styleRange = $FirstColumn. $FirstRow.': '. $LastColumn. $LastRow;
[...]>getStyle($styleRange)>applyFromArray (...);
The same principle applies if you need to create formulas, as a sum of the data that you just write for example



Hi Lwol,
Thank you for responding.
I was already considering doing it that way, what i was hoping was if if someone had already come up with a fucntion so i didn't have to keep looping and counting rows



To my knowledge, no. In one way or another, you need a counter to have the coordinates to write the cells unless you use fromArray and know so the number by count() but this solution seems not be simpler to implement than a counter...

