共同探讨QTP相关问题
如何使用qtp操作OpenOffice
上一篇 /
下一篇 2008-11-17 20:59:26
/ 个人分类:QTP
wJMx:_h7n0Public Function ConvertToURL(cFilename)
4b{N I nd E0Dim sURL
7TP.{Q6cb9k/@0' Ensure leading slash.51Testing软件测试网4@I)M1Mn q
If Left(cFilename, 1) <> "/" Then51Testing软件测试网iRW`0\J:y+VeM"U
cFilename = "/" + cFilename51Testing软件测试网9g1E\MCn
End If
"Q2h C%V0f_l'U0sURL = Replace(cFilename, "\", "/") 'change backslashes to forward slashes.
)[
LP#TTXS P2g%g+p0sURL = "file://" + sURL 'Example: "file:///E:/Sample Files/Sample.ods"51Testing软件测试网_e0OfY
ConvertToURL = sURL51Testing软件测试网!slG9c7k
End Function
+i'q6o~ m E0
51Testing软件测试网(M#k#ny1VP#R\0g51Testing软件测试网 W~BcQ*{h
51Testing软件测试网B Dn
t#y$Yg
51Testing软件测试网SU)]Gm;}3fI.rFunction 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:m8KSet ōbjServiceManager = CreateObject("com.sun.star.ServiceManager")
y6\:^,R2KNoM'|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软件测试网{+nU7~!]
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
YT9IG;S5F0
ne2@1@A0Set ōRowCursor = oSheet.createCursor() 51Testing软件测试网M
M K'ri#V
|;?b
oRowCursor.gotoStartofUsedArea(false) 51Testing软件测试网+Iio8O}c
oRowCursor.gotoEndofUsedArea(True)
hExQp1W0MsgBox oRowCursor.getrows.Count
7f7t9sM3^ dM'm0
51Testing软件测试网]Dch$U
#@.sS^`O5iF
d0Set ōColumnCursor = oSheet.createCursor() 51Testing软件测试网.tTh| r
oColumnCursor.gotoStartofUsedArea(false)
'{/xQ&p4k/F0oColumnCursor.gotoEndofUsedArea(True)
lz#J5e:C9@"g"FJ0MsgBox oColumnCursor.getColumns.Count51Testing软件测试网S P$xX;}TEAMs
d:yDT#x0MsgBox oSheet.GetCellByPosition(0, 0).GetString()
/t ])C_nr0
51Testing软件测试网?ar!H]1S&dEnd Function
&QiS#EA&a0
acHoU
w.vW)Q0
v&Rnq;F$[0
收藏
举报
TAG:
QTP