本文介绍了实习战争:请帮助我几个星期:(的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
---------------------------------------------------------
Public Class TCombMerge
Implements ICombMerge
Dim sHT As String = String.Empty 'header top
Dim sHB As String = String.Empty 'header bottom
Dim sRT As String = String.Empty 'report top
Dim sRB As String = String.Empty 'report bottom
Dim sTF As String = String.Empty 'template file
Function MergeFiles() As Long Implements ICombMerge.MergeFiles
Dim retVal As Long = 0, i As Long = 0, j As Long = 0
Dim sFiles As ArrayList = Nothing, oExc As Object = Nothing
Dim oWbkSrc As Object = Nothing, oWbkDst As Object = Nothing
Dim oWshSrc As Object = Nothing, oWshDst As Object = Nothing
-----------------------------------------------------------
-------------------------------------------------- ---------
-----------------------------------------------------------
--REPORT TOP & BOTTOM ----
---------------------------
-----BEGIN FOR TOP ------
--------------------------
'open source file Report Top / OPEN ONCE
oWbkSrc = oExc.Workbooks.Open(sRT)
'ReportTop:A2->I2 copy to Template:A16->I16
For i = 2
j = i + 14
oWshSrc.Range("A"& i.ToString).Copy(oWshDst.Range("A" & j.ToString))
'corresponding row of B,C,D,E,F,G,H,I
oWshSrc.Range("A"& i.ToString).Copy(oWshDst.Range("A"& j.ToString).offset(0,1))
----NEXT, SKIP 1 CELL THEN----
'ReportTop:A3->I3 copy to Template:A18->I18
For i = 2
j = i + 16
oWshSrc.Range("A"& i.ToString).Copy(oWshDst.Range("A" & j.ToString))
'corresponding row of B,C,D,E,F,G,H,I
oWshSrc.Range("A"& i.ToString).Copy(oWshDst.Range("A"&
j.ToString).offset(0,1))
----NEXT, SKIP 1 CELL THEN----
'ReportTop:A4->I4 copy to Template:A20->I20
For i = 2
j = i + 18
oWshSrc.Range("A"& i.ToString).Copy(oWshDst.Range("A" & j.ToString))
'corresponding row of B,C,D,E,F,G,H,I
oWshSrc.Range("A"& i.ToString).Copy(oWshDst.Range("A"& j.ToString).offset(0,1))
----NEXT, SKIP 1 CELL THEN----
'ReportTop:A5->I5 copy to Template:A22->I22
For i = 2
j = i + 20
oWshSrc.Range("A"& i.ToString).Copy(oWshDst.Range("A" & j.ToString))
'corresponding row of B,C,D,E,F,G,H,I
oWshSrc.Range("A"& i.ToString).Copy(oWshDst.Range("A"& j.ToString).offset(0,1))
----NEXT, SKIP 1 CELL THEN----
'ReportTop:A7->I7 copy to Template:A24->I24
For i = 2
j = i + 22
oWshSrc.Range("A"& i.ToString).Copy(oWshDst.Range("A" & j.ToString))
'corresponding row of B,C,D,E,F,G,H,I
oWshSrc.Range("A"& i.ToString).Copy(oWshDst.Range("A"& j.ToString).offset(0,1))
LOOP UNTILL THERE ARE NO READING.
---------------------------
-----BEGIN FOR BOTTOM ------
--------------------------
'open source file Report Bottom
oWbkSrc = oExc.Workbooks.Open(sRB)//OPEN ONCE
'ReportBottom:A2->I2 copy to Template:A17->I17
For i = 2
j = i + 15
oWshSrc.Range("A"& i.ToString).Copy(oWshDst.Range("A" & j.ToString).offset(1,0)
'corresponding row of B,C,D,E,F,G,H,I
oWshSrc.Range("A"& i.ToString).Copy(oWshDst.Range("A" & j.ToString).offset(0,1))
-----------BEGIN FROM 1st SKIPPED CELL----------
'ReportBottom:A3->I3 copy to Template:A19->I19
For i = 2
j = i + 17
oWshSrc.Range("A"& i.ToString).Copy(oWshDst.Range("A" & j.ToString).offset(1,0)
'corresponding row of B,C,D,E,F,G,H,I
oWshSrc.Range("A"& i.ToString).Copy(oWshDst.Range("A" & j.ToString).offset(0,1))
-----------NEXT 2nd SKIPPED CELL-----------
'ReportBottom:A4->I4 copy to Template:A21->I21
For i = 2
j = i + 19
oWshSrc.Range("A"& i.ToString).Copy(oWshDst.Range("A" & j.ToString).offset(1,0)
'corresponding row of B,C,D,E,F,G,H,I
oWshSrc.Range("A"& i.ToString).Copy(oWshDst.Range("A" & j.ToString).offset(0,1))
-----------NEXT 3rd SKIPPED CELL-----------
'ReportBottom:A5->I5 copy to Template:A23->I23
For i = 2
j = i + 21
oWshSrc.Range("A"& i.ToString).Copy(oWshDst.Range("A" & j.ToString).offset(1,0)
'corresponding row of B,C,D,E,F,G,H,I
oWshSrc.Range("A"& i.ToString).Copy(oWshDst.Range("A" & j.ToString).offset(0,1))
LOOP UNTILL THERE ARE NO READING.
推荐答案
这篇关于实习战争:请帮助我几个星期:(的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!