社区
C#
帖子详情
如何用c#在word中插入图片并且使图片居中显示
woto123
2011-12-13 03:37:03
看了好多帖子,实现了图片的插入,但是我想让图片居中,这个参数在哪里设置!
...全文
1049
2
打赏
收藏
如何用c#在word中插入图片并且使图片居中显示
看了好多帖子,实现了图片的插入,但是我想让图片居中,这个参数在哪里设置!
复制链接
扫一扫
分享
转发到动态
举报
AI
作业
写回复
配置赞助广告
用AI写文章
2 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
koooky
2011-12-13
打赏
举报
回复
http://www.pconline.com.cn/pcedu/empolder/gj/vc/10305/168480.html
csdn_aspnet
2011-12-13
打赏
举报
回复
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
文档.doc
7. **添加文档内容**: 虽然没有在提供的代码片段
中
展示,但操作
Word
文档的常见任务还包括添加文本、
插入图片
、设置字体和颜色、应用样式等。这可以通过调用
Word
对象模型
中
的相应方法完成,例如 `oDoc.Content.Text =...
使用
C#
实现在
word
中
插入页眉页脚的方法
在
C#
中
操作
Word
插入页脚,可以使用以下步骤: 1. 首先,我们需要检查当前视图是否为打印视图,如果不是,将其切换到打印视图,以便能够编辑页脚。这可以通过设置`ActiveWindow.ActivePane.View.Type`为`wdPrintView...
用
C#
生成
word
文档
标题:“用
C#
生成
word
文档” 描述:这段代码示例展示了如何使用
C#
与Microsoft Office Interop
Word
库来创建和操作
Word
文档。虽然描述部分较为简略,但从代码片段可以推测出,这是一个实用的工具,能够帮助用户在不...
c#
生成
word
文档
通过上述示例代码,我们可以看到使用
C#
和 Microsoft.Office.Interop.
Word
库可以轻松地生成
Word
文档,并且可以根据需求定制文档的样式和内容。这对于需要自动化文档生成的应用场景非常有用,同时也提供了极大的...
C#
进行
word
开发相关代码汇总.pdf
这些只是
C#
操作
Word
文档的基本步骤,实际上,
Word
对象模型提供了更多的功能,包括
插入图片
、应用复杂的样式、执行查找和替换、自动化邮件合并等。熟练掌握这些技能后,你可以创建出强大的文档处理工具,极大地提升...
C#
111,098
社区成员
642,554
社区内容
发帖
与我相关
我的任务
C#
.NET技术 C#
复制链接
扫一扫
分享
社区描述
.NET技术 C#
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
让您成为最强悍的C#开发者
试试用AI创作助手写篇文章吧
+ 用AI写文章