Set Center in Tables

Feb 21, 2011 at 9:05 AM

How can i set the Row in Table to Center?

 

$pptrow = $shapeTable->createRow();
$pptrow->setHeight(30);
$pptrow->getFill()->setFillType(PHPPowerPoint_Style_Fill::FILL_GRADIENT_LINEAR)
->setRotation(90)
->setStartColor(new PHPPowerPoint_Style_Color('B2B2B2'))
->setEndColor(new PHPPowerPoint_Style_Color('B2B2B2'));
$cell = $pptrow->nextCell();
$cell->setColspan(5);
$cell->createTextRun($statlang->gT("Answer"))->getFont()->setBold(true)->setName(pptGetFont())->setSize(12);
$pptrow->nextCell();
$pptrow->nextCell();
$pptrow->nextCell();
$pptrow->nextCell();
$pptrow->nextCell()->createTextRun($statlang->gT("Count"))->getFont()->setBold(true)->setName(pptGetFont())->setSize(12);
$pptrow->nextCell()->createTextRun($statlang->gT("Percentage"))->getFont()->setBold(true)->setName(pptGetFont())->setSize(12);
$pptrow->getActiveParagraph()->getAlignment()->setHorizontal( PHPPowerPoint_Style_Alignment::HORIZONTAL_CENTER );

 

And other Combination with getAlignment are not working.

 

Call to undefined method PHPPowerPoint_Shape_RichText_Run::getActiveParagraph()

Mar 16, 2011 at 4:09 PM

I need to know the exact same thing, and I have had the exact same results as the original poster.

Please help!

 

thanks!

Apr 27, 2011 at 10:34 AM

I only downloaded this library today so take this with a grain of salt, but I think only individual cells can have alignment. 

eg:

$row = $shape->createRow();
$cell = $row->nextCell();
$cell->createTextRun('R1C1');
$cell->getActiveParagraph()->getAlignment()->setHorizontal( PHPPowerPoint_Style_Alignment::HORIZONTAL_RIGHT );
$row->nextCell()->createTextRun('R1C2');

-asbjxrn

Apr 27, 2011 at 10:43 AM

Yes, I've not found a way to align rows vertically, which is what I think the original question is about.

To get vertical alignment I used:

$cell->getActiveParagraph()->getAlignment()->setVertical(PHPPowerPoint_Style_Alignment::VERTICAL_CENTER);

S