Forum


Replies: 3   Views: 322
Export siblings 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 s.montanarella  · 09-11-2021 - 09:01

Hi',

I've this html structure:

<table id="tab1">
...
</table>
<table id="tab2">
...
</table>

I tried also to wrap both tables in a single p tag or every single table in a p tag, but result doesn't change.

Inside the resulting docx a paragraph is added between the tables, in xml I've this:

    </w:tbl>
    <w:p/>
    <w:tbl>

instead of this (manually modified in the docx after exporting):

</w:tbl>
<w:tbl>

How can I achieve this?

 

Thanks, Federico

Posted by admin  · 09-11-2021 - 09:39

Hello,

OOXML specifications require that at least one content must exist between tables. It's a MS Word requirement and it can't be avoided; if you don't add at least a paragraph between two existing tables a corrupted message may appear when the document is opened. That's the reason because phpdocx adds that empty paragraph (<w:p/>) automatically if no other content exists between two tables.

You can add a paragraph with the minimum space between tables. Please check the documentation available on https://www.phpdocx.com/documentation/snippets/tables-without-spacing-between-them. The same can be done using HTML methods.

Regards.

Posted by s.montanarella  · 09-11-2021 - 10:58

Thank you for the reply,

It doesn't seems like that. In MS Word I can create two tables without a paragraph in the middle and this is confirmed by the document.xml inside it (I have not modify directly the document.xml); the code that I quoted is copied and pasted from it. So it seems possibile!

I tried your solutions and it works, it's just a little bit odd because, obviously, inside the docx this paragraph is visible, without it would be cleaner

Thanks, Federico

Posted by admin  · 09-11-2021 - 13:22

Hello,

This requirement (adding at least one content between tables) is needed to follow OOXML specifications, otherwise a corruption message may appear (maybe some specific revisions of MS Word doesn't display it). It we generate two tables without adding at least a paragraph appears an error using MS Word 2007, MS Word 2010, MS Word 2013... and other DOCX readers. When you move a table after other table, the tables are merged into a single table in almost all cases.

Please use the recommended approach.

Regards.