qtp 读取DataTable,excel数据

1.qtp读取Datatable数据:

call Datatable_getvalue()

Function Datatable_getvalue()

        dim rowcount

        rowcount = DataTable.GetSheet("SheetName").GetRowCount

        for i=1 to rowcount step 1

             rowValue = DataTbale.GetSheet("SheetName").GetParameter("fieldName").ValueByRow(i)

             msgbox  rowValue

        next       
End Function

2.vbs读取excel数据

扫描二维码关注公众号,回复: 1205410 查看本文章

call get_excel_value()
call set_excel_value()

rem 读取excel中的数据
function get_excel_value()
    'create excel 对象
    Set  excelApp =  CreateObject("Excel.Application")
        '让excel 可见
    excelApp.visible = true
    Set  newBook = excelApp.Workbooks.open("g:\test.xls")
    for i=1 to 5 step 1
        '获取excel中值
        GetCellValue = excelApp.Cells(i, i)
        msgbox  GetCellValue
    next
end function

rem 写入excel中是数据
function set_excel_value()
    Set excelAppSet = CreateObject("excel.application")
    excelAppSet.visible = true
    Set newbookSet = excelAppSet.workbooks.open("g:\test.xls")
    newbookSet.worksheets(1).activate
    newbookSet.worksheets(1).cells(1,1).value = "这是我设置的值哈哈哈"
end function

猜你喜欢

转载自cjxixi.iteye.com/blog/559236
QTP
今日推荐