C#打印表单,表单包含标题,内容。

来源:百度知道 编辑:UC知道 时间:2024/06/17 02:24:05
我现在已经作出来的打印程序,要不是就是只能打印dataGridview,要不是就是打印winform。但是第二种办法打印出来的效果像是图片效果,很模糊。
我是初学,大家有没有什么办法提供?

用word最好,代码是
using Word;
下面的例子中包括C#对Word文档的创建、插入表格、设置样式等操作:
(例子中代码有些涉及数据信息部分被省略,重要是介绍一些C#操作word文档的方法)
public string CreateWordFile(string CheckedInfo)
...{
string message = "";
try
...{
Object Nothing = System.Reflection.Missing.Value;
Directory.CreateDirectory("C:/CNSI"); //创建文件所在目录
string name = "CNSI_" + DateTime.Now.ToShortString()+".doc";
object filename = "C://CNSI//" + name; //文件保存路径
//创建Word文档
Word.Application WordApp = new Word.ApplicationClass();
Word.Document WordDoc = WordApp.Documents.Add(ref Nothing, ref Nothing, ref Nothing, ref Nothing);
//添加页眉
WordApp.ActiveWindow.View.Type = WdViewType.wdOutlineView;
WordApp.ActiveWind