zoukankan      html  css  js  c++  java
  • Windows server 2008 64bit计划任务运行使用了excel 2003 32bit .net开发组件的程序遇到的问题

    代码:

    View Code
     1             try
     2             {
     3                 excelApplication = new Excel.ApplicationClass();
     4                 excelWorkBooks = excelApplication.Workbooks;
     5                 excelWorkBook = ((Excel.Workbook)excelWorkBooks.Open(excelOpenFileName, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value));
     6                 excelWorkSheet = (Excel.Worksheet)excelWorkBook.Worksheets[excelActiveWorkSheetIndex];
     7                 excelApplication.Visible = false;
     8 
     9                 return true;
    10             }
    11             catch (Exception e)
    12             {
    13                 CloseExcelApplication();
    14                 MessageBox.Show("(1)没有安装Excel 2003;(2)或没有安装Excel 2003 .NET 可编程性支持;\n详细信息:"
    15                     +e.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
    16                 //throw new Exception(e.Message);
    17                 LabMessage.Text = "(1)没有安装Excel 2003;(2)或没有安装Excel 2003 .NET 可编程性支持;\n详细信息:"+ e.Message;
    18                 return false;
    19             }
     

    问题:

    Windows server 2008 64-bit计划任务运行使用了excel 2003 32-bit .net开发组件的程序,打开excel2003,报错

    System.FormatException: Index (zero based) must be greater than or equal to zero and less than the size of the argument list.

    通过跟踪代码,发现是第3行,new ApplicationClass()对象时报错

    解决办法:

    On 64 bit system with 32 bit Office try this:

    1.         Start

    2.         Run

    3.         mmc -32

    4.         4.File

    5.         Add Remove Snap-in

    6.         Component Services

    7.         Add

    8.         OK

    9.         Console Root

    10.     Component Services

    11.     Computers

    12.     My Computer

    13.     DCOM Config

    14.     Microsoft Excel Application

    15.     右键打开属性对话框

    16.     点击"安全"选项卡,

    18.     "启动和激活权限","配置权限",都选择为自定义,

    19.     然后依次点击它们的编辑,把计划任务执行用的账号添加进去,并加入所有的权限...

    如果以上解决办法无效,再试试下面的:

     运行dcomcnfg打开组件服务

     依次展开"组件服务"->"计算机"->"我的电脑"->"DCOM配置"

     找到"Microsoft Excel应用程序"

     右键打开属性对话框,点击"标识"选项卡,依次选择The interactive user或者This user试试。

    如果还不行,看看执行计划任务的账户是否在administrator群组中,如没有,请加入administrator群组再测试一下。

  • 相关阅读:
    jqGrid 属性、事件全集
    把app(apk和ipa文件)安装包放在服务器上供用户下方法
    c#中如何获取本机MAC地址、IP地址、硬盘ID、CPU序列号等系统信息
    Visual Studio Installer打包安装项目VS2015
    小白入门服务器压测
    PHP正则表达式快速查找
    PHP创建创建资源流上下文实现携带cookie访问
    js中文转Unicode编码与解码
    PHP的fpm配置学习笔记
    微信公众号PHP生成二维码海报的几个小扩展
  • 原文地址:https://www.cnblogs.com/thomaswang/p/2323323.html
Copyright © 2011-2022 走看看