OpenXML嵌套表 [英] OpenXML nested tables
问题描述
我试图将表格插入TableCell,但是当我尝试在MS Word中打开它时,出现类似"a <p> is required before a </tc>
"的消息.
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.
推荐答案
如果在Word中创建嵌套表结构,并查看生成的XML,您将看到类似以下内容的东西:
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>
根据该消息,看起来您需要在表之后和结束tc标记之前< w:p/>.
As per the message, looks like you need <w:p/> after your table, and before the closing tc tag.
这篇关于OpenXML嵌套表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!