以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  EXCEL选择后执行批量打印  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=79586)

--  作者:douglas738888
--  发布时间:2016/1/5 14:26:00
--  EXCEL选择后执行批量打印
请教老师,在窗口选择填报日期后执行批量打印,下面代码错在哪里  EXCEL模板设计的是主表和明细表关联的  
想实现在WebBrowser显示要打印的全部员工的表,并进行批量打印

For s As Integer=0 To Tables("业绩填报").Rows.Count-1
    Tables("业绩填报").Position=s
Dim wbr As WinForm.WebBrowser = e.Form.Controls("WebBrowser1")
Dim Book As New XLS.Book(ProjectPath & "Attachments\\业绩明细A.xls") \'打开模板
Dim rpt As String = ProjectPath & "Reports\\业绩明细A" & Tables("业绩填报").current("员工工号") & ".xls"
Dim Sheet As XLS.Sheet = Book.Sheets(0)
Sheet(7,12).Value = "<填报日期 >= #" & e.Form.Controls("DateTimePicker1").Value & "# And 填报日期 <= #" & e.Form.Controls("DateTimePicker2").Value & "#" \'写入打印条件
Book.Build() 
Book.Save(rpt)
wbr.OfficeToolBar = True \'如果不需要显示工具栏,可删除此行代码
wbr.AddRess = rpt
Next

--  作者:大红袍
--  发布时间:2016/1/5 14:35:00
--  

不要循环

 

Dim wbr As WinForm.WebBrowser = e.Form.Controls("WebBrowser1")
Dim Book As New XLS.Book(ProjectPath & "Attachments\\业绩明细A.xls") \'打开模板
Dim rpt As String = ProjectPath & "Reports\\业绩明细A" & Tables("业绩填报").current("员工工号") & ".xls"
Dim Sheet As XLS.Sheet = Book.Sheets(0)
Sheet(7,12).Value = "<填报日期 >= #" & e.Form.Controls("DateTimePicker1").Value & "# And 填报日期 <= #" & e.Form.Controls("DateTimePicker2").Value & "#" \'写入打印条件
Book.Build()
Book.Save(rpt)
wbr.OfficeToolBar = True \'如果不需要显示工具栏,可删除此行代码
wbr.AddRess = rpt


--  作者:大红袍
--  发布时间:2016/1/5 14:36:00
--  

打印参考

 

Dim App As New MSExcel.Application
Dim Wb As MSExcel.WorkBook = App.WorkBooks.Open("D:\\test.xls")
Dim Ws As MSExcel.WorkSheet = Wb.WorkSheets(1)

Wb.Saved = True
App.DisplayAlerts = False \'加上此行可禁止弹出合并前的提示
app.Visible = True
Ws.PrintPreview \'预览
\'ws.printout \'打印
app.quit