Foxtable(狐表)用户栏目专家坐堂 → EXCEL报表合并问题


  共有2849人关注过本帖树形打印复制链接

主题:EXCEL报表合并问题

帅哥哟,离线,有人找我吗?
大红袍
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/11/3 16:49:00 [显示全部帖子]

请把数据库发上来。

 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/11/3 17:28:00 [显示全部帖子]

Dim Book1 As New XLS.Book(ProjectPath & "Attachments\test.xls")
Dim fl As String = ProjectPath & "Reports\test.xls"
Dim Sheet1 As XLS.Sheet = Book1.Sheets(0)
Dim Sheet2 As XLS.Sheet = Book1.Sheets(1)
Dim Sheet3 As XLS.Sheet = Book1.Sheets(2)
Sheet1(3,8).Value = "<记账日期 = # " & Date.Today & "#>"  '写入打印条件
Sheet2(3,6).Value = "<记账日期1 = # " & Date.Today & "#>"  '写入打印条件

Book1.Build() '生成报表
Book1.Save(fl)


Dim App As New MSExcel.Application
Dim Wb As MSExcel.WorkBook = App.WorkBooks.Open(fl)
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+2).Select '横向拷贝
'ws3.Cells(Ws1.UsedRange.Rows.Count,1).Select '纵向拷贝
ws3.paste
Wb.Save
app.Visible = True
'App.Quit


 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/11/4 10:40:00 [显示全部帖子]

Dim Book1 As New XLS.Book(ProjectPath & "Attachments\test.xls")
Dim fl As String = ProjectPath & "Reports\test.xls"

 

Dim App As New MSExcel.Application
try
    Dim Wb As MSExcel.WorkBook = App.WorkBooks.Open(fl)
    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.activate
    ws3.Cells(1,1).Select
    ws3.paste
    Ws2.UsedRange.Copy
    ws3.activate
    ws3.Cells(1,Ws1.UsedRange.Columns.Count+2).Select '横向拷贝
    'ws3.Cells(Ws1.UsedRange.Rows.Count,1).Select '纵向拷贝
    ws3.paste
    Wb.Save
    app.Visible = True
catch ex As exception
    msgbox(ex.message)
    App.Quit
End try


 回到顶部