OpenXML nested tables

本秂侑毒 提交于 2020-01-23 06:27:07

问题


I am trying to insert a Table into a TableCell, but when I try to open it in MS Word I get a message like: "a <p> is required before a </tc>".

When I open the file in compatibility mode the table formatting looks perfect but the table lines are missing. Inserting simple text into the cell works fine, the issue only happens when I try to insert a whole table.

Inserting the Table in the document outside the other table also works fine.


回答1:


If you create a nested table structure in Word, and look at the resulting XML, you will see something like:

      <w:tc>
        <w:tcPr>
          <w:tcW w:w="4621" w:type="dxa"/>
        </w:tcPr>
        <w:tbl>..</w:tbl>
        <w:p/>
      </w:tc>

As per the message, looks like you need <w:p/> after your table, and before the closing tc tag.



来源:https://stackoverflow.com/questions/4485225/openxml-nested-tables

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!