简体   繁体   中英

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.

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM