qtp xml联合xsl输出html报表,用QTP实现数据的整理(将test1.xsl中的数据整理成result.xls)...

用QTP实现数据的整理(将test1.xsl中的数据整理成result.xls)

上一篇 /

下一篇  2013-05-16 17:01:30

/ 个人分类:QTP

'Option explicit

'Setting.WebPackage("ReplayType")=2

'删除已经存在的excel进程,避免文件打开重复

KillProcess "Excel.exe"

'创建result.xls

Set Excel=CreateObject("Excel.Application")

Set Shell=CreateObject("Wscript.Shell")

CPath = environment("TestDir")

oExcel.Workbooks.Open(CPath&"\test.xls")

wait 5

oExcel.Visible=true

oExcel.WorkSheets("Sheet1").UsedRange.Copy

set workbook=oExcel.Workbooks.Add

workbook.Worksheets("Sheet1").Range( "A1" ).PasteSpecial

workbook.Sheets("Sheet1").name="Action1"

'rename sheet1 to Action1

'RenameWorksheet oExcel, "工作簿1", "Sheet1", "Action1"

workbook.Sheets("Sheet2").Delete

workbook.Sheets("Sheet3").Delete

row=oExcel.Worksheets(1).UsedRange.Rows.count

col=oExcel.Worksheets(1).UsedRange.Columns.count

clsCount=0

Set Sheet=oExcel.Worksheets("Action1")

Set worksheet=oExcel.Worksheets

Scount=oExcel.Sheets.count

oExcel.Sheets.Add ,oExcel.Worksheets(Scount)

oExcel.Sheets(Scount+1).name="教师待定"

For clsCol=4 to col step 3

For i=2 to row

Tcher=oSheet.cells(i,clsCol)

Sclass=oSheet.cells(1,clsCol-1)

Sdate=oSheet.cells(i,1)

Scourse=oSheet.cells(i,clsCol-1)

'msgbox Tcher&"-"&Sclass&"-"&Sdata&"-"&Scourse

If  Trim(Scourse)<>"" or Trim(Tcher)<>"" Then

sheetCount =worksheet.Count

TrueCount=0

FalseCount=0

'判断是否存在教师sheet

For shCount=1 to sheetCount

'    msgbox oExcel.Worksheets(shCount).name

Select Case Tcher

Case   oExcel.Worksheets(shCount).name

TrueCount=TrueCount+1

Case ""

'                Set newSheet=oExcel.Sheets.Add

'                newSheet.name=Tcher

oExcel.Worksheets("教师待定").cells(1,1)="授课日期"

oExcel.Worksheets("教师待定").cells(1,2)="授课班级"

oExcel.Worksheets("教师待定").cells(1,3)="课程名称"

InsertValue oExcel, "教师待定",Sdate,Sclass,Scourse

Case Else

FalseCount=FalseCount+1

End Select

Next

'msgbox TrueCount&"+"&FalseCount&"="&sheetcount&"   "&Tcher&"="&oExcel.Worksheets(shCount).name

If TrueCount=1 and FalseCount=sheetCount-1 Then

InsertValue oExcel, Tcher,Sdate,Sclass,Scourse

Elseif FalseCount=sheetCount Then

oExcel.Sheets.Add ,oExcel.Sheets(Scount)

oExcel.Sheets(Scount+1).name=Tcher

oExcel.Worksheets(Tcher).cells(1,1)="授课日期"

oExcel.Worksheets(Tcher).cells(1,2)="授课班级"

oExcel.Worksheets(Tcher).cells(1,3)="课程名称"

InsertValue oExcel, Tcher,Sdate,Sclass,Scourse

End If

End If

next

next

SaveWorkbook  oExcel,"工作簿1",CPath&"\result.xls"

oExcel.Workbooks("test.xls").Close

'oExcel.Workbooks("result.xls").Close

'oExcel.Quit

Set Excel=nothing

Set Shell=nothing

05b10945a1012e3fab17e95648fda0c3.gif

引用

删除

kaqiinono /   2013-05-16 17:19:56

有待优化,欢迎大家提出宝贵意见

d8a3dac35532145b347031a8fb402eba.gif

我来说两句

显示全部

d8a3dac35532145b347031a8fb402eba.gif

4d73fc83cb27b31041650c043e06fdc8.gif

5d06f4dc9b08a7e1fecdedaf9fe87c66.gif

659391f05d11818e0d3bd694a6d99ddc.gif

f27d7d9f67d98cc858fe74ff4d76554e.gif

b0d82b880d66765dd2a1af173b20f406.gif

e87f042c31e114675541bb49e0fbf138.gif

97a372eda248bf63679ecf2d47467589.gif

a14a392968e29ace4cb2ca390d53264e.gif

ff31a40db0d852c3704276b17a1dd158.gif

46298ad80746c3790e9535ce3396efec.gif

ef97f2303f935b723744c0c99db267f8.gif

46add61d58ae5b455d8994b1485357d3.gif

701ffdce43c5ac45c241dba6a7ae431d.gif

4ac0c1a50de5d21a8087006d0295547a.gif

e54bbadbdbb00b0b5cc4182352ca2352.gif

afb655844bdfda4cf47fef6d239f009d.gif

bf5c12b671f1179ba425de53370ebd3d.gif

865ad24093d248b0ec3b85ea66a6aaa7.gif

ab80f8b6419577f8a8ad7bb690794024.gif

内容

昵称

验证

ada834077f6a48ad60a11ec0354fde86.png

提交评论

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值