1、用一个xls文件,做两个sheet,设计好模板;
2、生成报表后,用代码把两个sheet的内容合并到一起即可。
比如你生成了报表 d:\text.xls
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