ado读取excel文件中数据的2种方式
上一篇 /
下一篇 2007-06-12 19:04:07
/ 个人分类:QTP
'ado读取excel文件中数据的2种方式
y}*h-t"D\T!M0a G0FW+|^Q0Dim cnn,rst,strnn
51Testing软件测试网;l:D/A p
\ ~8G~Wstrnn="Provider=MSDASQL.1;Persist Security Info=False;Data Source=ExcelFiles;"
`
L;`#j9aQ @$T+R0strnn=strnn & "Initial Catalog=c:\REDB00000811.xls"
51Testing软件测试网z_I8M[kset cnn=createobject("ADODB.connection")
3Gb4Q+Gk0set rst=createobject("ADODB.recordset")
51Testing软件测试网[3zj_}cwicnn.open strnn
7yTr
N
L'@ VY0'使用表名跟美元符号
51Testing软件测试网3K!Qmb2grst.open "select * from [sheet1$]",cnn,1,1
"UeH&ca)y0rst.movefirst
q1he{~w"nm6vn0tmp0=rst.fields(0)
51Testing软件测试网T3T`7fAtmp1=rst.fields(1)
.\-]^+V:L0tmp2=rst.fields(2)
E9s%S`2wZw"e)Iz0tmp3=rst.fields(3)
&G6I:dd!aZe]9H,}0tmp4=rst.fields(4)
!~8FuL ~h5s0tmp5=rst.fields(5)
xpZ:p-a f
t0rst.movenext
#J\2mJ}Z#Oi0tmp6=rst.fields(0)
^;z#EE\4~0rst.close
51Testing软件测试网$y"\)D-g#F0s:od'与特定地址 (为示例, $ Sheet 1 [ A1:B10 ]) 指定区域。
^7d[3q1[Y.b({0rst.open "select * from [sheet1$A3:E5]",cnn '其实,数据是A4到E5的数据。A3所在的一行数据不 '取。
51Testing软件测试网&?L:CcWrst.movefirst
!J"x!nbQ.? b;}[,s0tmp7=rst.fields(0)
51Testing软件测试网8E\5gv4\ Erst.movenext
$|W:{[?(^.e'Mo0tmp8=rst.fields(0)
"z9xk3vg
GQ7Vp(\0tmp9=rst.fields(4)
51Testing软件测试网Vp;h:cV
i
O
Jrst.close
e;g}y}2`0cnn.close
51Testing软件测试网+E*c@8rQhHSet rst=nothing
51Testing软件测试网m\,B
F~@*[;Y/S5_]rSet cnn=nothing
51Testing软件测试网 jD/Ltz/tb|
相关阅读:
- QTP链接Oracle (fishy, 2007-6-11)
- QTP无法识别对象的补充(原创) (shaofei19820625, 2007-6-11)
- 相对路径[1] - 调用Reusable Action (winfood, 2007-6-12)
- 相对路径[2] - 关联对象库 (winfood, 2007-6-12)
- 相对路径[3] - 引用函数库 (winfood, 2007-6-12)
- QTP中连接数据库 (yzgonline, 2007-6-12)
- 学习QTP方法 (fishy, 2007-6-12)
- d大家有需要的就下吧 (zj_2782495, 2007-6-12)
- QTP与Oracle数据库链接脚本 (panqy163, 2007-6-12)
- 测试运行过程中改变QTP窗口状态 (panqy163, 2007-6-12)
收藏
举报
TAG:
QTP