学无止境

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

在用Excel生成report时,报错,跟踪代码,错误是在

private void CreateExcel()
  {
   this._App = new Excel.ApplicationClass();   
   this._App.Visible = false;
   this._App.DisplayAlerts = false;
  }

红色字代码抛出异常:"Access is denied"

原因:服务器上Excel组件权限受到限制

解决:

方法1.在Component Services - Computers - My Computer - DCOM Config - Microsoft Excel应用程序 的Properties - Security页上:

Launch and Activation Permissions: 选择Customize, Edit, Add 相应的Group或者Users, 加了Everyone,各个Permissions选中

Configuration Permissions: 选择Customize, Edit, Add 相应的Group或者Users, 加了Everyone,各个Permissions选中

Everyone应该换为某个用户组,但是这部分我还不了解,先用Everyone代替。

方法2.在web.config中,在authentication tag下面加上:

<identity impersonate="true" userName="machinename\administrator" password="admin password" />

其中"machinename\administrator"是服务器管理员组中的某个用户

 

参考:http://www.webdeveloper.com/forum/archive/index.php/t-58132.html

posted on 2008-10-21 13:35  路过蜻蜓  阅读(2155)  评论(0编辑  收藏  举报