社区
C#
帖子详情
关于用C# 打印word文档的 格式设置?
weixin_40336777
2020-07-17 08:17:30
C# 如何 想要打印word文档,但里面的一版打印4页,这种设置,如何调用?
...全文
1113
2
打赏
收藏
关于用C# 打印word文档的 格式设置?
C# 如何 想要打印word文档,但里面的一版打印4页,这种设置,如何调用?
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
2 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
以专业开发人员为伍
2020-07-17
打赏
举报
回复
微软 Office 菜单山就有“开发工具->录制宏”功能,你可以看看人家产生的 VBA 代码,就知道该调用什么对象和方法了。
X-i-n
2020-07-17
打赏
举报
回复
四页打在同一张纸上? 这是Word打印PrintOut方法的详细介绍:https://blog.csdn.net/xuxingfan000/article/details/51818559 你需要的应该是PrintZoomColumn和PrintZoomRow
C#
批量
打印
word文档
C#
批量
打印
WORD文档
,每次
打印
只需弹出一次
打印
设置
,之后就会按这个
设置
来
打印
。 这个是
打印
已有
word文档
9101307-
C#
实现
word文档
打印
及预览.rar_
C#
预览 word_
C#
打印
word文档
_
c#
word_hello1
C#
打印
预览
Word文档
复制就可以直接使用 代码方便快捷 谢谢大家的支持
C#
实现
word文档
打印
及预览
C#
实现
word文档
打印
及预览,下载后可以直接复制到程序中使用
C#
向
word文档
动态插入数据并
打印
预览
首先机子上安装有office,在COM中添加引用Microsoft.Word.11.0.Object.Library(或11.0以上) Microsoft.Office.Interop.Word.Application myWordApp = null; Microsoft.Office.Interop.Word.Document doc = null; object Filename = path + "\\" + TaskID + ".docx";//目的文件 object templateFile = System.Windows.Forms.Application.StartupPath + @"\Template.docx";//模板文件,有一个五列一行的表 System.IO.File.Copy(templateFile.ToString(), Filename.ToString(), true);//模板WORD中有一个五列的表头,分别是卡号,串口号,发送指令条数,接收指令条数,收发成功率 myWordApp = new Microsoft.Office.Interop.Word.Application(); doc = myWordApp.Documents.Open(ref Filename, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing); /////显示页码 object oAlignment = Microsoft.Office.Interop.Word.WdPageNumberAlignment.wdAlignPageNumberCenter; object oFirstPage = true; oAlignment = Microsoft.Office.Interop.Word.WdPageNumberAlignment.wdAlignPageNumberCenter; myWordApp.Selection.Sections[1].Footers[Microsoft.Office.Interop.Word.WdHeaderFooterIndex.wdHeaderFooterPrimary].PageNumbers.Add(ref oAlignment, ref oFirstPage); myWordApp.Selection.Sections[1].Footers[Microsoft.Office.Interop.Word.WdHeaderFooterIndex.wdHeaderFooterPrimary].PageNumbers.NumberStyle = Microsoft.Office.Interop.Word.WdPageNumberStyle.wdPageNumberStyleNumberInDash; for (int i = 2; i < 102; i++)//举例100台 { doc.Tables[1].Rows.Add(ref Nothing);//表格增加一行 doc.Tables[1].Cell(i, 1).Range.Text = "250297";//卡号 doc.Tables[1].Cell(i, 2).Range.Text = "COM12";//串口号 doc.Tables[1].Cell(i, 3).Range.Text = "100";//发送指令条数 doc.Tables[1].Cell(i, 4).Range.Text = "99";//接收指令条数 doc.Tables[1].Cell(i, 5).Range.Text = "99%";//收发成功率 } doc.SaveAs(ref Filename, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing); object savechanges = Microsoft.Office.Interop.Word.WdSaveOptions.wdDoNotSaveChanges;//不保存挂起的更改 ////下面是直接
打印
,文档不显示 //doc.PrintOut(ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing); object readOnly=false; object isVisable = true;////文档打开状态为可视 doc = myWordApp.Documents.Open(ref Filename, ref Nothing, ref readOnly, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref isVisable, ref Nothing, ref Nothing, ref Nothing, ref Nothing); doc.PrintPreview();//
打印
预览
C#
打印
Word_Excel_PDF文件
显示WORD、EXCEL等程序窗口
打印
不显示WORD、EXCEL等程序窗口
打印
C#
110,536
社区成员
642,578
社区内容
发帖
与我相关
我的任务
C#
.NET技术 C#
复制链接
扫一扫
分享
社区描述
.NET技术 C#
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
让您成为最强悍的C#开发者
试试用AI创作助手写篇文章吧
+ 用AI写文章