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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:20:00+00:00 2026-06-18T00:20:00+00:00

I have an excel (xlsx 2010) document that contains nothing but two columns, one

  • 0

I have an excel (xlsx 2010) document that contains nothing but two columns, one for DateTime, and one for a value, of the form:

DateTime                Value
01/09/2012 00:00:00     1.23456
02/09/2012 00:05:00     1.23457
03/09/2012 00:10:00     1.23458
04/09/2012 00:15:00     1.23459

The date time column is set to a custom format (dd/mm/yyyy hh:mm:ss), and all the Times are exacally on either the 5 or 10 minute mark, the seconds are always 00.

However when I read this using:

connectionString = string.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=Excel 12.0;", filePath);
OleDbCommand sqlComm = new OleDbCommand("SELECT * FROM [Sheet1$]", new OleDbConnection(connectionString));
OleDbDataReader r = sqlComm.ExecuteReader();

The first two DateTimes are read correctly, but there after all of the DateTimes are one second less than what the file actually contains eg:

00:15:00    00:14:59
00:20:00    00:19:59

Has anyone got any idea why? Or what I can do to correct it, short of checking them manually and rounding up to the nearest minute (a viable option in this case – I think)

PS. I’ve cut and pasted the relevant lines of code for the sake of brevity, so the above code sample may not technically work, but in the real app it does read the files

  • 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-18T00:20:01+00:00Added an answer on June 18, 2026 at 12:20 am

    Converting comment to answer

    After a major revamp and a steep learning curve I can confirm that using the interop libraries read the file correctly.

    See below for sample code, based on other posts across the web

    object misValue = System.Reflection.Missing.Value;
    // COMM creates a wrapper for each object and they don't get cleaned up.  Never use 2 dots with comm
    Excel.ApplicationClass xlApp = new Excel.ApplicationClass();
    Excel.Workbooks xlWorkbooks = xlApp.Workbooks;
    Excel.Workbook xlWorkbook  = xlWorkbooks.Open(fileInfo.getFileURL(), misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue);
    Excel.Worksheet xlWorksheet = (Excel.Worksheet)xlWorkbook.Sheets[1];
    Excel.Range xlRange, r;
    
    try
    {
        xlRange = (Excel.Range)xlWorksheet.UsedRange;
    
        int rowCount = xlRange.Rows.Count;
        int colCount = xlRange.Columns.Count;
    
        for (int col = 0; col < colCount; col++)
        {
            r = (Excel.Range)xlRange.Cells[fileInfo.columnHeaders, (col + 1)];
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two Excel files contains the following structure, EmployeeAllDtl.xlsx id email name age
I have an excel file, validating one column to enter numbers only but it
I have a PowerPoint template that contains one slide and on that slide is
I'm using Excel 2010 and I have a macro that needs to load OData
I have two copies of an Excel 2010 spreadsheet, my copy for editing and
I have a .xlsx file that I wish to launch in Excel from C#.
I have 12 excel files, each one with lots of data organized in 2
I have an excel csv with a date/time column and a value associated with
I have 2 excel files: IDList.csv and Database.csv. IDList contains a list of 300
I have an Excel spreadsheet that I have exported from some other program. It

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.