Forum


Replies: 1   Views: 1401
Html table with colspans
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  · 14-06-2021 - 15:28

Hello,

Your username doesn't a license tied. Please send to contact[at]phpdocx.com the username or email that purchased the license.

About your question, MS Word can handle many automatic values when adding tables, but some cases such as the one you have posted, requires setting widths (the table itself and at least the first row) instead of automatic values, so MS Word can display the table correctly. Please check the following sample after changing your code:

$docx = new CreateDocx();

$html = '<table width="600">
<tbody>
<tr>
<th width="150">AAAAA</th>
<th width="150">BBBBB</th>
<th width="150">CCCCC</th>
<th width="150">DDDDD</th>
</tr>
<tr>
<td colspan="3">111111</td>
<td>EEEEEE</td>
</tr>
<tr>
<td colspan="3">222222</td>
<td>FFFFFF</td>
</tr>
</tbody>
</table>'
;

$docx->embedHTML($html);

$docx->createDocx('output');

Following this recommendation, all your tables will be displayed correctly.

Regards.