Showing posts with label MS Office. Show all posts
Showing posts with label MS Office. Show all posts

Tuesday, April 6, 2010

Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80070005.

Please refer the following solution:

Note: If still it doesn't work You have to Impersonate a specific user in code.
This solved one of my problem where I was creating a Excel on runtime and saving it to server.

The problem is that by default Microsoft Excel as a COM object can only activated by the following accounts:

  • Administrator
  • System
  • Interactive
So you can impersonate section of code which needs the above privilege of a user and then you can undo the impersonate when you are done with it.

Here is the solution:

Problem Reading Excel Dates. Excel date gets converted to Double value in DotNet

Dates are stored in Excel as doubles, only displayed as dates per the formatting on the sheet. The Value2 property on the cells returns the stored long value. You need to convert this value to the date yourself. You can use the DateTime.FromOADate() method to do this conversion.

Example Code:


double dateTimeInExcelFormat = Convert.ToDouble(((Range)workSheet.Cells[5, 3]).Value2);
DateTime date = DateTime.FromOADate(dateTimeInExcelFormat);