Calculate sum of column in excel sheet

i have column named as marks
i want to calculate sum of marks column
no of rows for marks column are not fixed.

So if you read the excel sheet into a datatable using read range.

You can then use an assign

MarksSum = Datatable.AsEnumerable.Sum(Function(x) Convert.ToDecimal(x(“Marks”).ToString.Trim)

3 Likes

@Ananya1,
In a write cell activity you can pass this, cell number should be
“MarksColumns” + Convert.ToString(yourDataTable.Rows.Count+1)

Convert.ToString((TryCast((From s In yourDataTable.AsEnumerable() Select Decimal.Parse(s("Marks").ToString())), IEnumerable(Of Decimal))).Sum())

@Ananya1,
Try the below Approch.

  1. read the data of column Marks and store the output in datatable name OutPutDT
  2. Use below assign activity to get sum
    SumData = OutputDt.AsEnumerable.Sum(function(x) Convert.ToDecimal(x(“Marks”))).ToString

I hope this helpful you.

2 Likes

i want to use write range since in one excel there are two sheets Sheet1, Sheet2

in Sheet2 ,i want total of column

WriteTotal.xaml (4.5 KB)

Check this xaml, it will read sheet1 and in sheet2 it will write the total alone, Assumed sheet two already has the same data.

1 Like

Is there a specific cell within Sheet 2 you want to write the total sum value to?