I am trying to read the uploaded Excel content, but the following two methods cannot use reader.GetInt32(1)
:
I set the Excel field as "common format" and then input a number 1. --> Show InvalidCastException
I set the Excel field as "integer format" and then input a number 1. --> Show InvalidCastException
So I confirm the Excel field type, and found out it was a double
.
var fieldType = reader.GetFieldType(1);
I have two question:
Is this a setting of Excel itself which causes my get type is a Double?
How to get the Excel fields as int in my case? Because the content of the fields I should insert into the database must be int.