以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 多行细节区报表打印问题 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=107573) |
-- 作者:nothing -- 发布时间:2017/9/30 16:10:00 -- 多行细节区报表打印问题 Excel报表的细节区可以包括多行,而且可以任意复杂。 例如我们要Excel报表打印员工资料卡,可以按照下图所示设计模板: 根据这个帮助做的多行细节区报表, 需求:一页纸打印表中一行的内容,一行要打印N份,打完再打第二行的N份 问题:报表总是显示光标选中那行的内容,我用2个 For Each r As Row In Tables("表").Rows For i As Integer = 1 To e.Form.Controls("份数").value Dim Book As New XLS.Book(ProjectPath & "Attachments\\报表.xls") Dim fl As String = ProjectPath & "Reports\\报表.xls" Book.Build() Book.Save(fl) Dim App As New MSExcel.Application Dim Wb As MSExcel.WorkBook = App.WorkBooks.Open(fl) Dim Ws As MSExcel.WorkSheet = Wb.WorkSheets(1) App.Visible = True Ws.PrintPreview wb.save Wb.Close App.Quit Next Next 循环也不行,请老师帮忙 |
-- 作者:有点蓝 -- 发布时间:2017/9/30 16:29:00 -- For Each r As Row In Tables("表").Rows Tables("表").Position = r.Index For i As Integer = 1 To e.Form.Controls("份数").value Dim Book As New XLS.Book(ProjectPath & "Attachments\\报表.xls") Dim fl As String = ProjectPath & "Reports\\报表.xls" Book.Build() Book.Save(fl) Dim App As New MSExcel.Application Dim Wb As MSExcel.WorkBook = App.WorkBooks.Open(fl) Dim Ws As MSExcel.WorkSheet = Wb.WorkSheets(1) App.Visible = True Ws.PrintPreview wb.save Wb.Close App.Quit Next Next
|
-- 作者:有点蓝 -- 发布时间:2017/9/30 16:29:00 -- 重复打印还可以参考这个方法 |
-- 作者:nothing -- 发布时间:2017/9/30 16:31:00 -- 感谢,用循环还是VBA效率高些? |