开发者

error while creating excel file in c# webapplication

开发者 https://www.devze.com 2023-02-13 17:24 出处:网络
i am gettingfollowing error while creatin开发者_JS百科g the excel file System.UnauthorizedAccessException:

i am getting following error while creatin开发者_JS百科g 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


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消