我在docx文件中有一个表,我想处理它并更改行的高度。到目前为止,这是我的代码
WordprocessingDocument wordDoc = WordprocessingDocument.Open("path_to_file", true) ;
Table table = wordDoc.MainDocumentPart.Document.Body.Elements<Table>().ElementAt(1);
TableRow row = table.Elements<TableRow>().ElementAt(1);
我想要的是更改表格行的高度(为零,以便我可以在某些情况下隐藏它)。问题证明比看起来更难......
答案 0 :(得分:1)
获得行对象后,尝试这段代码
TableRowHeight trh = row.OfType<TableRowHeight>().FirstOrDefault();
trh.Val = 0;
我强烈建议您使用Open XML SDK 2.5 Productivity tool,这样您就可以更好地了解自己正在使用的内容。
希望这会有所帮助。