OLEDB connection to Excel & Datatypes

  • Thread starter Thread starter ryanbreakspear
  • Start date Start date
R

ryanbreakspear

Hi all,

On one machine when I read data from a column (DataRow[x].ToString())
from Excel it reads it as a floating point number. On another machine
it reads as a date (e.g. 12/10/1899 3:50:24 AM). In the connection I'm
passing "IMEX=1". I want it to be a floating point number, does anyone
have any ideas how I can do this?

I'm using Excel 11.5612.5606

Thanks in advance

Ryan
 
Are you dropping the value into a cell that is formatted as date?

--Mary
 
No, the value was a number, formatted as a number.

I did manage to find a solution, the first row in the column was a
date, and Excel treated the whole column as a date. Not sure why it's
got this functionality. Found a registry setting which increases the
number of rows it checks to guess the data type.

Thanks anyway

Ryan
 
If you want your code to do the correct interpretation of the data
every time, then apply the desired formatting to the range prior to
insertion and you don't need to muck with the registry.

--Mary
 
Back
Top