能否每个单独做一个模板,然后把几个模板的数据,合并到一个总的sheet里面去?
做两个报表 sheet1、sheet2,然后把两个报表合并起来,就是你要的结果
Dim App As New MSExcel.Application
Dim Wb As MSExcel.WorkBook = App.WorkBooks.Open("D:\test.xls")
Dim Ws1 As MSExcel.WorkSheet = Wb.WorkSheets("sheet1") '指定要复制的工作表
Dim Ws2 As MSExcel.WorkSheet = Wb.WorkSheets("sheet2")
Dim Ws3 As MSExcel.WorkSheet = Wb.WorkSheets("sheet3")
Ws1.UsedRange.Copy
ws3.Cells(1,1).Select
ws3.paste
Ws2.UsedRange.Copy
'ws3.Cells(1,Ws1.UsedRange.Columns.Count).Select '横向拷贝
ws3.Cells(Ws1.UsedRange.Rows.Count,1).Select '纵向拷贝
ws3.paste
'Wb.Save
app.Visible = True
'App.Quit