Forum


Replies: 5   Views: 831
Delete blank rows under the 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 neukanri  · 20-10-2020 - 08:40

 

I'm replacing what I created in HTML with the word template with replaceVariableHTML.

At that time, I am creating a table, but a blank row under the table is created. Is there a way to remove this blank line?

Posted by neukanri  · 20-10-2020 - 08:43

source

<div class="section">
    <p class="sSectionTitle">TITLE</p>
    <p class="indentStyle">
        <span class="sectionNumber">NUMBER</span> AAAAAAA
    </p>
    <ul class="numList">
        <li>BBBBBBBBBBBBBBBBBbb
        <table class="teigakuTable" border="0" cellpadding="0" cellspacing="0" style="width:98%;">
                <tr>
                    <td style="width:10%">&nbsp;</td>
                    <td style="width:35%">1. AAAAAA</td>
                    <td style="width:55%">BBBB</td>
                </tr>
                <tr>
                    <td style="width:10%">&nbsp;</td>
                    <td>2.BBBBBB</td>
                    <td>CCCCCC</td>
                </tr>
                <tr>
                    <td style="width:10%">&nbsp;</td>
                    <td>3.CCCCCC</td>
                    <td>DDDDDDDDDDDDDDDDDDDDD</td>
                </tr>
        </table>
        </li>
        <li>COMMENTTTTTTT</li>
    </ul>
</div>

Posted by admin  · 20-10-2020 - 08:54

Hello,

We have run the following code using phpdocx 10:

$docx = new CreateDocx();

$html = '
<div class="section">
    <p class="sSectionTitle">TITLE</p>
    <p class="indentStyle">
        <span class="sectionNumber">NUMBER</span> AAAAAAA
    </p>
    <ul class="numList">
        <li>BBBBBBBBBBBBBBBBBbb
        <table class="teigakuTable" border="0" cellpadding="0" cellspacing="0" style="width:98%;">
                <tr>
                    <td style="width:10%">&nbsp;</td>
                    <td style="width:35%">1. AAAAAA</td>
                    <td style="width:55%">BBBB</td>
                </tr>
                <tr>
                    <td style="width:10%">&nbsp;</td>
                    <td>2.BBBBBB</td>
                    <td>CCCCCC</td>
                </tr>
                <tr>
                    <td style="width:10%">&nbsp;</td>
                    <td>3.CCCCCC</td>
                    <td>DDDDDDDDDDDDDDDDDDDDD</td>
                </tr>
        </table>
        </li>
        <li>COMMENTTTTTTT</li>
    </ul>
</div>
';
$docx->embedHTML($html);

$docx->createDocx('output');

And there's no blank rows after the table when opening the document. We have opened the output with MS Word (2007, 2010, 2013, 2016, 2019, 365 and Online) and LibreOffice (5, 6 and 7) and in all cases the output is correct. What DOCX reader are you using? Maybe you are applying some extra style or your template has some extra content?

If you send to contact[at]phpdocx.com the most simple script (and the template) that illustrates the issue and the output you get we'll check them.

Regards.

Posted by neukanri  · 21-10-2020 - 00:33

 

thank you for your answer.

When I checked here, I couldn't confirm the blank line.

However, when I create the following consecutive tables, a blank row is created between them.

<table  border="0" cellpadding="0" cellspacing="0" style="width:98%;">
<tbody><tr><th>THHHHH</th><td>TRRRR</td></tr></tbody></table>

<table  border="0" cellpadding="0" cellspacing="0" style="width:98%;">
<tbody><tr><th>THHHHH</th><td>TRRRR</td></tr></tbody></table>

<table  border="0" cellpadding="0" cellspacing="0" style="width:98%;">
<tbody><tr><th>THHHHH</th><td>TRRRR</td></tr></tbody></table>

<div>DIV<p>P</p>DIV</div>

 

Posted by admin  · 21-10-2020 - 05:21

Hello,

That's a MS Word limitation. MS Word requires adding at least one paragraph between tables. If you open MS Word you can try it: after adding a table to a document and then you try to add another table, MS Word doesn't allow it unless you add at least a paragraph.

You can get the minimum space between tables adding a paragraph between them and setting the spacing and font-size to the minimum value:

https://answers.microsoft.com/en-us/msoffice/forum/msoffice_word-mso_win10-mso_2013_release/remove-space-after-table/1f651f2d-e630-4d53-ab1e-a3a7418faf21?auth=1

http://www.wordbanter.com/showthread.php?t=123470

You can change spacing and font-size values with phpdocx.

Using removeWordContent from DOCXPath you can force removing that paragraphs between tables that MS Word requires, but please note that then MS Word may display a corrupted document error when trying to open it.

Regards.

Posted by neukanri  · 22-10-2020 - 05:23

 

understood. Thank you very much.