Answer the question
In order to leave comments, you need to log in
PhpWord: how to display a table correctly?
You need to put the table in the doc-file template. The table is taken from the database, where it is stored as html ($html_table).
the code:
$templateProcessor = new \PhpOffice\PhpWord\TemplateProcessor('tempatename.docx');
$wordTable = new \PhpOffice\PhpWord\Element\Table();
$wordTable->addRow();
$cell = $wordTable->addCell();
\PhpOffice\PhpWord\Shared\Html::addHtml($cell, $html_table);
$templateProcessor->setComplexBlock('html_table', $wordTable);
$templateProcessor->saveAs($pathToSave);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question