共同探讨QTP相关问题

DataTable使用方法

上一篇 / 下一篇  2008-08-08 22:25:57 / 个人分类:QTP

51Testing软件测试网7v"|4h'w!Dj*riL

Function ImportSheet(ExcelSheetName)51Testing软件测试网6Dz$e9z2j)^(z X
   Err.Clear51Testing软件测试网f)_4M"N)gt
   Dim sheetCount
}9N6IAMv0   sheetCount = DataTable.GetSheetCount51Testing软件测试网K;{Zh X0h;v'i!A
   For i = 1 to sheetCount51Testing软件测试网1x;XtUU(Z
    If strcomp(ExcelSheetName, DataTable.GetSheet(i).Name) = 0 Then51Testing软件测试网/~1}P6C.BG
     ImportSheet = True51Testing软件测试网JV ]1Sf
     Exit Function
ST Z dd,{0    End If51Testing软件测试网]S)gx9]5v KV
   Next51Testing软件测试网"uk&W(gM#_
   DataTable.AddSheet ExcelSheetName51Testing软件测试网)a5NJK2m*VX
   DataTable.ImportSheet "RandallTest.xls", ExcelSheetName, ExcelSheetName
X#lNQ xh&bh0   If Err.Number<>0 Then51Testing软件测试网1S%v0t@2h!A}it`
    ImportSheet = False
L#] s4T3qmy/M(I0    Exit Function51Testing软件测试网c&zdQ9Ek u
   Else
)h*d!gEj0      ImportSheet = True    51Testing软件测试网`#[$n VN8A^
   End If51Testing软件测试网$bF7C3j ]G!p
End Function51Testing软件测试网oTkl8M1D? Eg

0m4LI,I RF0Function GetCellData(DTSheetName, FieldName, Row)
B"w-M,H!{p ^P0   Err.Clear
r,iX$?H$Y0   Dim sheetCount
yj0}\0em0   Dim blnExist
"c.}3r)S6n6G0   blnExist = False51Testing软件测试网KN |(o6HB
   sheetCount = DataTable.GetSheetCount51Testing软件测试网za^WN7V
   For i = 1 to sheetCount
~|)gZ(Ok-h]0    If strcomp(DTSheetName, DataTable.GetSheet(i).Name) = 0 Then
9j%Yd q]0     blnExist = True51Testing软件测试网d Y"jB:T3W H
     Reporter.ReportEvent micDone, "GetSheet: "+DTSheetName, "Passed"51Testing软件测试网n.w.[|r*|E0^.x
     Exit For51Testing软件测试网7sMQ)|1pU'r1n7]3H w
    End If
x4_%}*s bs,f0   Next  
7[}$vOZ6O+Q0   If Not blnExist Then
%y vQQ4]o.k"g{0    Reporter.ReportEvent micFail, "Sheet Exist: "+ DTSheetName, "Failed"51Testing软件测试网 ia*}m3{
    GetCellData = False
,nk8g*a2b z0    Exit Function51Testing软件测试网 k(|p)U&Z NE
   End If
)`$C!^#vTE?0   DataTable.SetCurrentRow Row
b-X1W.s.F8V l+W K4n0   GetCellData = DataTable.Value(FieldName, DTSheetName)
Y#aF&?(`TL8b&u,a L0   If Err.Number<>0 Then
Z.h%~x6{G9A-l0    Reporter.ReportEvent micFail, "GetSheetValue", "Failed"51Testing软件测试网 b*P|U%cX,q
    Exit Function
*WX0RmT0   End If51Testing软件测试网 NP0G2V!IB;Mjw
End Function51Testing软件测试网6B Q'PEG9o!g


TAG: QTP

 

评分:0

我来说两句

Open Toolbar