I have an empty table (about twenty rows and 5 columns). I want to insert a new row in the middle (roughly), with the first column having some text and then the other four having simple html (i.e one word colored blue in p tags), and then I want to print the .GetText() of the whole row after each cell have been changed.
I’ve attached the code that I am running.
Thanks,
Hi Rob,
var doc = new Document(MyDir + “RowGetTextIssue.docx”);<o:p></o:p>
var builder = new DocumentBuilder(doc);
Aspose.Words.Tables.Table table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, 0, true);
var newRow = (Aspose.Words.Tables.Row)table.LastRow.Clone(true);
int insertLoc = (table.Rows.Count - 1) / 2;
table.Rows.Insert(insertLoc, newRow);
int i = 0;
foreach (Aspose.Words.Tables.Cell cell in newRow.Cells)
{
if (++i == 1)
{
Aspose.Words.Run run = new Aspose.Words.Run(doc, "Row Header");
cell.FirstParagraph.Runs.Add(run);
continue;
}
cell.RemoveAllChildren();
var para = new Aspose.Words.Paragraph(doc);
cell.AppendChild(para);
builder.MoveTo(para);
builder.InsertHtml(" Blue text..: "
}
Console.WriteLine(newRow.ToString(SaveFormat.Text));
Console.ReadLine();