使用C#将行添加到Word文档

时间:2018-11-28 09:34:08

标签: c# ms-word

我使用C#在Word文档中创建了一个表,我试图在表的末尾添加行。现在我有4行的桌子。

我试图这样添加:

sudo apt install python3-pip

Source。如果我将int reading package lists... Done Building dependency tree Reading state information... Done Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable distribution that some required packages have not yet been created or been moved out of Incoming. The following information may help to resolve the situation: The following packages have unmet dependencies: python3-pip : Depends: python3-setuptools but it is not going to be installed Recommends: python3-dev (>= 3.2) but it is not going to be installed E: Unable to correct problems, you have held broken packages 设置为表格的开头,则将行添加到表中,而当我尝试将其设置为 int rowIndex=1; this.Tables[1].Rows.Add(this.Tables[1].Rows[rowIndex]); 时,则将其行添加到表的末尾。

我需要在表的最后一个新行 ,所以我尝试了rowIndex=1;,但随后得到了:

  

未处理的异常:System.Runtime.InteropServices.COMException:所请求的集合成员不存在。      在Microsoft.Office.Interop.Word.Rows.get_Item(Int32索引)

1 个答案:

答案 0 :(得分:0)

尝试:

object oMissing = System.Reflection.Missing.Value;
this.Tables[1].Rows.Add(ref oMissing);