C#操作word的一些基本方法(word打印,插入文件,插入图片,定位页眉页脚,去掉横线)
2012-03-30 15:46
936 查看
http://archive.cnblogs.com/a/2036597/
1、Microsoft.Office.Interop.Word.Application wordApp =new
ApplicationClass()
word对象
2、 Microsoft.Office.Interop.Word.Document wordDoc = wordApp.Documents.Add(ref Nothing,ref Nothing,
ref Nothing,ref Nothing)
文档对象
3、 Object Nothing = System.Reflection.Missing.Value常用的一个参数
4、wordApp.ActiveWindow.ActivePane.View.SeekView =WdSeekView.
wdSeekCurrentPageHeader定位到页眉
5、 wordApp.Selection.ParagraphFormat. Borders[WdBorderType.wdBorderBottom]
.LineStyle = WdLineStyle.wdLineStyleNone去掉页眉线
6、wordApp.ActiveWindow.View.SeekView =
WdSeekView.wdSeekMainDocument跳出页眉
7、 wordApp.Selection.ParagraphFormat.Alignment =WdParagraphAlignment.
wdAlignParagraphCenter对齐方式(此为居中)
8、 Microsoft.Office.Interop.Word.Table policyTab = wordDoc.Tables.Add
(wordApp.Selection.Range, 行数, 列, ref Nothing,
ref Nothing);创建表格
9、 wordApp.Selection.GoTo(ref oGoToItem,ref oGoToLast,
ref Nothing,ref Nothing);定位页面(此为将光标定位到内容的最后)
10、 wordApp.Selection.InsertBreak(ref Nothing);插入分节符
11、 wordApp.Selection.InsertFile(nofile,
ref Nothing, ref contenFalse,
ref contenFalse, ref contenFalse);插入文件
12、 wordApp.Selection.InlineShapes.AddPicture(picName,ref LinkToFile,
ref SaveWithDocument,ref Nothing);插入图片
13、 wordApp.ActiveWindow.ActivePane.View.SeekView =WdSeekView.
wdSeekCurrentPageFooter;定位到页脚
14、 wordApp.Selection.TypeText("此处写需要在指定位置输出的文字");文本输入
15、 wordDoc.ComputeStatistics(WdStatistic.wdStatisticPages,ref Nothing);得到页码
16、 wordDoc.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);
调用打印机实现打印(调用的是默认打印机)
17、 wordDoc.Close(ref saveChanges,ref Nothing,
ref Nothing);文档退出
18、 wordApp.Quit(ref Nothing,ref Nothing,
ref Nothing);word程序退出
1、Microsoft.Office.Interop.Word.Application wordApp =new
ApplicationClass()
word对象
2、 Microsoft.Office.Interop.Word.Document wordDoc = wordApp.Documents.Add(ref Nothing,ref Nothing,
ref Nothing,ref Nothing)
文档对象
3、 Object Nothing = System.Reflection.Missing.Value常用的一个参数
4、wordApp.ActiveWindow.ActivePane.View.SeekView =WdSeekView.
wdSeekCurrentPageHeader定位到页眉
5、 wordApp.Selection.ParagraphFormat. Borders[WdBorderType.wdBorderBottom]
.LineStyle = WdLineStyle.wdLineStyleNone去掉页眉线
6、wordApp.ActiveWindow.View.SeekView =
WdSeekView.wdSeekMainDocument跳出页眉
7、 wordApp.Selection.ParagraphFormat.Alignment =WdParagraphAlignment.
wdAlignParagraphCenter对齐方式(此为居中)
8、 Microsoft.Office.Interop.Word.Table policyTab = wordDoc.Tables.Add
(wordApp.Selection.Range, 行数, 列, ref Nothing,
ref Nothing);创建表格
9、 wordApp.Selection.GoTo(ref oGoToItem,ref oGoToLast,
ref Nothing,ref Nothing);定位页面(此为将光标定位到内容的最后)
10、 wordApp.Selection.InsertBreak(ref Nothing);插入分节符
11、 wordApp.Selection.InsertFile(nofile,
ref Nothing, ref contenFalse,
ref contenFalse, ref contenFalse);插入文件
12、 wordApp.Selection.InlineShapes.AddPicture(picName,ref LinkToFile,
ref SaveWithDocument,ref Nothing);插入图片
13、 wordApp.ActiveWindow.ActivePane.View.SeekView =WdSeekView.
wdSeekCurrentPageFooter;定位到页脚
14、 wordApp.Selection.TypeText("此处写需要在指定位置输出的文字");文本输入
15、 wordDoc.ComputeStatistics(WdStatistic.wdStatisticPages,ref Nothing);得到页码
16、 wordDoc.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);
调用打印机实现打印(调用的是默认打印机)
17、 wordDoc.Close(ref saveChanges,ref Nothing,
ref Nothing);文档退出
18、 wordApp.Quit(ref Nothing,ref Nothing,
ref Nothing);word程序退出
相关文章推荐
- C#操作word的一些基本方法(word打印,插入文件,插入图片,定位页眉页脚,去掉横线)
- C#操作word的一些基本方法(word打印,插入文件,插入图片,定位页眉页脚,去掉横线)
- C#操作word的一些基本方法(word打印,插入文件,插入图片,定位页眉页脚,去掉横线)
- c#之Word基本操作----创建,打开,绘制表格,插入图片等
- Visual Studio 2017中使用正则修改部分内容 如何使用ILAsm与ILDasm修改.Net exe(dll)文件 C#学习-图解教程(1):格式化数字字符串 小程序开发之图片转Base64(C#、.Net) jquery遍历table为每一个单元格取值及赋值 。net加密解密相关方法 .net关于坐标之间一些简单操作
- C# :Word 标签替代文字或图片 (图片浮于文字之上 插入后回车或换行符替换的解决方法)
- C# 文件的一些基本操作(转)//用C#读写ini配置文件
- C# 对sharepoint 列表的一些基本操作,包括添加/删除/查询/上传文件给sharepoint list添加数据
- c# 操作word中在右下角插入图片
- C#中Bitmap类实现对图像操作的一些方法(Asp.net(C#)-放大缩小图片尺寸)
- c#操作word 在指定书签插入文字或者图片
- C#操作数据库中存取图片文件的方法
- 黄聪:C# web word文档操作,任意指定位置插入图片,表格简单操作
- c#操作word 在指定书签插入文字或者图片
- javaWeb项目springMVC框架下利用ITextpdf 工具打印PDF文件的方法(打印表单、插入图片)
- 用C#操作office组件库实现word文档的创建及文字 表格 图片的插入
- 转:C# 对sharepoint 列表的一些基本操作,包括添加/删除/查询/上传文件给sharepoint list添加数据
- 控件的一些基本操作,设置颜色,自动连接,插入图片,padding,ellipsize。
- C# 对sharepoint 列表的一些基本操作,包括添加/删除/查询/上传文件给sharepoint list添加数据
- 07单链表的一些基本操作(创建、测量、插入、打印、删除)