创建TableCellProperties
并删除TableCellBorders
后,单词document变得不可读,我得到:
Word在test.docx中发现了不可读的内容。您要恢复本文档的内容吗?如果您信任此文档的来源,请单击“是”。
我使用的代码:
TableCellProperties cellProp = new TableCellProperties(
new TableCellBorders(
new TopBorder()
{
Val =
new EnumValue<BorderValues>(BorderValues.Nil),
},
new BottomBorder()
{
Val =
new EnumValue<BorderValues>(BorderValues.Nil),
},
new LeftBorder()
{
Val =
new EnumValue<BorderValues>(BorderValues.Nil),
},
new RightBorder()
{
Val = new EnumValue<BorderValues>(BorderValues.Nil),
}
)
);
TableCell tc = new TableCell();
tc.Append(cellProp);
TableRow trTest = new TableRow();
trTest.Append(new TableCell(tc.OuterXml));
trTest.Append(new TableCell(new Paragraph(new Run(new Text("B")))));
trTest.Append(new TableCell(new Paragraph(new Run(new Text("C")))));
trTest.Append(new TableCell(new Paragraph(new Run(new Text("D")))));
trTest.Append(new TableCell(new Paragraph(new Run(new Text("E")))));
trTest.Append(new TableCell(new Paragraph(new Run(new Text("F")))));
t.Append(trTest);
BorderValue
设置为Nil
,因为None
似乎没有删除边框。 MS Word自动恢复过程之后,该文件就可以了。谁会引起这样的问题?
答案 0 :(得分:0)
问题解决了!
每个表单元格应包含/以Paragraph
对象结尾,因此解决方案是:
tc.Append(cellProp);
tc.Append(new Paragraph());
好像我在this question中遇到了同样的问题,但是没有错误。