Free Support Forum - aspose.com

How to add new rows to a table in word document

hi,

how can I add rows dynamically to an existing table on a word document? I will also have to add textboxes into those new rows.

see the attached the document for a table example I am talking about. how do I refer to a specific table? (my document contains lots of tables) is there a bookmark for the table??

thanks

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry. I think that you can clone the last row in the table. For example see the following code.

Document doc = new Document(@"Test024\table.doc");

//Get table

Table awTable = doc.FirstSection.Body.Tables[0];

//Clone last row

Row newRow = (Row)awTable.LastRow.Clone(true);

//Add cloned row to table

awTable.Rows.Add(newRow);

//Save document

doc.Save(@"Test024\out.doc");

Hope this helps.

Best regards.