3
votes

i am getting following error while creating the excel file

System.UnauthorizedAccessException: Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80070005 Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)). at QA.CreateExcel.createDoc() in e:\~~CreateExcel.cs:line 33

i am using this code.

private Office.Excel.Application app =new Office.Excel.Application();

m using fw 4.0 and its a webapplication

2
Do not automate excel in a web application. It won't work well.SLaks
but its required, no other optionvakas
support.microsoft.com/kb/257757 And, there are other options.SLaks
There are several libraries that allow you to produce and read Excel and other office documents without office.C. Ross

2 Answers

2
votes

Office 2007/2010 file formats are XML files wrapped inside of zips and can be created server-side without needing Office installed. Some searching online will reveal solutions for simplifying the task of doing so.

For example, Codeplex has a project that makes doing so almost as easy as automating Excel, but with none of the issues you are encountering.

http://www.codeproject.com/KB/office/ExcelPackage.aspx

0
votes

Well, install Excel on the server and give IIS the rights to use it. This will not be stable, and chances are that your hosting provider won't even let you (unless you are hosting it on your own servers). This would also cost you an Office license..

Microsoft advises against installing Office on servers because of stability and reliability issues. http://support.microsoft.com/kb/257757 focusses on some of these problems and also mentions some alternatives.