QTP导入EXCEL文件

上一篇 / 下一篇  2007-06-13 10:44:36 / 个人分类:QTP

51Testing软件测试网 t)a,Mk2b+OA

找了很久,结合资料和VB。终于可以从EXCEL中读入数据51Testing软件测试网3X0rF ?'y%W(g

51Testing软件测试网8` hj*q X?'wk%y

Dim conn,rst,filename51Testing软件测试网 B ^]6I5X,~ICt p z$D
Dim var51Testing软件测试网R wR^(Rl `
filename="E:\test.xls"51Testing软件测试网(w7_x/R{I
Set conn= createobject("ADODB.Connection")51Testing软件测试网C0inqJ I*gZq
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source="&filename&";Extended Properties='Excel 8.0;hdr=yes'"
EdBE.s wSD0s0Set rst= createobject("ADODB.Recordset")51Testing软件测试网MT0p'?\a-a(x
rst.Open "select  *   from [Sheet1$] " ,conn,1,151Testing软件测试网bxtx#Rk
result = rst.RecordCount
#t,h'FdYO0msgbox "RecordCount = "&result51Testing软件测试网"x2CL+Tr)c
 While Not rst.EOF 
O8J8EpWa0  var = rst.fields("a")
0{(U)bOsS.U}0  msgbox "Data="&var
Z@x#Kl D;i*J pZr7Q0      rst.MoveNext          
#jlF6`R~%i6]`)n };B0   Wend
l[(tLD/H0rst.close51Testing软件测试网ci/I8{d6ZlZ Z%_
Set rst=nothing

{:I AXxco051Testing软件测试网1m5a4Eb:]G

 51Testing软件测试网'ey pP:J6k


TAG: QTP

 

评分:0

我来说两句

我的栏目

日历

« 2024-03-19  
     12
3456789
10111213141516
17181920212223
24252627282930
31      

我的存档

数据统计

  • 访问量: 9292
  • 日志数: 16
  • 建立时间: 2007-06-12
  • 更新时间: 2007-06-21

RSS订阅

Open Toolbar