We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to sum numbers in table's column using .NET

Hi,
I have been working with an issue where we have to add a line at the end of the table which will has total of the above date. For example, we have a table which has two columns like this, the last row of the table must be added automatically after the table ends. Can I know if there is any function that aspose supports image.png (3.5 KB)

@sindhuV

In your case, we suggest you please insert the SUM(ABOVE) field in the last row of table. You need to add a row to table and insert this field to get the desired output. Please check the following code example. Hope this helps you.

Document doc = new Document(MyDir + "input.docx");
Table table = (Table)doc.GetChild(NodeType.Table, 0, true);

table.Rows.Add(table.LastRow.Clone(true));
foreach (Cell cell in table.LastRow.Cells)
{
    cell.RemoveAllChildren();
    cell.EnsureMinimum();
}

DocumentBuilder builder = new DocumentBuilder(doc);
builder.MoveTo(table.LastRow.LastCell.LastParagraph);
builder.InsertField(@" =SUM(ABOVE) ");
doc.UpdateFields();
doc.Save(MyDir + "output.docx");

Hi @ tahir.manzoor
It worked. Thank you