Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Style a range of cells with phpexcel

Tags:

php

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.

like image 722
M-- Avatar asked Jul 13 '11 08:07

M--


1 Answers

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)
like image 193
Gedrox Avatar answered Oct 12 '22 13:10

Gedrox