Forum


Replies: 5   Views: 2547
Replacevariablebyhtml nevers displays a table
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by admin  · 16-01-2018 - 15:36

Hello,

A table can't be replaced as an inline element or you'll only get its inline text. You must do a block replacement for tables and other block elements:

$docx->replaceVariableByHTML('CHUNK_2', 'block', $html, array('isFile' => false, 'parseDivsAsPs' => true, 'downloadImages' => false));

All samples available in the package and on the website use block replacements when replacing a placeholder with a table HTML.

We recommend you to read the tutorial page about HTML to DOCX (https://www.phpdocx.com/documentation/introduction/html-to-word-PHP); from this page:

The type of substitution that may be:
block: The whole paragraph containing the variable is replaced by the corresponding HTML.
inline: Only the variable itself is replaced by the inline HTML content (block elements are removed from the code).

Regards.