'######读取data.xlsx中的行列数及第一个单无格中的数据#########
Set ExcelApp=CreateObject("Excel.Application")
Set ExcelPath=ExcelApp.Workbooks.Open("D:\UFT\data.xlsx")
Set ExcelSheet=ExcelPath.Worksheets("Sheet1").UsedRange
rowCount=ExcelSheet.Rows.count
msgbox rowCount
columnCount=ExcelSheet.Columns.count
msgbox columnCount
msgbox ExcelSheet.cells(1,1)
ExcelPath.Close
ExcelApp.Quit
set ExcelApp = Nothing
'####################读取data.xlsx中的数据结束############
'#######比对flight中fromCity中的数据
Set ExcelApp=CreateObject("Excel.Application")
Set ExcelPath=ExcelApp.Workbooks.Open("D:\UFT\data.xlsx")
Set ExcelSheet=ExcelPath.Worksheets("Sheet1").UsedRange
rowCount=ExcelSheet.Rows.countSet fromCity = WpfWindow("HPE MyFlight Sample Applicatio").WpfComboBox("fromCity")
For i = 0To rowCount-1 Step 1If fromCity.GetItem(i)= ExcelSheet(i+1,1) Then
print i& " is right"Else
print i& " is wrong"EndIfNext'#######比对flight中fromCity中的数据 结束####################
'#####在aa.xlsx的sheet1中A1中写入数据wwwSet ExcelApp= CreateObject("Excel.Application")
Set ExcelPath=ExcelApp.Workbooks.Open("D:\UFT\aa.xlsx")
Set ExcelSheet=ExcelPath.Worksheets("sheet1")
ExcelSheet.Columns(1).Clear
ExcelSheet.cells(1,1)="www"
ExcelPath.Save
ExcelPath.Close
ExcelApp.Quit
Set ExcelApp = Nothing'#####在aa.xlsx的sheet1中A1中写入数据结束www
'写人数据函数化Sub writeexcel(path,sheet,str)
Set ExcelApp= CreateObject("Excel.Application")
Set ExcelPath=ExcelApp.Workbooks.Open(path)
Set ExcelSheet=ExcelPath.Worksheets(sheet)
ExcelSheet.Columns(1).Clear
ExcelSheet.cells(1,1)=str
Set ExcelSheet=Nothing
ExcelPath.Save
ExcelPath.Close
ExcelApp.Quit
Set ExcelApp = NothingEndSub'调用函数Call writeexcel("D:\UFT\aa.xlsx","Sheet2","123456")