Forum


Replies: 1   Views: 20
Microsoft publisher - importing docx documents: issues with table cell content and strictwordstyles

Posted by mschill  · 01-07-2025 - 08:50

Hello,

I'm using phpdocx to generate a DOCX document from HTML that is later edited in Microsoft Publisher. Unfortunately, Publisher does not display the content of certain table cells correctly — especially when those cells contain multiple blocks or line breaks. The content sometimes disappears entirely.

To work around this, I’ve removed all <p> tags from my HTML and replaced them with <br /> and inline styles only. This helps in many cases, but not all.

I noticed that enabling strictWordStyles = true makes the document render correctly in Publisher (no missing content), but then I lose formatting options like background colors in table headers.

My questions:

  1. Is this a known issue with Publisher compatibility?

  2. Is there a way to apply strictWordStyles = trueonly to specific parts of the document, for example, only inside certain table cells?

For context, here's a simplified example of what gets generated:

Problematic output (Publisher breaks rendering):

<w:p>
  <w:pPr>
    <w:widowControl w:val="on"/>
    <w:pBdr/>
    <w:spacing w:before="105" w:after="30" w:line="379" w:lineRule="auto"/>
  </w:pPr>
  <w:r>
    <w:rPr>...</w:rPr>
    <w:t>Hl. Messe</w:t>
  </w:r>
  <w:r>
    <w:rPr>...</w:rPr>
    <w:br/>
    <w:t>nach Meinung</w:t>
  </w:r>
</w:p>

Working output in Publisher:

<w:p>
  <w:pPr>
    <w:widowControl w:val="on"/>
  </w:pPr>
  <w:r>
    <w:rPr>
      <w:b/>
    </w:rPr>
    <w:t>Hl. Messe</w:t>
  </w:r>
  <w:r>
    <w:rPr/>
    <w:br/>
    <w:t>nach Meinung</w:t>
  </w:r>
</w:p>

 

Kind regards,
Anna Krämer