Replies: 1   Views: 1229
Table border issues, collapse does not work
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 marius.janulaitis  · 24-02-2020 - 13:34


i set table border size 1 also using "border-collapse: collapse", but with Open Office borders looks very big.
Also doesn't seem to work "collapse". How to create default (single) table border?
phpdocx version is 9.5.

require_once 'classes/CreateDocx.php';
$docx = new CreateDocx();


$html = 'Some random text START ....<br>
Text new line
<table width="600" border="1" style="border-collapse: collapse;">
                        <td width="278">Test 1</td>
                        <td width="22" align="center">x</td>
                        <td width="278">Test 1 2</td>
                        <td class="c-val" width="22"><br></td>
                        <td width="278">Test 2 1</td>
                        <td width="22" align="center">x</td>
                        <td width="278">Test 2 2</td>
                        <td class="c-val" width="22"><br></td>
Some random text ENT ....<br>
Text new line';



Posted by admin  · 24-02-2020 - 15:29


We have run your sample and then opened the output with MS Word 2007 to MS Word 2016 and in all cases, border-collapse works perfectly. The included sample Core/embedHTML/sample_1.php illustrates using this option.

LibreOffice and OpenOffice don't handle cell margins as OOXML (DOCX standard) sets. To get the same output you need to apply cell borders using CSS styles or apply a custom table style when importing HTML.