qtp 读取excel单元格内容
Function GetExcelCells(ExcelPath,SheetName,SheetColumn,SheetRow)
Set ExcelBook = CreateObject("Excel.Application")
Set ExcelSheet = CreateObject("Excel.Sheet")
Set myExcelBook = ExcelBook.WorkBooks.Open(ExcelPath)
Set myExcelSheet = myExcelBook.WorkSheets(SheetName)
SheetValue = myExcelSheet.cells(SheetColumn,SheetRow).value
GetExcelCells = SheetValue
ExcelBook.Quit
set ExcelSheet = Nothing
Set ExcelBook = Nothing
End Function
Function GetExcleSheetRowsCount(ExcelPath,SheetName)
Set ExcelBook = CreateObject("Excel.Application")
Set ExcelSheet = CreateObject("Excel.Sheet")
Set myExcelBook = ExcelBook.WorkBooks.Open(ExcelPath)
Set myExcelSheet = myExcelBook.WorkSheets(SheetName)
GetExcleSheetRowsCount = myExcelSheet.UsedRange.Rows.Count
ExcelBook.Quit
set ExcelSheet = Nothing
Set ExcelBook = Nothing
End Function
ReadExcelPath="C:UsersChengshuDesktopCD混合模型测试框架文档 01-登录系统.xls"
msgbox GetExcleSheetRowsCount(ReadExcelPath,"测试用例")
For i=3 to GetExcleSheetRowsCount(ReadExcelPath,"测试用例")
msgbox GetExcelCells(ReadExcelPath,"测试用例",i,3)
msgbox GetExcelCells(ReadExcelPath,"测试用例",i,2)
next