Dim tb As WinForm.TabControl = e.Form.Controls("TabControl1") Dim pg As WinForm.TabPage = tb.SelectedPage Dim doc As PrintDoc = e.Form.GernatePrintDoc(pg) If tb.SelectedPage.Text = "page2" Then Dim dlg As New OpenFileDialog '定义一个新的OpenFileDialog dlg.Filter= "Excel文件|*.xls|Word文件|*.doc|Access文件|*.mdb" '设置筛选器 If dlg.ShowDialog = DialogResult.Ok Then '如果用户单击了确定按钮 Dim idx As Integer = dlg.FileName.LastIndexOf(".") Dim ext As String = dlg.FileName.SubString(idx).Toupper If ext.contains(".XLS") Then Dim Book As New XLS.Book(dlg.FileName) 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 ShowAppWindow("考核",2) Ws.PrintPreview App.Quit ElseIf ext.contains(".DOC") Then '如果用户单击了确定按钮 Dim tm As String = dlg.FileName Dim fl1 As String = "D:\准考证\准考证.doc" '指定目标文件 Dim fl2 As String = "D:\准考证\准考证.pdf" '指定目标PDF文件 Dim wrt As New WordReport(Tables("管理_Table8"),tm,fl1) '定义一个WordReport wrt.Build() '逐行生成报表 wrt.SaveToPDF(fl2) '保存为PDF文件 wrt.Quit() '退出 Dim Proc As New Process '打开PDF文件 Proc.File = fl2 Proc.Start() End If End If End If
|