Syntax for populating merged cells

Feb 10, 2010 at 5:44 PM

What is the syntax used to populate cells that have been merged together?

I use the following syntax to merge the appropriate cells:

$objPHPExcel->getActiveSheet()->mergeCells('A'.$maxRow.':Q'.$maxRow);

 

Also, is there a module for dynamically populating cells post 1 alphabet character (EG AA, AB,AC)

Coordinator
Feb 10, 2010 at 7:14 PM
boogyman wrote:

What is the syntax used to populate cells that have been merged together?

I use the following syntax to merge the appropriate cells:

$objPHPExcel->getActiveSheet()->mergeCells('A'.$maxRow.':Q'.$maxRow);

when cells have been merged, I find it easiest to reference by the top-left cell of the mergeset

$objPHPExcel->getActiveSheet()->mergeCells('A'.$maxRow.':Q'.$maxRow);
$objPHPExcel->getActiveSheet()->setCellValue('A'.$maxRow, $value);

boogyman wrote:

Also, is there a module for dynamically populating cells post 1 alphabet character (EG AA, AB,AC)

Simply use cell references such as AB1

$objPHPExcel->getActiveSheet()->setCellValue('IV65535', $value);

Note that PHP (very usefully) allows you to post-increment characters as well as numbers using ++
so:

$column = 'A';
while ($column != 'IW') {
   echo $column.'<br />';
   $column++;
} 
Feb 11, 2010 at 10:32 AM
Edited Feb 11, 2010 at 12:53 PM
MarkBaker wrote:

boogyman wrote:

Also, is there a module for dynamically populating cells post 1 alphabet character (EG AA, AB,AC)

Simply use cell references such as AB1

$objPHPExcel->getActiveSheet()->setCellValue('IV65535', $value);

Note that PHP (very usefully) allows you to post-increment characters as well as numbers using ++
so:

$column = 'A';
while ($column != 'IW') {
   echo $column.'<br />';
   $column++;
} 

I was thinking more along the lines of a full fledged system. There is a potential for up to 208 (12 sets of 17 columns) columns, and I would prefer to minimize the line-count for the processing as much as possible, but thank you for your suggestions. I am aware of the feature to create multiple sheets, and while it was a consideration, it was decided to use 1 row per record set, thus the dilemma

 

// UPDATE

Okay, so viewing other threads, I have found that you can set a value by it's numeric column... however I cannot find anything where there's the ability to set the style of a range of columns by their numeric column.  setSharedStyleByColumnAndRow(1:2,2:2) "A2:B2". Would I need to make a post on the features request thread to have this happen, or have I just not been able to locate such thread yet?

Coordinator
Feb 13, 2010 at 10:03 AM

Convert your column references between numeric and string using PHPExcel_Cell::stringFromColumnIndex() and PHPExcel_Cell::columnIndexFromString()

Dec 26, 2012 at 3:49 AM

Buscando una solucion encontre tu post, despues vi el codigo fuente de las librerias y edite la funcion "setSharedStyle" para adecuarla a nuestras necesidades..

http://phpexcel.codeplex.com/discussions/418596