How to sum the row value in excel sheet

For example, I Have atttached excel sheet. In this i need to sum the mark1, mark2 and mark3 values and put in the total (column name) also calculate the percentage(column name) in the same excel sheet.
how can i do this?
Merge.xlsx (7.7 KB)

Hi @jamunatj

Use for each row
Use row(“total”). ToString=row(0). ToString+row(1). ToString+row(2). ToString

Use row(“Percentage”)=row(total).ToString/3
Then use write range to print the total and Percentage
Thanks
Ashwin.S

1 Like

How to add the null value in sixth row and eight row while running it showing like this Merge.xlsx (7.7 KB)

Based on this you are getting error right
Thanks
Ashwin.S

yes ,while running it showing
object cannot be cast from DBnull to the other types .

@jamunatj

Try like below
Use assign activity for these below things

row(“total”)=Convert.Toint32(row(0).ToString)+Convert.Toint32(row(1).ToString)+Convert.Toint32(row(2).ToString)

 row(“Percentage”)=Convert.Toint32(row(total).ToString)/3

If you have decimal numbers, use Convert.ToDouble instead of Convert.ToInt32

1 Like

Merge.xlsx (7.7 KB)
How to add the null value in sixth row and eight row while running it showing
object cannot be cast from DBnull to the other types
I have followed like this
row(“total”=(Convert.ToInt32(row(“Mark1”))+Convert.ToInt32(row(“Mark2”))+Convert.ToInt32(row(“Mark3”))).ToString

@jamunatj Try like below

 row("Total")=(Convert.ToInt32(if(row(“Mark1”).Tostring<>"",row(“Mark1”),0))+Convert.ToInt32(if(row(“Mark2”).Tostring<>"",row(“Mark2”),0))+Convert.ToInt32(if(row(“Mark3”).Tostring<>"",row(“Mark3”),0)))
1 Like

Its working. Thanks.

1 Like