M--
M--

Reputation: 375

Style a range of cells with phpexcel

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.

Upvotes: 11

Views: 15145

Answers (1)

Gedrox
Gedrox

Reputation: 3612

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)

Upvotes: 10

Related Questions