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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T17:05:52+00:00 2026-06-06T17:05:52+00:00

I opened *.htm file with Excel Application ( Microsoft.Office.Interop.Excel ). It was parsed excellent!

  • 0

I opened *.htm file with Excel Application (Microsoft.Office.Interop.Excel). It was parsed excellent! So I can work with it. For more speed, I’m trying to get data from Excel Range and insert into System.Array and work with it:

Excel.Range range = ExcelWorksheet.get_Range("A1", "H1500"); // get all values
System.Array dataArray = (System.Array)(range.Cells.Value2); // insert into array

Problem is with data type. If Excel cell has time or date format, range.Cells.Value2 makes:
12.06.2012 to 41072 (Excel Cell Type – date)
14:48 to 0,616666666666667 (Excel Cell Type – time)
If I get single value form Excel Cell, I get correct value (with Cells.Text.ToString()):

ExcelWorksheet.get_Range("A1", "A1").Cells.Text.ToString()

Task: I need get values from Excel Sheet as they are, just like text, not as another type.
And don’t want Excel thinks instead of me 🙂

  • 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-06T17:05:54+00:00Added an answer on June 6, 2026 at 5:05 pm

    Why don’t you just convert the returned values to the format you need? The FromOADate method of DateTime is designed for this (see http://msdn.microsoft.com/en-us/library/1ad4d8d6(v=vs.80).aspx). For example, the time value returned represents a fractional portion of a 24 our day. Hence the following example will output “14:48”:

    double oleDateTime = 0.616666666666667;
    DateTime dt = DateTime.FromOADate(oleDateTime);
    string time = dt.ToString("H:mm");
    Console.WriteLine(time);
    

    As far as the date values, you can use the same approach. The only difference will be the fact that the value from Excel (double) would be greater than zero because it is includes a date portion (not just time). The following will yield “12.06.2012”:

    dt = DateTime.FromOADate(41072);
    string date = dt.ToString("dd.MM.yyyy");
    Console.WriteLine(date);
    

    To further illustrate, in the case that you are dealing with date AND time (returned Excel value is greater than zero), the following will yield “6/12/2012 2:48:00 PM”:

    dt = DateTime.FromOADate(41072.616666666666667);
    Console.WriteLine(dt.ToString());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have opened Excel file in my C# WinForm Application adding reference to Microsoft.Office.Interop.Excel.dll
I Opened/Created a new Word document dynamically on FormLoad using: using Word = Microsoft.Office.Interop.Word;
I received a spam message that had a .htm attachment. I opened the file
I opened a files in vim using gf command.which opened a file that the
I have opened one file with following way: fp = fopen(some.txt,r); Now in this
I opened hello.cpp. Why isn't there File -> Compile -> hello.cpp? What is an
I opened a javaScript file in a javaScript time.... document.write(<script src='newnote.js' type='text/javascript'></script>); is there
I'm working on a .NET application which exports CSV files to open in Excel
I have tried to change file association of .htm file in XP, and here
Currently, I have a GWT based application /app.htm It displays an openId login button

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.