我已经下载并开始使用 DocX library .我有一个名为 template.docx
的文档正在加载到内存中。我在该文档中有一个表,其中包含 id = 241
。我想通过它的 id 获取该表并向其中添加行。我怎样才能做到这一点?这是我的代码:
using (DocX document = DocX.Load("template.docx"))
{
int tableId = 241, i = 0;
Table t = //here I need to find the table
foreach(DataGridViewRow row in produseFacturate.Rows)
{
i++;
//here I want to add rows to the table
}
}
最佳答案
我自己找到了解决方案。
因为 document.Tables
是一个列表,我可以这样调用它:
Table t = document.Tables[3]; // I found out that the table index is actually 3;
关于c# - 使用 DocX 库在 DOCX 文件中查找表格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15977202/