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

Free Support Forum - aspose.com

Dynamically doing summation of a single column when rows range is dynamic


I want to calculate the sum of the column , but the rows are dynamic in no.

Like there may be 10 records or may be lesser or more.I want to dynamically calculate the sum of the column .

Kindly help me.




Well, you may do it, see the sample code below for your reference:

Workbook workbook = new Workbook(FileFormatType.Excel2007Xlsx); 
Worksheet sheet=workbook.Worksheets.Add(“Test”);
sheet.Cells[0, 0].PutValue(11);
sheet.Cells[99999, 0].PutValue(22);
//Set the formula to get sum of the first column
sheet.Cells[0, 1].Formula="=SUM(A:A)";
MessageBox.Show(sheet.Cells[0, 1].StringValue);
workbook.Save(@“c:\temp\test.xlsx”, FileFormatType.Excel2007Xlsx);

Thank you.