Style a range of cells with phpexcel

M-- picture M-- · Jul 13, 2011 · Viewed 13.9k times · Source

I'm trying to style an excel table with phpexcel. I do this:

$sheet->getStyle('A1:B2')->applyFromArray($style);

But it would be better if I can give numeric coordinates. I can use getStyleByColumnAndRow($x, $y) with one cell, but not with a range. Any ideas? Is it supported?

Thanks in advance, M.

Answer

Gedrox picture Gedrox · Jul 13, 2011

You can generate the cell names A1 and B2 from integer coordinates by PHPExcel function which name I currently don't remember (will add when found) and just concat the names using ':' as the glue character and use the same code as you have right now.

EDIT

The function used to create column name by it's coordinate is

PHPExcel_Cell::stringFromColumnIndex($colIndex)