QTP读取excel的内容

上一篇 / 下一篇  2009-09-05 23:17:49

  1. ******************************************
  2. ' ** 函数名:GetCell
  3. ' ** 输 入:filePath,sheetName,rowNum, colNum
  4. ' ** filePath --- 文件路径
  5. ' ** sheetName --- 表名
  6. ' ** rowNum --- 行号
  7. ' ** colNum --- 列号或列名
  8. ' ** 功能描述: 此函数实现取得Excel表中某一单元格值的功能
  9. '** 调用方法:GetCell("c:\db.xls","Sheet1",1,1)
  10.                    或getcell("c:\db.xls","Sheet1",1,"A")
  11. '****************************************************
  12. Function GetCell(filePath,sheetName,rowNum,colNum)
  13. Set excObj = createobject("Excel.Application")
  14. Set excFile = excObj.workbooks.open(filePath)
  15. Set excSheet = excFile.worksheets(sheetName)
  16. getCell = excSheet.cells(rowNum,colNum) '取单元格的值
  17. End Function

TAG:

 

评分:0

我来说两句

Open Toolbar