• DCOM权限问题.不能导出Excel


    最近在做一个项目时要求导出Excel文件,本来用的是比较原始的办法,直接生成字符串发运到客户端.这当然不会出什么问题. 毕竟不是真正的Excel文件看起来总是不舒服.于是改用COM组件来生成Excel文件.用COM其实也挺简单的:).在本地测试没发现任何问题一发到服务器上就出了问题. 因为是菜鸟不知道怎么看错误信息.就在这个问题上折腾了好几天.最后终于上我发现了错误信息!!于是立马百度一下~问题就解决了~.

    异常信息:Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80070005.

    问题原因: 远程用户无法运行Excel应用程序
    解决办法:(百度上什么都能搜出来~)
    直接把原文贴下面.

    Example Application

    The problem is that by default Microsoft Excel as a COM object can only activated by the following accounts:

    • Administrator
    • System
    • Interactive

    When you are running your ASP.Net account on Windows XP your web application is running as the ASPNET account.

    The way to resolve this issue is to edit the DCOM configuration settings for the Microsoft Excel Application object.

    Configure DCOM

    • Go to the Start-Run menu item.
    • Type in "DCOMCNFG" and hit enter.
    • This should load the "Component Services" MMC (you can also load from Administrative Tools - Component Services"
    • Expand "Component Services"
    • Expand "Computers"
    • Expand "My Computer"
    • Select the "DCOM Config" item
    • Select the "Microsoft Excel Application" item.
    • Right click and select Properties
    • Select the Security Tab and you should see the following:



       
    • Under "Launch and Activation Permissions" select the "Customize" option.
    • Click the "Edit" button


       
    • Click the "Add" button to add a new account to the list.
    • On the dialog that is displayed click the Locations button

      (this is because by default your domain will be selected and we need a local account)

      In this dialog scroll the list to the top (sometimes the first item is not visible) but scroll to the top and select the first item which is your computer name. In the list below "CCROWE" is the name of my computer.



       
    • Click the OK button
    • On the dialog that is displayed enter "ASPNET" as the account name.


    • Click the OK button

    Note: A quicker way is to just enter the computer name and the account so in my case that would be:

    ccrowe\ASPNET 

    • Now make sure you select the following options for the "ASP.NET Machine Account"
       
      • Local Launch         : Allow
      • Remote Launch        : [blank]
      • Local Activation     : Allow
      • Remote Activation    : [blank]

         

    These settings can be seen below:

    Click the OK button and test your web application again and it should work fine.

  • 相关阅读:
    Ubuntu 16.04安装双显卡驱动方法收集
    Log4j的日志级别分析(转)
    Linux下使用Curl调用Java的WebService接口
    OSGI是什么
    Netflix是什么,与Spring Cloud有什么关系
    Ubuntu 16.04安装SQLite Browser操作SQLite数据库
    Eclipse关联JDK源码
    Markdown中插入图片技巧收集
    Mac OS X中Launchpad的图标添加删除方法(添加方法别试了,和Linux很大区别)
    Java反编译工具-JD-GUI
  • 原文地址:https://www.cnblogs.com/heys/p/385958.html
Copyright © 2020-2023  润新知