DataTable.ImportSheet操作失败.文件无效 [英] DataTable.ImportSheet operation failed.Invalid file

查看:350
本文介绍了DataTable.ImportSheet操作失败.文件无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在UFT上运行Excel测试,有时会收到错误号20012,即"DataTable.ImportSheet操作失败.文件无效".

I'm running Excel tests on UFT and sometimes I get the error number 20012 which is "DataTable.ImportSheet operation failed.Invalid file".

这是我导入脚本的方式:

This is my way of importing the script:

DataTable.ImportSheet filepath,scriptname,"Action2"

  • 文件路径是我的工作簿的路径,其中包含许多Excel工作表(脚本)

    • filepath is the path of my workbook which conatins many excel sheets (scripts)

      脚本名称:我要运行的脚本的名称

      scriptname: the name of the script that I want to run

      动作2:包含脚本可能包含的所有可能关键字的所有调用.

      Action2: contains all the call of all possible keywords that may script can contains.

      请任何帮助,为什么我会收到此错误.

      Any help please, why I'm getting this error.

      问题是,这对于某些脚本以及在3或4个运行时间后运行的脚本来说效果很好.

      The problem is that this is working well for some scripts and for others not after 3 or 4 run times.

      我认为问题出在Excel本身而不是代码上,在使用Excel 2016和UFT 12时是否有任何问题?

      I think the problem is on Excel itself and not on the code, are there any problems when working with Excel 2016 and UFT 12 ?

      推荐答案

      用于导入工作表的UFT语法为:

      UFT syntax for importing a worksheet is:

      DataTable.ImportSheet FileName, vtSrcSheet, vtDstSheet 
      

      这意味着您需要将文件名(和路径)传递给excel文件,将要导入的源工作表的名称(或索引)作为参数传递,然后将您希望该工作表作为目标传递给目标文件(例如全局"或"Action1"等)

      This means you need to pass as parameters the filename (and path) to the excel file, the name (or index) of the source sheet you want to import, and then the destination you want this sheet to be (for example "Global" or "Action1" etc)

      除非scriptname恰好是您要导入的工作表的确切名称,否则会出现此错误.

      Unless scriptname happens to be the exact name of the worksheet you are trying to import you will get this error.

      如果要导入整个文件,请使用Datatable.Import而不是Datatable.ImportSheet

      If you want to import the whole file use Datatable.Import instead of Datatable.ImportSheet

      这篇关于DataTable.ImportSheet操作失败.文件无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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