共同探讨QTP相关问题

如何使用qtp操作OpenOffice

上一篇 / 下一篇  2008-11-17 20:59:26 / 个人分类:QTP

;Y yzI$_*ryo0Public Function ConvertToURL(cFilename)51Testing软件测试网nyX ~4W se
Dim sURL
p0qU'ycF$v f0' Ensure leading slash.51Testing软件测试网c)i?(t7[ k{9x
If Left(cFilename, 1) <> "/" Then
K @'M KcL-@j5i3L0cFilename = "/" + cFilename
EjA&bi1C0End If
~ sE7b%Lb.`0sURL = Replace(cFilename, "\", "/") 'change backslashes to forward slashes.51Testing软件测试网B*{4V\zL d3q
sURL = "file://" + sURL 'Example: "
file:///E:/Sample Files/Sample.ods"51Testing软件测试网C"u)~m{yd
ConvertToURL = sURL
X(T#ss"{;`'[&I ADf0End Function
51Testing软件测试网 }&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%_ JL j]0Dim oDocument51Testing软件测试网;{'J"gJ$[(nD
Dim oSheet
Gx4I5Z z }N ]v0Dim oParCursor51Testing软件测试网(sA Y }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 I pT
xSearchDesc.SetSearchString("DC")51Testing软件测试网L!J7B9Y P(~
Set ōCell = oSheet.findFirst(xSearchDesc)
PJ spp.PA&Y:z({ y0MsgBox oCell.getCellAddress().Row
N8l0M(H_^.{T`:q"c t0MsgBox oCell.getCellAddress().Column '//Use the openoffice search function to getcell and return the row and column
51Testing软件测试网$E t2O(vk

51Testing软件测试网#\-s*{7T;t-a1f

Set ōRowCursor = oSheet.createCursor()
'z:?:P%X t*Ye2F0oRowCursor.gotoStartofUsedArea(false)
yqM~~W0C0oRowCursor.gotoEndofUsedArea(True)51Testing软件测试网 r[0S ^3G w u
MsgBox oRowCursor.getrows.Count
51Testing软件测试网%^;XE7Kr s

51Testing软件测试网 S-J c$s1FL N H

51Testing软件测试网)WKq\\"g
Set ōColumnCursor = oSheet.createCursor() 51Testing软件测试网9f$IN^C}U|C
oColumnCursor.gotoStartofUsedArea(false) 51Testing软件测试网:bO`p G+`pZ
oColumnCursor.gotoEndofUsedArea(True)
Pw \sNG!R0MsgBox oColumnCursor.getColumns.Count
51Testing软件测试网)dj5Ck9hG(yc8xM7A

51Testing软件测试网M$Pd9wyE

MsgBox oSheet.GetCellByPosition(0, 0).GetString()

3k%B"p#FR#o6GN0 51Testing软件测试网i@4Si'R hC

End Function

Sd-N~rk5d0k0 51Testing软件测试网Dr&b FAF!P

qLFS\ E,K0

TAG: QTP

 

评分:0

我来说两句

Open Toolbar