Creating xlsx file from asp.net code - c#

Hi i am using c# code for creating xlsx file. i have added the reference to my bin for Microsoft.Office.Interop.Excel Version 12.0.0.0
It Works ok on my local machine. But when i upload it to the server it throws the error in the page where i am creating the xlsx file
"Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
"
can anybody plz help

You are getting the error because excel isn't installed on the server.

You shouldn't be automating Office in ASP.NET. It can lead to myriad performance and scale issues on your server. Office itself is designed for interactive desktop usage, not unattended execution in a non-GUI app. Here is the authoritative reference from MS on the matter:
http://support.microsoft.com/kb/257757
With that being said, there are third-party libraries designed specifically for manipulation of Excel in ASP.NET. OfficeWriter is one example:
http://www.officewriter.com

Related

COM exception on Office Automation - Windows Service C#

I have developed a windows service that would read doc / docx files and replace values based on database records and convert the replaced document as PDF.
Used Microsoft Office Interop DLL for the conversion. The service is hosted in two different machines ( Win Server 2008 R2 Enterprise - 64 Bit ). I had to
set the Identity as Interactive User in DCOM settings to solve the exception :
Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046}failed due to the following error: 8000401a.
Initially I couldn't not find the DCOM entry for Microsoft Windows Document. So I had to change some settings in the registry following this link. This got me working in one system ( the service working fine). However, in another system, the service threw an exception Attempted to read or write protected memory. This is often an indication that other memory is corrupt on WorkDocument.ClearFormatting() code.
To overcome that I had changed the build properties form "Any CPU" to "x86". The service worked fine for some times but it just started to throw the exception (Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046} failed due to the following error: 8000401a) again. I could not figure out when the service starts throwing this exception. If I restart the service it works normal but not for too long.
I know using MS interop is not recommended for services. But i came to know about this issue only after the complete development of the service as I had no problems running the program as windows application on my system for testing purposes.
Tried with google and have even solved the issue but the solution seems to be a temporary one for one server and the other seems to work fine. Kindly guide me to overcome the situation.
Thanks

Running an ASP.NET application that uses Excel on a Windows Server

I have developped an asp.net application using microsoft office interop excel on my local machine, everything worked well, an excel file was build.
When I deploy the application on my server and run it, I am getting the following exception :
Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046}
failed due to the following error: 80040154 Class not registered
(Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))
I have done some research on forums, I know that it's probably because excel is missing on the server, however I am not able to find an appropriate solution, knowing that install excel on the server is not really possible. And also knowing that I would like to keep interop as my library.
Does anyone have a solution?
First, what ever you are trying to do, try to do it without using Excel (or any Office) interop in ASP.NET. Microsoft strongly discourages it, as it might not work as you expect.
There are plenty possibilities to do this without the 'client application' Excel, for example EPPlus.
Second, the problem with your code is the lack of Office installed or the wrong version of Office (also consider 32- or 64-bit platform versions).

COM Exception 80040154 When creating an Excel Application

I'm trying to run my application on a server which does not and will not have Office installed on it.
using EXCEL = Microsoft.Office.Interop.Excel;
...
EXCEL.Application app = new EXCEL.Application();//Exception thrown here
The code is working fine on my own system, but on the server it gives the following exception:
Unhandled Exception: System.Runtime.InteropServices.COMException:
Retrieving the COM class factory for component with CLSID {...} failed
due to the following error: 80040154 Class not registered
(Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
both systems are 32bits, and I've copied the excel Interop dll next to application's exe. I've also installed O2010PIA.
any lead?
The Office Interop assemblies are runtime-callable wrappers (RCW) that allow you to interoperate with a copy of Office that's installed on the system via the COM API that it exposes.
The error message indicates that Excel isn't installed, exactly what I'd expect. You can't use the Interop assemblies on a machine without Office.
I'm trying to run my application on a server which does not and will
not have Office installed on it.
As Joe said, you'll need to install Excel for Interop to work. If you're dead-set against that, consider third-party alternatives. In general, Microsoft did not recommend installing Office on your server and using it with Interop - that being said, it will work (at least most of the time).

Using Microsoft.Office.Interop.Word in asp.net

I'm attempting to leverage the Microsoft.Office.Interop.Word dll in my asp.net application. Long story short, an internal web based document management/editing system requires access to a MS Word flesch-kincaid value on an ad-hoc basis. I have no problem using this dll in a console app, but I can't get the right permissions to it when accessed via asp.net.
Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046} failed due to the following error: 80070005 Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)).
I've tried everything in this forum thread with no luck. I'm using .Net 4.0 on Win7, I've tried both 32 and 64 bit versions of MS Word. I'm also anticipating more head-aches once I deploy to our server running Windows Server 2008 R2 Standard
I would use the openXML SDK instead for the reason todda.speot.is gives
http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=5124
http://www.codeproject.com/Articles/87711/Manipulate-Docx-with-C-without-Microsoft-Word-inst

error when opening excel file

i have a web service that reads data from excel using Microsoft.Office.Interop.Excel. It works fine on my local machine but when i upload it on a server it gives the following error
Server was unable to process request. ---> Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80070005.
i googled and tried to follow the suggestion of DCOMCNFG-> component services-> computers-> my computer-> com+ appications but then i dont find the Microsoft excel to change rights.
Office 2003 is installed in server and file i am trying to open is 2003 too.
Please help!!
Thanks
You won't find Excel, you'll have to find the matching CLSID and alter the Activation/Launch permissions.
Standard Disclaimer: Unattended execution of office on the server is not recommended by Microsoft, but a lot of us do it happily (myself included).

Categories

Resources