Forum


Replies: 3   Views: 2927
Table cell vertical alignment in html to word not working
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  · 23-01-2019 - 17:55

Hello,

We have done some quick tests and everything is working correctly.

The following script illustrates a basic sample:

$docx = new CreateDocx();

$html .=
'
<style>
tr {
    height: 100px;
}
td {
    vertical-align: bottom;
}
.td_middle {
    vertical-align: middle;
}
.td_top {
    vertical-align: top;
}
</style>
<table border="1" style="border-collapse: collapse" width="600">
    <tbody>
        <tr width="600">
            <td style="background-color: yellow">1_1</td>
            <td rowspan="3" colspan="2">1_2</td>
        </tr>
        <tr width="600">
            <td>Some random text.</td>
        </tr>
        <tr width="600">
            <td class="td_middle">
                <ul>
                    <li>One</li>
                    <li>Two <b>and a half</b></li>
                </ul>
            </td>
        </tr>
        <tr width="600">
            <td class="td_middle">3_2</td>
            <td class="td_top">3_3</td>
            <td class="td_top">3_3</td>
        </tr>
    </tbody>
</table>
';
$docx->embedHTML($html);

$docx->createDocx('output');

As you check in the DOCX output, the td contents are correctly aligned. We recommend you run the script standalone and then compare it with your code to find any issue, maybe other styles are overwriting the CSS you point out.

Regards.