PHPPresentation Adding Text After Using setColSpan() Doesn't Work

304 views Asked by At

I'm try to add text following a colspan column and nothing I've tried has worked. Here is what I have tried so far.

// Create a shape (table)
$tableShape = $currentSlide->createTableShape(3);
$tableShape->setHeight(1200);
$tableShape->setWidth(960);
$tableShape->setOffsetX(0);
$tableShape->setOffsetY(0);

// Add row
$row = $tableShape->createRow();
$cell = $row->nextCell();
$cell->setColSpan(2);
$cell->createTextRun('Row 1 Colspan column 1');

$Cell = $row->nextCell();
$Cell->createTextRun('Row 1 column 2');

// Add row
echo date('H:i:s') . ' Add row'.EOL;
$row = $tableShape->createRow();
$oCell = $row->nextCell();
$oCell->createTextRun('R2C1');

$oCell = $row->nextCell();
$oCell->createTextRun('R2C2');

$oCell = $row->nextCell();
$oCell->createTextRun('R2C3');

// Save file
echo write($objPHPPresentation, basename(__FILE__, '.php'), $writers);
if (!CLI) {
    include_once 'Sample_Footer.php';
}

Here's what the result looks like:

enter image description here

1

There are 1 answers

0
RiggsFolly On BEST ANSWER

Looks like it has placed both the texts in the first column with the colspan2 set

So try this to place the cursor into the third column/cell

$Cell = $row->getCell(2);
$Cell->createTextRun('Row 1 column 2');