11

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.

M--
  • 375
  • 1
  • 2
  • 11
  • Maybe an important note: Writing the styles of many cells at once is much faster than writing the style of each cell separately. In my test cases writing multiple cell values at once didn't make my code faster, but writing multiple cell styles at once made it much faster. – David Gausmann May 04 '17 at 08:30

1 Answers1

11

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)
Gedrox
  • 3,592
  • 1
  • 21
  • 29
  • Thanks for your answer! I was hoping there is a better looking solution, a seperate function maybe. I like keeping my code short :D – M-- Jul 13 '11 at 09:51