This project has moved and is read-only. For the latest updates, please go here.

Insert Table Into Table

Nov 22, 2011 at 8:32 PM

I am looking to insert a 1 row, 3 column table into an existing 1 column table.

Is this possible? If so, is there an example?



Nov 22, 2011 at 10:00 PM
Hi tposhea,

here is an example of how to do what you want.

using (DocX document = DocX.Create("test.docx"))
// Insert a 1 column, 3 row Table.
Table t1 = document.AddTable(1, 3);
t1.Design = TableDesign.TableGrid;

// Get the first Paragraph out of the first cell out of the first row.
Paragraph p = document.Tables[0].Rows[0].Cells[0].Paragraphs[0];

// Insert the Table t2 before the Paragraph p.
Table t2 = document.AddTable(1, 3);
t2.Design = TableDesign.TableGrid;

// Save the document to disk.

Kind regards,