Forum


Replies: 6   Views: 588
Table with no cell border
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  · 07-11-2018 - 11:35

Hello,

You can use HTML attributes, CSS styles or a MS Word custom table style.

For example, the following script removes the border and set a border-collapse:

<?php

require_once 'classes/CreateDocx.php';

$docx = new CreateDocx();

$html = '
<style>
    table, th, td { border: 0; }
    table {border-collapse: collapse;}
</style>
<table>
    <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>
                <ul>
                    <li>One</li>
                    <li>Two <b>and a half</b></li>
                </ul>
            </td>
        </tr>
        <tr width="600">
            <td>3_2</td>
            <td>3_3</td>
            <td>3_3</td>
        </tr>
    </tbody>
</table>';
$docx->embedHTML($html);

$docx->createDocx('output');

If you open the DOCX output with MS Word 2003 or newer or LibreOffice 5 or newer, you can check there's no border and the table is 'collapse'.

A very similar sample is included in the package (examples/Core/embedHTML folder).

Regards.