Excel data with 4 columns data i want to sum the individual column data in one LINQ Query

Hi have an excel file i want to
InputFile.xlsx (8.5 KB)
write the sum at end the each row of the column
how can we intergrade all the columns data sum in one linq query
instead of writing multiple linq queries can we write in one linq query for this

also attaching sample excel file

  • Read Range into datatable
  • Add Data Column for total
  • For Each Row in Data Table
    ** Assign CurrentRow(“Total”) = CDbl(CurrentRow(“Column 1 To Add”).ToString) + CDbl(CurrentRow(“Column 1 To Add”).ToString) + etc…
  • Write Range back to Excel

The only part of this that LINQ can do is the For Each. LINQ doesn’t interact with Excel. LINQ isn’t necessarily faster than For Each, by the way. Why not just do it with activities like I showed above?

Here is the solution.
Query → {"Compare", "Amount", "Bill", "Tax"}.Select(Function (x) dt_InputFile.AsEnumerable.Sum(Function (row) If(IsNumeric(row(x)), CDbl(row(x)), 0))).ToArray()
Workflow →