使用C#填充.doc文件 [英] filling a .doc file using C#
本文介绍了使用C#填充.doc文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个运行中的ASP.NET Web应用程序来管理项目和客户.现在,我想为一些客户生成一个word文件.在此文件中应显示有关客户的一些数据.每个生成的文件应具有相同的数据和相同的设计.因此,我想使用这些字段创建新的Word模板,并以编程方式填充占位符.
I have a working ASP.NET web application to manage projects and customers. Now I want to generate a word file for some customers. In this file should be displayed some data about the customer. Every generated file should have the same data and the same design. So I want to craete a new Word Template with the fields and want to fill the placeholders programmatically.
推荐答案
我对.NET使用Office Interop Services做了同样的事情.只需创建一个Word模板文件并使其结构,然后在要添加一些信息的每个位置插入boomarks.
您可以按名称访问任何书签:WordApplication.ActiveDocument.Bookmarks["BookmarkName"]
.
然后使用其Range
将table
,text
或image
插入该位置.
希望对您有所帮助.
I did the same thing with Office Interop Services for .NET. Just create a word template file and make its structure then insert boomarks in every position that you want to add some information.
You can access to any bookmark by its name :WordApplication.ActiveDocument.Bookmarks["BookmarkName"]
.
Then use itsRange
to inserttable
,text
orimage
into that position.
Hope it helps.
WordApplication.ActiveDocument.Bookmarks["Your Bookmark name"]
这篇关于使用C#填充.doc文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文