DataTable.ImportSheet operation failed.Invalid file

老子叫甜甜 提交于 2019-12-11 07:15:14

问题


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"
  • filepath is the path of my workbook which conatins many excel sheets (scripts)

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

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

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

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

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 ?


回答1:


UFT syntax for importing a worksheet is:

DataTable.ImportSheet FileName, vtSrcSheet, vtDstSheet 

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)

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

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



来源:https://stackoverflow.com/questions/40002360/datatable-importsheet-operation-failed-invalid-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!