Free Support Forum -

Working with a template doc

I have a pretty complex table (vertical text, merged cells, background shading, and custom fonts) that I don't want to create in code. I have been trying to import a single "template" table (from a file) that contains merge fields in it. What I want to be able to do is load the template document then insert the table in a new document and update the merge fields then add the table again (and update the merge fields...). The solution to this has evaded me so far.

Any thoughts?

<?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" />Mike Rogers

Hi Mike,

Thank you for considering Aspose.

There seem to be no major obstacles to achieve this thanks to flexibility of the v3 object model. Here’s an approximate solution:

Document srcDoc = new Document(“ImportTable.doc”);
// Extract the table
NodeCollection nodes = srcDoc.GetChildNodes(NodeType.Table, true);
Table table = (Table)nodes[0];

Document dstDoc = new Document();

for (int i = 0; i < 10; i++)
// Add the table to the current section
Table cloneTable = (Table)dstDoc.ImportNode(table, true);

// Perform mail merge on dstDoc



However, if you need your table to be repeated and populated with data, maybe mail merge with regions will be a simpler solution?