Forum


Replies: 3   Views: 3238
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  · 24-01-2019 - 08:55

Hello,

If you remove width and height values, the vertical-align is correctly set as well:

$html .=
'
<style>
td {
    vertical-align: bottom;
}
.td_middle {
    vertical-align: middle;
}
.td_top {
    vertical-align: top;
}
</style>
<table border="1" style="border-collapse: collapse">
    <tbody>
        <tr>
            <td style="background-color: yellow">1_1</td>
            <td rowspan="3" colspan="2" class="td_middle">1_2</td>
        </tr>
        <tr>
            <td>Some random text.</td>
        </tr>
        <tr>
            <td class="td_middle">
                <ul>
                    <li>One</li>
                    <li>Two <b>and a half</b></li>
                </ul>
            </td>
        </tr>
        <tr>
            <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);

we set a height value in the previous sample to illustrate the use of vertical-align. We recommend you to run this script standalone and check its output, and also check/debug your script to find the source of the issue.

Regards.