以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 指定打印机 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=189188) |
-- 作者:xuzihang -- 发布时间:2023/11/15 15:13:00 -- 指定打印机 这个是我之前的,但是不能指定打印机,根据论坛里先人用的是第二个 \' 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已经打开 问题是提示一:运行错误:无法使用本格式保存该工作簿,至少一个表单包含太多的列。 二、不选择打印机不提示错误。 大佬给看看怎么改 |
-- 作者:有点蓝 -- 发布时间:2023/11/15 15:27:00 -- 打开和保存的文件扩展名要一致呀 Dim Book As New XLS.Book(ProjectPath & "Attachments\\jfd.xlsx") Dim fl As String = ProjectPath & "Reports\\jfd.xlsx" |
-- 作者:xuzihang -- 发布时间:2023/11/15 15:31:00 -- 老师用PDF这个不好用是怎么改 Dim fl As String = ProjectPath & "Reports\\jfd.pdf"
|
-- 作者:有点蓝 -- 发布时间:2023/11/15 15:34:00 -- 保存为pdf参考:http://www.foxtable.com/webhelp/topics/2930.htm |