Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
Thanks for your inquiry. Please try using the following code:
//Open document
Document doc = new Document(@"Test297\in.doc");
//Create DocumentBuilder
DocumentBuilder builder = new DocumentBuilder(doc);
//Get table from the first section of document
Table myTable = doc.FirstSection.Body.Tables[0];
//Get last row of table
Row myRow = myTable.LastRow;
//Add 10 more rows into the table
for (int rowIndex = 0; rowIndex < 10; rowIndex++)
{
//Clone last row
Row newRow = (Row)myRow.Clone(true);
//Insert created row into the table
myTable.AppendChild(newRow);
//Loop through all cells in row
foreach (Cell cell in newRow)
{
//Remove old content from the cell
//Remove paragraphs
while (cell.Paragraphs.Count > 1)
{
cell.LastParagraph.Remove();
}
//Remove content of first paragraph
cell.FirstParagraph.ChildNodes.Clear();
//Move DocumentBuilder cursor to the cell
builder.MoveTo(cell.FirstParagraph);
//Insert new content
builder.Write("This is new content");
}
}
//Save document
doc.Save(@"Test297\out.doc");
Hope this helps.
Best regards.