Windows 2008 R2服务器上的Microsoft.Office.Interop.Excel程序集问题。 [英] Issue with Microsoft.Office.Interop.Excel assembly on windows 2008 R2 server.

查看:162
本文介绍了Windows 2008 R2服务器上的Microsoft.Office.Interop.Excel程序集问题。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的任务是,我们需要以编程方式运行excel宏。



在当地环境中它工作正常,当我们按照以下步骤操作时: - < br $>


1)Microsoft.Office.Interop.Excel.Application appExcel = new Microsoft.Office.Interop.Excel.Application();



2)Microsoft.Office.Interop.Excel.Workbook workBook = appExcel.Workbooks.Open(" FilePath",

Type.Missing,Type.Missing,Type.Missing ,Type.Missing,

Type.Missing,Type.Missing,Type.Missing,Type.Missing,

Type.Missing,Type.Missing,Type.Missing,Type .Missing,

Type.Missing,Type.Missing);



3)appExcel.Run(" Macro name"," $ W $ 5",1,0," $ Q $ 11:$ Q $ 112",Type.Missing,Type.Missing,Type.Missing,

Type.Missing,Type.Missing, Type.Missing,Type.Missing,Type.Missing,Type。缺少,

Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing,

Type.Missing,Type.Missing, Type.Missing,Type.Missing,Type.Missing,Type.Missing,

Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing);

注意: -



在localhost上一切正常,宏正在执行。



但是当在IIS(版本7.5)中托管时,功能无法正常工作。



为此,我们所做的更改包括: -



a)控制面板 - >管理工具 - >组件服务

计算机 - >我的电脑 - > DCOM配置 - > Microsoft Excel应用程序 - >属性



i)在安全选项卡中,我们通过添加用户(IUSR)并给予他所有

访问权限来自定义所有权限。



执行这些更改后,我们可以创建Interop.Excel的实例。

但我们无法打开工作簿。



ii)在Microsoft Excel应用程序peroperties的Identity选项卡中,默认情况下为启动用户。已选中。



将值更改为交互式用户后我们可以打开工作簿。

但是我们无法运行宏。



iii)C:\ Windows \ system32 \\\ n \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\对于这个文件夹属性,在安全选项卡中我们创建了用户(IUSR)并给予完全控制。

现在我们能够运行宏并获得所需的输出,即使在IIS托管的IIS上运行网站。



问题: -



在我们将更改移至生产后进行所有更改后服务器,我们在DCOM配置中找不到Microsoft Excel应用程序。

Microsoft Office未完全安装在生产服务器中。服务器上只安装了Excel软件。



我们在下面的代码行中得到空引用异常。



Microsoft.Office.Interop.Excel.Workbook workBook = appExcel.Workbooks.Open(" FilePath",

Type.Missing, Type.Missing,Type.Missing,Type.Missing,

Type.Missing,Type.Missing,Type.Missing,Type.Missing,

Type.Missing,Type。 Missing,Type.Missing,Type.Missing,

Type.Missing,Type.Missing);



我们的生产服务器在windows上运行2008 R2。



任何人都可以建议正确的方法来解决这个问题。

Our task is , we need to run the excel macro through programatically.

In local environment it was working fine, when we follow the below Steps:-

1) Microsoft.Office.Interop.Excel.Application appExcel = new Microsoft.Office.Interop.Excel.Application();

2) Microsoft.Office.Interop.Excel.Workbook workBook = appExcel.Workbooks.Open("FilePath",
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing);

3) appExcel.Run("Macro name", "$W$5", 1, 0, "$Q$11:$Q$112", Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing,Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing,Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
Note:-

On localhost everything is working fine and the macro is getting executed.

But the functionality is not working as expected when hosted in IIS(version 7.5).

For this to work the changes which we have done are:-

a) Control Panel -> Administrative Tools -> Component Services
Computers -> My Computer -> DCOM Config -> Microsoft Excel Application -> Properties

i) Here in the security tab we have Customized all the permissions by adding user(IUSR) and giving him all
access permissions.

After doing these changes we are able to create instance of Interop.Excel.
But we could not open the workbook.

ii) In Identity tab of Microsoft Excel Application peroperties, by default "The launching user" is selected.

After changing the value to "The interactive user" we are able to open the workbook.
But we could not run the macro.

iii) C:\Windows\System32\config\systemprofile

In this location we have created Desktop folder. For this folder properties, in the security tab we have created user(IUSR) and given full control.
Now we are able to run the macro and getting the desired output even when running the application on IIS hosted site.

Issue:-

After making all the changes when we have moved the changes to production server, there we could not find Microsoft Excel Application in DCOM Config.
Microsoft Office is not completely installed in production server. Only Excel software was installed on the server.

We are getting null reference exception at below line of code.

Microsoft.Office.Interop.Excel.Workbook workBook = appExcel.Workbooks.Open("FilePath",
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing);

Our production server is running on windows 2008 R2.

Could any one please suggest the right way to resolve this issue.

推荐答案

W


5",1,0,"
5", 1, 0, "


Q


这篇关于Windows 2008 R2服务器上的Microsoft.Office.Interop.Excel程序集问题。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆