Web测试
VBS 对EXCEL 操作 的类
上一篇 /
下一篇 2013-02-20 17:02:53
/ 个人分类:测试总结
Class Excel
'****************************************
'函数功能:获取特定单元格值
'filepath:文件地址
'sheetname:表名
'row:行
'column:列
'****************************************
Function readExcel(filePath,sheetname,row,column)
Dim excelAPP
Set excelApp=CreateObject("excel.application")
excelApp.Workbooks.Open(filePath)
readExcel=excelApp.Worksheets(sheetname).cells(row,column).value
excelApp.Quit
Set excelApp=Nothing
End Function
'****************************************
'函数功能:在特定单元格写入值
'filepath:文件地址
'sheetname:表名
'row:行
'column:列
'str:写入的值
'****************************************
Function writeExcel(filePath,sheetname,row,column,str)
Dim excelAPP
Set excelApp=CreateObject("excel.application")
excelApp.Workbooks.Open(filePath)
excelApp.Worksheets(sheetname).cells(row,column).value=str
excelApp.Quit
Set excelApp=Nothing
End Function
'****************************************
'函数功能:获取表中被使用的行数
'filepath:文件地址
'sheetname:表名
'****************************************
Function rowCount(filePath,sheetname)
Dim excelAPP
Set excelApp=CreateObject("excel.application")
excelApp.Workbooks.Open(filePath)
rowCount=excelApp.Worksheets(sheetname).UsedRange.Rows.Count
excelApp.Quit
Set excelApp=Nothing
End Function
'****************************************
'函数功能:获取表中被使用的列数
'filepath:文件地址
'sheetname:表名
'****************************************
Function columnCount(filePath,sheetname)
Dim excelAPP
Set excelApp=CreateObject("excel.application")
excelApp.Workbooks.Open(filePath)
columnCount=excelApp.Worksheets(sheetname).UsedRange.columns.Count
excelApp.Quit
Set excelApp=Nothing
End Function
End Class
Function ExcelClass
Set ExcelClass=New Excel
End Function
'QTP10使用DLL在QTP中写代码有智能提示
收藏
举报
TAG: