Forum


Replies: 5   Views: 2003
Table with empty cell and space after table
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  · 26-02-2020 - 09:32

Hi,
i have two issues with table:
1. When one of table cell is empty, row with this cell is with corrupted style. Extra space appears and the cursor appears at the top of the cell.
2. After table i need to add text with style. Before text should be one line. If text without any tag, then <br> works perfect, but when text is with tage appears extra space.

Here is my file: https://imgur.com/a/LuVduvD

Code:

<?php
require_once 'classes/CreateDocx.php';
$createDocx = new CreateDocx();
$createDocx->setDefaultFont('Verdana');
$createDocx->setDocumentDefaultStyles(['fontSize' => 15]);
  
$html = '<style>
    body{
        font-family: Verdana, sans-serif!important;
        font-size: 10px!important;
    }
    table {
        font-family: Verdana, sans-serif!important;
        font-size: 10px!important;
        line-height: 10px;
    }
    table.full-borders {
        width: 100%;
        border-collapse: collapse;
    }
    table.full-borders, .full-borders td, .full-borders th {
        border: 1px solid black;
        padding-left: 5px;
    }
</style>
<div>
    1. Table title:
</div>
<table class="table-full full-borders" width="600" cellspacing="0">
    <tr>
        <td width="300">1 Lorem ipsum dolor</td>
        <td width="300">Lorem ipsum dolor</td>
    </tr>
    <tr>
        <td>2 Quisque ac augue eu nibh</td>
        <td></td>
    </tr>
        <tr>
        <td>3 Quisque ac augue eu nibh</td>
        <td>augue eu nibh</td>
    </tr>
</table>
<br>
<div style="font-weight: bold;">First new line</div><br>
2 new line<br>
3 new line<br>
4 new line<br><br>
5 Second new line';

$html .= '<table style="display: none;">
        <tbody>
                <tr>
                        <td></td>
                </tr>
        </tbody>
</table>';

$createDocx->embedHTML($html);
$createDocx->createDocx('output');