opening excel error: System.Runtime.InteropServices.COMException (0x80080005): Retrieving the COM class factory for component with CLSID

前端 未结 2 1014
暗喜
暗喜 2020-12-20 01:27

I have a C# .net web app. I want a user to click a button on a webpage, the server to open an excel spreadsheet and write data to it, and the user to save the document. Th

相关标签:
2条回答
  • 2020-12-20 02:06
    1. In DCOMCNFG, right click on the My Computer and select properties.
    2. Go to Component /MyComputer/DCOMConfig
    3. Go to Microsoft Excel Application property Security
    4. In launch and Activation Permissions, click "Custamize" and add Network Service to it and give it "Local launch" and "Local Activation" permission. give same As Acess Permissions and cofiguration Permissions Press OK and thats it. i can run my application now.
    0 讨论(0)
  • 2020-12-20 02:15

    Office automation - the usage of these Excel.Application and Excel.Workbook objects - is not recommended and not supported by Microsoft. Look:

    Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.

    This means that even if yo sort out your server-side/client-side issues, you're still playing with fire, since some scenarios might work, others won't, and others will sometimes work and sometimes cause your process to hang because Excel attempts to open a pop-up notification when there isn't a console user logged onto the server. Trust me, don't do it.

    The link I provided lists several alternatives to what you're trying to do, but assuming you're planning on building relatively simple Excel sheets for your user, you're better off just creating a CSV file and sending that back to the user with the appropriate header (something like Response.ContentType="application/vnd.ms-excel") so that the returned data will be opened by Excel by default. You can see more answers to that question here.

    0 讨论(0)
提交回复
热议问题