Forum


Replies: 3   Views: 500
Table cell spacing adding empty cells
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  · 13-10-2022 - 06:46

Hello,

MS Word doesn't allow adding empty cells (a corrupted DOCX message appears if a cell doesn't have at least one content). If a cell doesn't contain at least one content, an empty paragraph without styles is added by phpdocx when transforming the HTML to avoid generating a corrupted DOCX. For this reason, we recommend adding at least one space to generate all sizes in the same way:

<td width="30%"><b>Last Name</b></td>
<td width="70%">&nbsp;</td>

otherwise, an empty paragraph is generated. As this paragraph doesn't apply styles, the default ones are used.
Adding some default styles can be avoided by disabling the addDefaultStyles option:

$docx->embedHTML($html, array('addDefaultStyles' => false));

but this approach requires using paragraphs in cells to set custom pararagraph spacings with CSS styles.

These are the available approaches using the current stable version. We have also sent your message to the dev team to be checked and improve the transformation in this case.

Regards.