共同探讨QTP相关问题

如何使用qtp操作OpenOffice

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

wJMx:_h7n0Public Function ConvertToURL(cFilename)
4b{N Ind E0Dim sURL
7TP.{Q6c b9k/@0' Ensure leading slash.51Testing软件测试网4@I)M1Mnq
If Left(cFilename, 1) <> "/" Then51Testing软件测试网iRW`0\J:y+VeM"U
cFilename = "/" + cFilename51Testing软件测试网9g1E\MCn
End If
"Q2hC%V0f_l'U0sURL = Replace(cFilename, "\", "/") 'change backslashes to forward slashes.
)[ L P#TTXSP2g%g+p0sURL = "file://" + sURL 'Example: "
file:///E:/Sample Files/Sample.ods"51Testing软件测试网_e0OfY
ConvertToURL = sURL51Testing软件测试网!slG9c7k
End Function

+i'q6o~ mE0 51Testing软件测试网(M#k#ny1VP#R\0g

51Testing软件测试网 W~BcQ*{h
 51Testing软件测试网BDn t#y$Yg

51Testing软件测试网SU)]Gm;}3fI.r

Function GetData(sFileName, sSheetName)
rT%u7Lb0kq}[X0Dim objServiceManager51Testing软件测试网$b+BD9O~H
Dim oDesktop
0e m\:G\`B0Dim oDocument
poSOLoL0Dim oSheet51Testing软件测试网1U)cP {,Z
Dim oParCursor
] tHESFI6W0Dim oCell51Testing软件测试网!]1Vqk:b G
Dim xSearchDesc

TWv8NT0 51Testing软件测试网8]k*F4v4ai#L%v${:HS:m8K

Set ōbjServiceManager = CreateObject("com.sun.star.ServiceManager")
y6\:^,R2KN oM'|0Set ōDesktop = objServiceManager.createInstance("com.sun.star.frame.Desktop")51Testing软件测试网XJRkk/c a/v |IP
Set ōDocument = oDesktop.loadComponentFromURL(ConvertToURL(sFileName), "_blank", 0, Array())51Testing软件测试网f)wvxyI$io{
Set ōSheet = oDocument.Sheets.getByName(sSheetName)

!SI)D@ D$tm0

Q%\ D)[\)B9fX!c5kAW0Set xSearchDesc = oSheet.createSearchDescrīptor()51Testing软件测试网{+n U7~!] n
xSearchDesc.SetSearchString("DC")51Testing软件测试网8gw9^GB-d
Set ōCell = oSheet.findFirst(xSearchDesc)
&J\L#y&BYp@0MsgBox oCell.getCellAddress().Row
Frphho0MsgBox oCell.getCellAddress().Column '//Use the openoffice search function to getcell and return the row and column

Y T9IG;S5F0

ne2@1@A0Set ōRowCursor = oSheet.createCursor() 51Testing软件测试网M MK'ri#V |;?b
oRowCursor.gotoStartofUsedArea(false) 51Testing软件测试网+Iio8O}c
oRowCursor.gotoEndofUsedArea(True)
hExQp1W0MsgBox oRowCursor.getrows.Count

7f7t9sM3^ dM'm0 51Testing软件测试网]Dch$U


#@.s S^`O5iF d0Set ōColumnCursor = oSheet.createCursor() 51Testing软件测试网.tTh| r
oColumnCursor.gotoStartofUsedArea(false)
'{/xQ&p4k/F0oColumnCursor.gotoEndofUsedArea(True)
lz#J5e:C9@"g"FJ0MsgBox oColumnCursor.getColumns.Count
51Testing软件测试网SP$xX;}TEAM s

d:yDT#x0MsgBox oSheet.GetCellByPosition(0, 0).GetString()

/t ])C_nr0 51Testing软件测试网?ar!H]1S&d

End Function

&QiS#EA&a0

acHoU w.vW)Q0

v&Rnq;F$[0

TAG: QTP

 

评分:0

我来说两句

Open Toolbar