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 8780611
In Process

The Archive Base Latest Questions

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

In the application we have a wizard with multiple tabs. On the first tab

  • 0

In the application we have a wizard with multiple tabs. On the first tab we can select a excel sheet path using a browse button. The moment you select the excel, excel file contents are loaded in a dataset (everything in correct format including DATE fields). Then click Next to go to the next wizard tab.

But if the file is open program loads the excel and this time with all the date fields in General format.
eg: 6/22/2006 as 38890

We are trying to find if the excel is open or being used by another format as:

    bool IsFilebeingUsed(FileInfo file)
    {
        FileStream stream = null;

        try
        {
            stream = file.Open(FileMode.Open, FileAccess.Read, FileShare.None);
        }
        catch (IOException)
        {
            return true;
        }
        finally
        {
            if (stream != null)
                stream.Close();
        }
        return false;
    }

The way we are trying to read the excel is as follows:

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

Can anyone tell whats wrong with the application or code?

  • 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:06:08+00:00Added an answer on June 13, 2026 at 8:06 pm

    More updated question can be found here.

    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

Hi Sitepoint wizard people, Say we have an admin application that has multiple users
I have converted an iPhone application using the wizard like thing in XCode into
I have application where i have two view controllers my first view and second
I have a series of pages (in a wizard type application). After collecting user's
Hey guys..I am designing a set-up wizard using CPropertySheet and CpropertyPage in MFC application...I
I have use wizard window in extjs application. It open at center of window
I have a MFC wizard based application (CPropertySheet, CPropertyPage) created with vS2008. I am
I have an asp.net wizard control in my web application I am calling a
I have an MVC web application in asp.net 3.5 How can I convert that
On my WinForm application I have a button (printBtn) and I want to print

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.