Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error while creating excel file in c# webapplication

Tags:

c#

asp.net

excel

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

like image 735
vakas Avatar asked Mar 08 '26 10:03

vakas


1 Answers

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

like image 190
David Avatar answered Mar 10 '26 23:03

David



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!