cell in Excel with Date format is read by ADO.NET as NULL

Posted on 2004-11-28
Last Modified: 2008-01-09
My problem is the title itself.

I have tried to read an excel file using ADO.NET (as opposed to automation, which forces me to create an instance of an excel process).

Using a data adapter, I call the Fill() method and pass a datatable (most examples on the internet feature passing a dataset).

In the datatable, I am able to read the cells whose values has a string format.
But somehow, the cells with date format are null when I try to read it.

Did I miss some setting?
Should I set something in the datatable variable before using it?
Or do I really have to use a dataset instead? This should not matter, right?
Question by:DrkLight
    LVL 25

    Expert Comment

    Hi DrkLight,

    Strange, I don't seem to have this problem. Could you show your code (including your connection string).

    are you sure the date in your excel in in the format of your regional settings

    Author Comment

    Thanks for the reply.

    I've also thought of this.

    I checked the style of the date cell formatting and nothing seems to be strange.
    In fact, I even downloaded from the internet a different program that does almost the same thing (reads excel files).  That program is able to read the date cell on another file that it creates.
    But when I use it to read my excel file, it also fails.
    I have tried changing the date cell to various formats availabale for a date, but it still returns null.

    I have tried printing out the contents of the read excel file (whether by datatable or by datareader).
    Either way, the date cells are returned as null. =(

    There was one cell though where the date was shown.
    This cell shows the date in the style with the asterisk (I am using WinXP J-OS so its kind of hard to explain)

    Author Comment

    Thanks RonaldBiemans, but I found the solution to my problem.

    As advised by this link,
    I added the "IMEX=1" extended property and was able to retrieve my data already...

    My excel data is kind of awry (not the standard table fromat) so this works fine for me.
    LVL 25

    Expert Comment

    Great, then get a refund for your points at comminity support

    Accepted Solution

    Closed, 125 points refunded.

    Community Support Moderator
    Experts Exchange

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Article by: jpaulino
    XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String ( Literal, only instead of starting and ending with w…
    1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now