Hi Guys,
Having an issue with a table when using embedHtml
When the cell is blank, the formatting is off. See screenshot at https://snipboard.io/lPKr0O.jpg
Thanks
Hi Guys,
Having an issue with a table when using embedHtml
When the cell is blank, the formatting is off. See screenshot at https://snipboard.io/lPKr0O.jpg
Thanks
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%"> </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.
Hello,
The dev team has generated a patch in the testing branch. Although it's currently being tested before including it in the stable branch, it can suit your needs without adding empty blank spaces as explained in our previous reply.
Please edit the HTMLWordML.php file and go to the repairWordML method. In this method, replace the following line:
$data = str_replace('</w:tcPr></w:tc>', '</w:tcPr><w:p /></w:tc>', $data);
with:
$data = str_replace('</w:tcPr></w:tc>', '</w:tcPr><w:p><w:pPr><w:spacing w:after="0" w:before="0" w:line="240" w:lineRule="auto"/></w:pPr></w:p></w:tc>', $data);
Regards.