-- 作者:hongye
-- 发布时间:2017/2/5 13:17:00
-- 生成的PDF为什么不能换页
Dim year As String = e.Form.Controls("所属年").Value Dim moth As String = e.Form.Controls("所属月").Value If year = "" OrElse moth = "" Then Messagebox.show("请选择工资报表所属的年和月,如果需要查询全年工资,请点击历史工资表选项!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information) Return End If e.Form.Controls("WebBrowser1").Visible = True Dim wbr As WinForm.WebBrowser = e.Form.Controls("WebBrowser1") wbr.AddRess = Nothing Dim r As Row = Tables("工资报表_Table1").Current Dim tmp As String = ProjectPath & "Attachments\\工资清单.xls" Dim tmp1 As String = ProjectPath & "Attachments\\银行接口报表.xls" Dim tmp2 As String = ProjectPath & "Attachments\\工资签收单.xls" Dim rpt1 As String = "d:/工资/"+(r("所属年份")) + (r("所属月份")) +"01.xls" Dim rpt2 As String = "d:/工资/"+(r("所属年份")) + (r("所属月份")) +"无卡签收表.xls" Dim pdf As String = "d:/工资/temp/"+(r("所属年份"))+ "年" + (r("所属月份")) +"月工资报表.pdf" Dim rpt As String = "d:/工资/"+(r("所属年份")) + (r("所属月份")) +"工资清单.xls"
FileSys.CreateDirectory("d:/工资/temp") If FileSys.FileExists(rpt) = False Then Dim Book As New XLS.Book(tmp) Book.Build() Book.Save(rpt) \'保存为pdf文件 End If If FileSys.FileExists(rpt2) = False Then Dim Book1 As New XLS.Book(tmp2) Book1.Build() Book1.Save(rpt2)\'保存为pdf文件 End If Dim App1 As New MSExcel.Application Dim App2 As New MSExcel.Application try Dim Wb1 As MSExcel.WorkBook = App1.WorkBooks.Open(rpt) Dim Wb2 As MSExcel.WorkBook = App2.WorkBooks.Open(rpt2) Dim Ws1 As MSExcel.WorkSheet = Wb1.WorkSheets(1) \'指定要复制的工作表 Dim Ws2 As MSExcel.WorkSheet = Wb2.WorkSheets(1) Ws2.UsedRange.Copy ws1.Select \'ws1.Cells(1,Ws1.UsedRange.Columns.Count).Select \'横向拷贝 ws1.hPageBreaks.Add(ws1.Cells(Ws1.UsedRange.Rows.Count+1,1)) ws1.Cells(Ws1.UsedRange.Rows.Count+1,1).Select \'纵向拷贝 ws1.paste wb1.Save wb2.Save wb1.ExportAsFixedFormat(MSExcel.XlFixedFormatType.xlTypePDF, pdf, MsExcel.XlFixedFormatQuality.xlQualityStandard, True, False, System.Reflection.Missing.Value, System.Reflection.Missing.Value, False, System.Reflection.Missing.Value) \'app1.visible = True app1.quit app2.quit catch ex As exception msgbox(ex.message) app1.quit app2.quit End try If FileSys.FileExists(rpt1) = False Then Dim Book2 As New XLS.Book(tmp1) Book2.Build() Book2.Save(rpt1)\'保存为XLS文件 End If wbr.AddRess = pdf
此主题相关图片如下:bnhy.jpg
请帮我看看,为什么生成合并的PDF文件后,不能换页
|