How to sum the row data

in this i want to sum the row data i don’t want to use the loop to add it is their any function are their to sum the row data .

1 Like

any one .

@akshaygm12 if it is present in excel we can add.

Check if this helps out ,

DataTable1.Columns.Add(“TotalVal”, typeof(Double));
DataTable1.Columns[“TotalVal”].Expression = “C1+D1+E1”;

Create a new column , which would be based on a expression , and in the expression formula , give in the column names …

maybe try something like this …

its very crude , and can be structured better ,


1 Like


You first Read your Excel and store it in a DataTable dta

Then the Sum of each row will be stored in a List , Let us take List A

List A= (From p In dta.Select
            Select(Convert.ToString(p.ItemArray.Sum(Function(x) If(IsNumeric(x), Convert.ToDouble(x),0))))).ToList

List A will Contain Sum of Each Row.

I have not tested the code, Please try this.



thanks its working. :slight_smile:

1 Like