I’m using the PHPWord package in Laravel to replace placeholders in a DOCX template.
I have a placeholder ${table} in my DOCX file and I’ve done code like:
$tableStyle = [
'width' => 100 * 50,
'unit' => 'pct',
'cellMargin' => 150,
'borderColor' => '000000',
'borderSize' => 6,
];
$table = new Table($tableStyle);
$table->addRow();
$nameCell = $table->addCell(2000);
$nameCell->getStyle()->setGridSpan();
$nameCell->addText('Name', ['bold' => true, 'size' => 8]);
$processor->setComplexBlock('table', $table);
Now when I add placeholder like:
${table}
${table}
in docx multiple time it’s only replacing first placeholder.
Can anyone tell me what can be issue here? It’s working for the normal placeholder like setValue
function for other type of placeholder.