Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 88054

How to get the Excel fields(double) as int

$
0
0

I am trying to read the uploaded Excel content, but the following two methods cannot use reader.GetInt32(1):

  1. I set the Excel field as "common format" and then input a number 1. --> Show InvalidCastException

  2. 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);

enter image description here

I have two question:

  1. Is this a setting of Excel itself which causes my get type is a Double?

  2. 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.


Viewing all articles
Browse latest Browse all 88054

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>