Recently in the original write a Web page program run, there is the problem of Excel operation permissions, specifically, in the code called the following paragraph with Excel operations related to the statement,
Application Curexcelapp = new ApplicationClass ();
The prompt permission is insufficient, the specific prompt content is as follows:
Retrieving a component with a CLSID of {00024500-0000-0000-c000-000000000046} in a COM class factory failed because the following error occurred: 80070005.
Note: An unhandled exception occurred during the execution of the current WEB request. Check the stack trace for more information about the error and where the error occurred in the code. Exception Details: System. UnauthorizedAccessException: Failed to retrieve the component with the CLSID {00024500-0000-0000-c000-000000000046} in the COM class factory because the following error occurred: 80070005. ASP.net is not authorized to access the requested resource. Consider granting the ASP.NET request identity access to this resource. ASP.net has a base process identity that is used when the application has no impersonation (typically, on IIS 5, on IIS 6 for network services). If the application is/> impersonation through <identity impersonate= "true", the identity will be anonymous (usually IUSR_machinename) or authenticated request user. To grant asp.net access permissions to a file, right-click the file in Explorer, select Properties, and then select the Security tab. Click Add to add the appropriate user or group. Highlight the ASP.net account, and select the box that corresponds to the required access rights. SOURCE Error:
Line 533://Create Excel Information Row 534:object missing = System. Reflection.Missing.Value; Row 535:application Curexcelapp = new ApplicationClass (); Row 536:curexcelapp.application.displayalerts = false; Row 537:workbook Curworkbook = CurExcelApp.Workbooks.Add (Xlwbatemplate.xlwbatworksheet); |
I've had this situation before, and I know it's due to insufficient permissions on the DCOM component of Excel, so set it up as follows:
1: Install Office Excel software on the server;
2: In the "Start"-> "Run" Enter Dcomcnfg.exe start "Component Services";
3: Double-click "Component Services"-> "Computer"-> "My Computer"-> "DCOM Configuration";
4: Locate the Microsoft Excel application in the DCOM configuration, right-click on it, and click Properties to eject the Microsoft Excel Application Properties dialog box;
5: Click on the "Logo" tab, select "Interactive User";
6: Click the "Security" tab and click "Customize" on "Start and Activate Permissions". Then click on the corresponding "edit" button, in the pop-up "Security" dialog box to fill in a "Network SERVICE" User (note to select this computer name), and give it "local startup" and "Local activation" Permissions. Add the ASPNET user to the XP system and the 2000 system;
7: Remain the "Security" tab, click "Customize" on "Access", then click "Edit", and add a "network SERVICE" user in the Pop-up Security dialog box, and give "local access" permission.