且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用C#在现有Word文档中插入图像

更新时间:2023-11-07 13:21:10

当然,Word对象模型提供了将图像插入文档的必需方法.要在光标位置添加图片,您只需调用AddPicture 方法"rel =" nofollow> InlineShapes 集合,并传入文件名.

Of course, the Word object model provides the required methods for inserting an image into the document. To add a picture at the cursor location you just need to call the AddPicture method of the InlineShapes collection and pass in the name of the file.

 Application.Selection.InlineShapes.AddPicture(@"C:\SamplePicture.jpg");

请参见如何:以编程方式将图片和艺术字添加到文档中有关更多信息.

您也可以考虑使用Open XML SDK.看一下MSDN中的以下文章:

Also you may consider using the Open XML SDK. Take a look at the following articles in MSDN: