Hi,
While reading from Excel file, I am summing the amount column using the following expression. Sometimes this is giving me the error given below. Can you please help?
Reading the data from Excel. I am not sure why it thinks “Amount” field is datetime format.
It happens only sometimes.
Thanks a lot,
Total Amount = dt.AsEnumerable.Sum(Function(row) Math.Abs(Convert.ToDouble(row(“Amount”)))).ToString
Assign – Total Amount: Invalid cast from ‘DateTime’ to ‘Double’.
Can you share cell format information and screenshot of the cell which causes the exception in the excel sheet? And which activity do you use to read the sheet?
I think mainly there are 2 approach to solve the matter.
First approach, read the sheet as Display style (Preserve Format)
Second approach, modify LINQ expression to be able to handle it even if input is datetime.