我试图使用DocX nuget包创建/操作Word .docx文件。尝试插入使用Novacode DocX nuget包的表时出错
在他们所提供的下面的示例的文档:
// Place holder for a Table.
Table t;
// Load document a.
using (DocX documentA = DocX.Load(@"C:\Example\a.docx"))
{
// Get the first Table from this document.
t = documentA.Tables[0];
}
// Load document b.
using (DocX documentB = DocX.Load(@"C:\Example\b.docx"))
{
/*
* Insert the Table that was extracted from document a, into document b.
* This creates a new Table that is now associated with document b.
*/
Table newTable = documentB.InsertTable(t);
// Save all changes made to document b.
documentB.Save();
}// Release this document from memory.
当代码执行我接收插入表时的错误: 表newtable的= documentB.InsertTable(T);
错误: System.InvalidOperationException {“序列不包含任何元素”}
我很茫然,为什么这正在发生。我查看了正在插入的表“t”,它看起来具有所有的属性。我不清楚是什么导致了错误。
任何帮助将不胜感激。