' Dim Book As New XLS.Book(ProjectPath & "Attachments\jfd.xlsx")
' Dim Sheet As XLS.Sheet = Book.Sheets(0) '引用工作簿的第一个工作表
' With Sheet.PrintSetting
' '页眉左边为日期,中间为时间,右边为表名
' ' .Header = "&L&D &C&T &R&A"
' '在页脚右边打印页号和总页数
' .Footer = "&R第&P页,总&N页"
' End With
' Dim fl As String = ProjectPath & "Reports\jfd.pdf"
' Book.Build() '生成细节区
' Book.SaveToPDF(fl) '保存为PDF文件
' Dim Proc As New Process '打开PDF文件
' Proc.File = fl
' Proc.Verb = "Print" '指定动作
' Proc.Start()
第二个
'--------------------------------------------------------------------------------
' '==========打印机遍历代码,我放在窗口的afterload事件
' Dim cmb As WinForm.ComboBox = e.form.Controls("打印机选择")
' For Each p As String In InstalledPrinters
' cmb.Items.Add(p)
' Next
' cmb.Text = GetConfigValue("pntname1", "请选择打印机")
'=================================打印按钮代码
Dim pnt As WinForm.ComboBox = e.Form.Controls("打印机选择")'取得打印机名称
Dim pntn As String = pnt.Text
SaveConfigValue("pntname1", pntn)
Dim Book As New XLS.Book(ProjectPath & "Attachments\jfd.xlsx")
Dim fl As String = ProjectPath & "Reports\jfd.xls"
' Dim fl As String = ProjectPath & "Reports\jfd.pdf"
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)
Ws.PrintOut(ActivePrinter:=pntn)
App.quit '这个一定要写,退出进程里的EXCEL,否则会提示XXX已经打开
问题是提示一:运行错误:无法使用本格式保存该工作簿,至少一个表单包含太多的列。 二、不选择打印机不提示错误。
大佬给看看怎么改