Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8780475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:03:30+00:00 2026-06-13T20:03:30+00:00

Few days back I asked a question but could not find enough answers. I

  • 0

Few days back I asked a question but could not find enough answers. I analyzed the problem a bit more and decided to create a new thread. If I should have not, let me know or close the question.

I have an OPEN excel file with a column in Date format with some values like 6/22/2006, 6/22/2006. I am trying to read the excel using OleDbDataReader. The code is like this:

string sql = string.Format("SELECT * FROM [{0}]", excelSheetName);
internal OleDbCommand command = new OleDbCommand();
command.CommandText = sql;
OleDbDataReader oleRdr = command.ExecuteReader();

DataTable dataTable = new DataTable();
datatable.TableName = excelSheetName;
dataTable.Load(oleRdr);

I am using the connection string as:

string connectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\ExcelData\sample.xls;Extended Properties='Excel 8.0;HDR=No;IMEX=1'";

The problem is I am not able to read the date values in correct (DateTime) format. I believe everything is treated as numeric format. So my result is

6/22/2006 as 38890

After reading some articles on internet, I understood my column is having multiple datatypes and then I changed my connection string as:

string connectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\ExcelData\sample.xls;Extended Properties="Excel 8.0;HDR=No;IMEX=1;ImportMixedTypes=Text;TypeGuessRows=0"";

But still I am not able to read the excel in correct format. Any suggestions on this. It looks a weird problem to me. Please let me know if I to need to provide some more information.

Note: Also make a note that when my excel file is closed both the connection strings give me the correct data. Also for new doc formats.xlsx we are using Microsoft.ACE.OLEDB.12.0.

EDIT

I tried editing the registry as well….but no relief.
But when I changed the value IMEX = 0 or IMEX = 1 it is working fine again. Can any one tell the exactly what is happening?

EDIT 2
When I changed HDR=Yes still everything worked good. Any help please? I could not find enough help on internet.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T20:03:31+00:00Added an answer on June 13, 2026 at 8:03 pm

    So I solved the issue in a unsatisfactory way. I noticed with my analysis and experiments and ultimately concluded that when the excel is open in MS-Excel and we try reading the excel in C# using OleDbDataReader, some of the DataTypes are not read properly and unfortunately DateTime being one of them in my case.

    As a solution, at present we are forcing the user to close the excel at the time we are reading the excel file. I even noticed that if the excel is open in Read-only mode in MS-Excel, then the data read is correct for all DataTypes including DateTime. But when opened in Write-Mode, then data read is incorrect.

    These are my analysis results and I know/agree that the results are a bit weird. If any one disagree or have something else in their mind, then let me know and please correct me.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Few days back, in an interview one question was asked to me as, Are
I asked a similar question a few days ago, but there's no harm in
I asked a similar question a few weeks back but it failed to attract
Few days back I put a question regarding mapping two classes Message and MessageStatusHistory
A few days back, I started using new OpenCV-Python interface, cv2 . My question
This is a follow-up question to an answer I gave a few days back
A few days back I felt this question to be dumb and dint post
I asked a question a few days ago and no one seems to know
Recently few days I run into a weird problem of php not able to
A few days back, while writing an answer for this question here on overflow

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.