I am using the below code
Dt_billnotlodged = (From row in out_dt_final1021.AsEnumeravke.Where(Function(x) x (“Remarks”).tostring.tolower.contains(“bill not lodged”))
Group row by a =row(“Trim”) into grp =group
Let xsum =grp.sum(Function (x) CDbl(x(“Final Reportable in INR”). tostring.trim))
Select Dt_biklboylodged.rows.add({a,xsum})). copytodatatable
When I am using this I am getting error as conversion from string “” to type double is not valid.
Dt_billnotlodged = (From row In out_dt_final1021.AsEnumerable().Where(Function(x) x("Remarks").ToString().ToLower().Contains("bill not lodged"))
Group row By a = row("Trim") Into grp = Group
Let xsum = grp.Sum(Function(x) If(Double.TryParse(x("Final Reportable in INR").ToString().Trim(), 0.0), CDbl(x("Final Reportable in INR").ToString().Trim()), 0.0))
Select Dt_biklboylodged.Rows.Add({a, xsum})).CopyToDataTable()
I want the bot to give the column values of “Trim” and “Final Reportable in INR” but when I using the code which you have given bot is giving Trim values as same as excel but Final Reportable in INR is becoming 0 in spite of value are there in excel
Dt_billnotlodged = (From row In out_dt_final1021.AsEnumerable().Where(Function(x) x("Remark").ToString().Contains("Bill not lodged"))
Group row By a = row("Trim") Into grp = Group
Let xsum = grp.Sum(Function(x) If(Double.TryParse(x("Final Reportable in INR").ToString().Trim(), 0.0), CDbl(x("Final Reportable in INR").ToString().Trim()), 0.0))
Select Dt_biklboylodged.Rows.Add({CInt(a), CInt(xsum)})).CopyToDataTable()
=> Write Range Workbook Dt_billnotlodged back to excel