Free Support Forum - aspose.com

Subtotal and Total

I have been using aspose.cells and using excel grouping i can get the total and subtotals but i am unable to get the same using aspose.words. Even this link is not giving answer to my question because total is stroed i your table itself.

http://www.aspose.com/docs/display/wordsnet/How+to++use+nested+mail+merge+regions

so please give me some work around using aspose.words


Hi,


Thanks for your inquiry. In your case, I suggest you to use SUM(ABOVE) field. Please insert this field in the last row of table as shown in following code snippet.

<span style=“font-size:10.0pt;
font-family:“Courier New”;color:#2B91AF;mso-font-kerning:0pt;mso-ansi-language:
PL;mso-no-proof:yes”>Document<span style=“font-size:10.0pt;font-family:
“Courier New”;mso-font-kerning:0pt;mso-ansi-language:PL;mso-no-proof:yes”> doc
= new Document(MyDir

  • “in.docx”);

    <o:p></o:p>

DocumentBuilder builder = new DocumentBuilder(doc);

Table table = (Table)doc.GetChild(NodeType.Table, 0, true);

builder.MoveToCell(0, table.Rows.Count - 1, 0, 0);

builder.InsertField(@"=SUM(ABOVE)");

builder.MoveToCell(0, table.Rows.Count - 1, 1, 0);

builder.InsertField(@"=SUM(ABOVE)");

doc.UpdateFields();

doc.Save(MyDir + "AsposeOut.docx");


Hope this helps you. Please let us know if you have any more queries.

Thanks for the reply.

half of my query is resolved but i also want to provide subtotals in the middle of document.
Lets say i want the subtotal by employee in middle of document and grand total at the end of the page.
End of the page total i can get from this but how to get subtotals?

Hi,


Thanks for your inquiry. It would be great if you please share some more detail about your scenario along with input and output Word document.