I'm trying to create/manipulate Word .docx files using the DocX nuget package.
In the documentation they provide the following example:
// 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.
When the code executes I receive an error when inserting the table: Table newTable = documentB.InsertTable(t);
Error: System.InvalidOperationException {"Sequence contains no elements"}
I am at a loss as to why this is occurring. I have looked at the table "t" that is being inserted and it appears to have all of the properties populated. I am unclear as to what is causing the error.
Any help would be greatly appreciated.