[英]change height of table row with C# Open XML and Word docx documents
我在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);
我想要的是將表行的高度更改為零(以便在某些情況下可以將其隱藏)。 問題被證明比看起來困難得多。
在擁有行對象之后,嘗試這段代碼
TableRowHeight trh = row.OfType<TableRowHeight>().FirstOrDefault();
trh.Val = 0;
我強烈建議您使用Open XML SDK 2.5生產力工具 ,這樣您可以更好地了解所使用的工具。
希望這可以幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.