共同探讨QTP相关问题
如何使用qtp操作OpenOffice
上一篇 /
下一篇 2008-11-17 20:59:26
/ 个人分类:QTP
;Y
yzI$_*ryo0Public Function ConvertToURL(cFilename)51Testing软件测试网nyX
~4Wse
Dim sURL
p0qU'ycF$v f0' Ensure leading slash.51Testing软件测试网c)i?(t7[
k{9x
If Left(cFilename, 1) <> "/" Then
K@'M Kc L-@j5i3L0cFilename = "/" + cFilename
EjA&bi1C0End If
~ sE7b%Lb.`0sURL = Replace(cFilename, "\", "/") 'change backslashes to forward slashes.51Testing软件测试网B*{4V\zLd3q
sURL = "file://" + sURL 'Example: "file:///E:/Sample Files/Sample.ods"51Testing软件测试网C"u)~m{yd
ConvertToURL = sURL
X(T#ss"{;`'[&I ADf0End Function51Testing软件测试网}&w;hC"~m
Z*c
.J/D.j?0K051Testing软件测试网,|:xbu`aP!e`s
51Testing软件测试网+PU{#A
T
:Uo)hl6GUy)T0Function GetData(sFileName, sSheetName)
9p}C:w%i*V5}I0Dim objServiceManager
5]t)]2]w&f0Dim oDesktop
c1F%_JLj]0Dim oDocument51Testing软件测试网;{'J"gJ$[(n D
Dim oSheet
Gx4I5Z z}N
]v0Dim oParCursor51Testing软件测试网(sAY }c,j
Dim oCell
1n5U-Sq#m#sc0Dim xSearchDesc
QBF;za2YH7^,\%G0
!g-zH
y(L(QT0Set ōbjServiceManager = CreateObject("com.sun.star.ServiceManager")51Testing软件测试网O])u/j4z{ ~
Set ōDesktop = objServiceManager.createInstance("com.sun.star.frame.Desktop")
[TG u?0Set ōDocument = oDesktop.loadComponentFromURL(ConvertToURL(sFileName), "_blank", 0, Array())
|1JH*i"w]4X0Set ōSheet = oDocument.Sheets.getByName(sSheetName)
L _sxf#p!~0
6R/CexhoJ:J;r0Set xSearchDesc = oSheet.createSearchDescrīptor()51Testing软件测试网2y9`:q |S$G IpT
xSearchDesc.SetSearchString("DC")51Testing软件测试网L!J7B9YP(~
Set ōCell = oSheet.findFirst(xSearchDesc)
PJ spp.PA&Y:z({
y0MsgBox oCell.getCellAddress().Row
N8l0M(H_^.{T `:q"ct0MsgBox oCell.getCellAddress().Column '//Use the openoffice search function to getcell and return the row and column51Testing软件测试网$Et2O(vk
51Testing软件测试网#\-s*{7T;t-a1fSet ōRowCursor = oSheet.createCursor()
'z:?:P%X
t*Ye2F0oRowCursor.gotoStartofUsedArea(false)
yqM~~W0C0oRowCursor.gotoEndofUsedArea(True)51Testing软件测试网 r[0S^3Gw
u
MsgBox oRowCursor.getrows.Count51Testing软件测试网%^;XE7Kr
s
51Testing软件测试网S-Jc$s1FL N
H51Testing软件测试网)WKq\\"g
Set ōColumnCursor = oSheet.createCursor() 51Testing软件测试网9f$IN^C}U |C
oColumnCursor.gotoStartofUsedArea(false) 51Testing软件测试网:bO`pG+`pZ
oColumnCursor.gotoEndofUsedArea(True)
P w
\sNG!R0MsgBox oColumnCursor.getColumns.Count51Testing软件测试网)dj5Ck9hG(yc8xM7A
51Testing软件测试网M$Pd9wyEMsgBox oSheet.GetCellByPosition(0, 0).GetString()
3k%B"p#FR#o6GN0
51Testing软件测试网i@4Si'R
hCEnd Function
Sd-N~rk5d0k0
51Testing软件测试网Dr&bFAF!PqLFS\E,K0
收藏
举报
TAG:
QTP