Rather than defining cell color etc. in a range in the form of "A1:G1" or range('A','G') - since the table is dynamic and will have different count of columns each time - I wanted to use the range in the form of:
->getStyle('A1:' . $highestColumn . '1')
where
$highestColumn = $objPHPExcel->getActiveSheet()->getHighestColumn();
but this is not working. If I print the result, $highestColumn is shown to be "A", whereas in fact it should be "G".
Why is getHighestColumn() not working?
getHighestColumn()
(andgetHighestRow()
) use a value populated from a file load, and those values then remain unchanged - even if you add further rows or columns yourself - until you save the PHPExcel object.Perhaps you should use
getHighestDataColumn()
which is calculated dynamically at the point when it is called, and always based on the actual collection of cell data at that point in time.