Forum


Replies: 6   Views: 5433
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 lucaloda  · 04-11-2018 - 18:52

i'm trying to create a table with embedHtml() but it has always cellborder and cellspacing even if i state "<style>table, th, td {   border: 0; }</style> "  and  "<tablecellspacing="0"cellpadding="0">".

 

any tips?

Posted by admin  · 04-11-2018 - 19:30

Hello,

What version and license of phpdocx are you using?

Regards.

Posted by lucaloda  · 07-11-2018 - 09:53

hello, we have 'basic', 8.0

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.

Posted by lucaloda  · 08-11-2018 - 10:38

it appears it's not working. i menage to partially hide it using { border: 0 solid white; } but the border is still there

Posted by admin  · 08-11-2018 - 11:20

Hello,

We have run the previous script and then opened the DOCX output with MS Word 2007, MS Word 2010, MS Word 2013, MS Word 2016 and LibreOffice 6 and there's no border displayed.

What program and version are you using to open the DOCX?

Regards.

Posted by lucaloda  · 27-11-2018 - 14:11

the last version of office on windows 10 and openoffice on ubuntu

i overcome the problem bu setting the border really thin and trasparent