Posted by michealorion ·
Deleted by michealorion ·
05-12-2016 - 09:52
Hello,
The method replaceVariableByHTML allows to replace a placeholder by a HTML, transforming the HTML to Word. You can use almost any tag and CSS style to add contents and style them.
For example you can set width of the whole table:
$html = '<table border="1" style="border-collapse: collapse" width="400">
<tbody>
<tr>
<td style="background-color: yellow">1_1</td>
<td rowspan="3" colspan="2">1_2</td>
</tr>
<tr>
<td>Some random text.</td>
</tr>
<tr>
<td>
<ul>
<li>One</li>
<li>Two <b>and a half</b></li>
</ul>
</td>
</tr>
</tbody>
</table>';
$docx->replaceVariableByHTML('VAR', 'inline', $html, array('isFile' => false, 'parseDivsAsPs' => true, 'downloadImages' => false));
This code uses the attribute width, but you can use CSS as well.
We recommend you to read the documentation available on:
http://www.phpdocx.com/documentation/introduction/html-to-word-PHP
http://www.phpdocx.com/documentation/cookbook/convert-html-to-word
and the examples included in the package.
Regards.