通过openxml将表格插入到单词中,以及如何设置适合单词的宽度

时间:2016-01-09 15:52:06

标签: openxml

我想通过openxml创建一个word文件并在其中插入一个表。现在我不知道如何设置网格的宽度以适应word文件。请帮我。 感谢

1 个答案:

答案 0 :(得分:2)

表格宽度可以通过第二行代码设置。

其余部分仅用于说明如何将属性附加到表

TableProperties tblProps = new TableProperties();

tableWidth = new TableWidth() { Width = "5000", Type =TableWidthUnitValues.Pct };

TableStyle tableStyle = new TableStyle() { Val = "TableGrid" };
tblProps.Append(tableStyle, tableWidth);

table.Append(tblProps);