Replies: 5   Views: 2735
Html in table cell
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  · 07-11-2018 - 14:38


The addTable method, as other methods, allows adding WordFragments ( as contents.

You just need to create a new WordFragment, insert the HTML and then add the values to the table:

$html = new WordFragment($docx);

$valuesTable = array(
    'Title A',
    'Title B',
    'Title C',
   'Line A',
   'Line B',


You can see a full sample using WordFragments on the API page of the method (

You can also add a placeholder to the table as value an then use replaceVariableByHTML or replaceVariableByWordFragment to replace it with a WordFragment of the HTML.