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

  • Home
  • SEARCH
  • 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 8451425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:14:12+00:00 2026-06-10T11:14:12+00:00

I’m working on VS2008 .NET3.5 with a Office 2003 doc (.xls). I’m using Microsoft.Office.Interop.Excel

  • 0

I’m working on VS2008 .NET3.5 with a Office 2003 doc (.xls). I’m using Microsoft.Office.Interop.Excel to access to a document.

This works fine for my purpose but fails whenever I try to get a Date.

The way I’m using is the most common:

object date= xlWorkSheet.get_Range("E" + i, "E" + i).Value2;
double doubleDate = double.Parse(date);
DateTime finallyDate = DateTime.FromOADate(doubleDate);

The date I have stored is 01/12/1961 (in Italian means first december and if I open excel it tolds me 1 december 1961).

When I run my app it happens that the value of the double become 15011.0 and when the finallyDate value is 2/4/1941 that’s not right!

How can I solve this problem? Is there any way to convert (also manually) that 15011 number?

Thank you!!

  • 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-10T11:14:14+00:00Added an answer on June 10, 2026 at 11:14 am

    Get the Value property instead of Value2, then you will be able to work with a Date object. You may need to cast it as (DateTime).

    What you get instead with Value2 is the floating point value of the Date.

    For example, check out my spreadsheet below, where A1 contains a date:

    Spreadsheet

    Then in Excel, I add my reference to Microsoft.Office.Interop.Excel, and grab the Value and Value2 properties like so:

    var excel = new Excel.Application();
    
    var workbook = excel.Workbooks.Open(@"C:\Test\Test.xlsx");
    var worksheet = (Excel.Worksheet)workbook.Sheets[1];
    
    Excel.Range range = worksheet.get_Range("A1");
    
    var rangeAsValue = range.Value;
    var rangeAsValue2 = range.Value2;
    
    Console.WriteLine(rangeAsValue);
    Console.WriteLine(rangeAsValue2);
    
    Console.ReadLine();
    

    I get this output:

    Output

    Interestingly, if you try this in a .Net 4.5 application, it still works but the type of var is resolved as dynamic for rangeAsValue and rangeAsValue2, and you lose your intellisense.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I am reading a book about Javascript and jQuery and using one of the
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I have this code to decode numeric html entities to the UTF8 equivalent character.
We're building an app, our first using Rails 3, and we're having to build

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.