How to Set Word Document Properties with C#

Word properties shows a brief description about one document. Through properties, we can learn general information about this document, such as document size, date to create and so on. Also, we can set advance properties by ourselves, for example, adding document title, author information. In this post, I want to introduce a method about how to set Word document properties with C# via Spire.Doc.

//Create word document
Document document = new Document();

document.BuiltinDocumentProperties.Title = "Document Properties";
document.BuiltinDocumentProperties.Subject = "demo";
document.BuiltinDocumentProperties.Author = "S.W";
document.BuiltinDocumentProperties.Company = "e-iceblue";
document.BuiltinDocumentProperties.Manager = "H.H";
document.BuiltinDocumentProperties.Category = "Document Setting";
document.BuiltinDocumentProperties.Keywords = "Property, Setting, Word";
document.BuiltinDocumentProperties.Comments = "This is just an example.";

Section section = document.AddSection();
section.PageSetup.Margins.Top = 72f;
section.PageSetup.Margins.Bottom = 72f;
section.PageSetup.Margins.Left = 89.85f;
section.PageSetup.Margins.Right = 89.85f;

String p1
    = "Microsoft Word is a word processor designed by Microsoft. "
    + "It was first released in 1983 under the name Multi-Tool Word for Xenix systems. "
    + "Subsequent versions were later written for several other platforms including "
    + "IBM PCs running DOS (1983), the Apple Macintosh (1984), the AT&T Unix PC (1985), "
    + "Atari ST (1986), SCO UNIX, OS/2, and Microsoft Windows (1989). ";
String p2
    = "Microsoft Office Word instead of merely Microsoft Word. "
    + "The 2010 version appears to be branded as Microsoft Word, "
    + "once again. The current versions are Microsoft Word 2010 for Windows and 2008 for Mac.";
section.AddParagraph().AppendText(p1).CharacterFormat.FontSize = 14;
section.AddParagraph().AppendText(p2).CharacterFormat.FontSize = 14;

//Save doc file.
document.SaveToFile("Sample.doc",FileFormat.Doc);
时间: 2024-11-10 00:12:47

How to Set Word Document Properties with C#的相关文章

word:Can't find the word document templant:WordToRqm.doc

问题:打开word文件时弹出提示 Cannot find the Word template:WordToRqm.dot 原因:安装了power designer. 解决:运行regedit.exe 打开注册表编辑器,定位到:HKEY_CURRENT_USER\Software\Microsoft\Office\Word\Addins\WordToRQM12.Connect 键,    双击右边的“LoadBehavior”,在弹出的修改值对话框中将其值从3改为2,然后关闭注册表编辑器,重新启动

【翻译自mos文章】 怎么对Microsoft (Office) Word Document 2007 索引化?

怎么对Microsoft (Office) Word Document 2007 索引化? 来源于:How To Index a Microsoft (Office) Word Document 2007 ? (文档 ID 752710.1) 适用于: Oracle Text - Version: 11.1.0.7 to 11.2.0.3 - Release: 11.1 to 11.2 Information in this document applies to any platform. 目

【转】How to view word document in WPF application

How to view word document in WPF application (CSVSTOViewWordInWPF) Introduction The Sample demonstrates how to view word document in WPF application. WPF does not support to view Word documents directly but some customers want to show word document i

asp.net Word Document Open return null

velocity模板技术生成word文档

本文介绍采用velocity技术在Java中生成word文档的方法. 1.新建一个word文档,编辑内容如下: 2.将上述word文档另存为htm格式的文件 3.新建一个Java Project项目velocityTest,加入Velocity所依赖的Jar包velocity-dep-1.5-beta2.jar. 4.在src目录下新建一个velocity.vm文件,将第二步生成的velocity.htm用文本编辑器打开,复制内容到velocity.vm中.内容如下: <html xmlns:v

Java使用velocity导出word

效果展示: 使用word编辑好模板 先在模板中填充部分数据(之所以先写好两条数据,是为了在保存为xml用文本编辑器打开后快速定位到需要出传入的数据.增加不同颜色的两条数据,是为了判断颜色),然后保存文件为 然后再用普通的文本编辑器打开 以上是模板的创建. 导出后的word文档展示 开发过程记录: 1,  首先创建工程,导入 2,  创建模板文件,将修改好的xml文件用普通文本工作打开,然后复制到改文件中. 3,  新建 4,  执行该类,即可导出word. 代码展示: Person.java i

POI加dom4j将数据库的数据按一定格式生成word文档

一:需求:将从数据库查处来的数据,生成word文档,并有固定的格式.(dom4j的jar包+poi的jar包) 二:解决:(1)先建立固定格式的word文档(2007版本以上),另存成为xml文件,作为模板.(修改xml节点,添加属性,用于标示要填固定数据的节点) (2)dom4j解析模板xml文件,将文件读入内存,并把数据库数据写入内存的xml模型中 (3)利用poi将内存中的含有数据库内容的xml模型转换成word内存模型,利用输出流输出word文档 三:DEMO [1]模板的word文档

C#生成word文档

最近两天研究了一下如何使用VS2008(C#语言)输出Word文档.以下是几点总结: 1.非常简单. 2.开发及运行环境要求.操作系统为:WindowsXP(安装.net framework2.0)/Vista/Win7:在操作系统必须安装Word2003完全安装版.这里必须要强调是Word2003完全安装版,因为软件开发及运行都需要一个com组件:Microsoft word 11.0 Object Library.如果不是Word2003完全安装版,可以下载这个com组件,并手动的安装这个c

C#实现对Word文件读写[转]

手头上的一个项目报表相对比较简单,所以报表打印采用VBA引擎,通过定制Word模版,然后根据模版需要填充数据,然后OK,打印即可. 实现方法:首先需要引用VBA组建,我用的是Office2003 Professional,Dll版本号为Microsoft Word11.0 另外当然还需要引用Interop.Word.Dll. 代码如下: ///#region 打开Word文档,并且返回对象wDoc,wDoc /// /// 打开Word文档,并且返回对象wDoc,wDoc /// /// 完整W