Input string was not in a correct format - Excel

I have a row with empty column and when tried to sum it, it is failing with string not in a correct format.
Ex; Document Amount = $1200.99

dtOpenInoviceFiltered.AsEnumerable.Sum(Function(x) Convert.ToDouble(x(“Document Amount”).ToString.Replace("$","").Trim)).ToString

any leads?

@Vishwanth_Raya
as you mentioned the presence of empty column values it is a hint for the failure.

Give a try on:
dtOpenInoviceFiltered.AsEnumerable.Where(Function ( r ) Not String.IsNullOrWhitespace(r(“Document Amount”).toString)).Sum(Function( r ) Convert.ToDouble(r(“Document Amount”).ToString.Replace("$","").Trim))

2 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.