FieldAutoText
内容
[
隐藏
]FieldAutoText class
实现 AUTOTEXT 字段。
要了解更多信息,请访问使用字段文档文章。
public class FieldAutoText : Field
构造函数
姓名 | 描述 |
---|---|
FieldAutoText() | 默认构造函数。 |
特性
姓名 | 描述 |
---|---|
DisplayResult { get; } | 获取表示显示字段结果的文本。 |
End { get; } | 获取代表字段结束的节点。 |
EntryName { get; set; } | 获取或设置自动图文集条目的名称。 |
Format { get; } | 获得FieldFormat 提供对字段格式进行类型化访问的对象。 |
IsDirty { get; set; } | 获取或设置字段的当前结果是否由于对文档所做的其他修改而不再正确(陈旧)。 |
IsLocked { get; set; } | 获取或设置字段是否被锁定(不应重新计算其结果)。 |
LocaleId { get; set; } | 获取或设置字段的 LCID。 |
Result { get; set; } | 获取或设置字段分隔符和字段结尾之间的文本。 |
Separator { get; } | 获取表示字段分隔符的节点。可以是无效的 . |
Start { get; } | 获取表示字段开始的节点。 |
virtual Type { get; } | 获取 Microsoft Word 字段类型。 |
方法
姓名 | 描述 |
---|---|
GetFieldCode() | 返回字段开始和字段分隔符之间的文本(如果没有分隔符,则返回字段结束)。 包括子字段的字段代码和字段结果。 |
GetFieldCode(bool) | 返回字段开始和字段分隔符之间的文本(如果没有分隔符,则返回字段结束)。 |
Remove() | 从文档中移除该字段。返回紧接该字段之后的节点。如果该字段的末尾是其父节点的最后一个 child ,则返回其父段落。如果该字段已被移除,则返回无效的 . |
Unlink() | 执行字段取消链接。 |
Update() | 执行字段更新。如果字段已在更新,则抛出异常。 |
Update(bool) | 执行字段更新。如果字段已在更新,则抛出异常。 |
评论
插入自动图文集条目。
例子
展示如何显示带有 AUTOTEXT 和 GLOSSARY 字段的构建块。
Document doc = new Document();
// 创建一个词汇表文档并向其中添加自动图文集构建块。
doc.GlossaryDocument = new GlossaryDocument();
BuildingBlock buildingBlock = new BuildingBlock(doc.GlossaryDocument);
buildingBlock.Name = "MyBlock";
buildingBlock.Gallery = BuildingBlockGallery.AutoText;
buildingBlock.Category = "General";
buildingBlock.Description = "MyBlock description";
buildingBlock.Behavior = BuildingBlockBehavior.Paragraph;
doc.GlossaryDocument.AppendChild(buildingBlock);
// 创建一个源并将其作为文本添加到我们的构建块中。
Document buildingBlockSource = new Document();
DocumentBuilder buildingBlockSourceBuilder = new DocumentBuilder(buildingBlockSource);
buildingBlockSourceBuilder.Writeln("Hello World!");
Node buildingBlockContent = doc.GlossaryDocument.ImportNode(buildingBlockSource.FirstSection, true);
buildingBlock.AppendChild(buildingBlockContent);
// 设置一个包含我们的文档或其附加模板可能不包含的部分的文件。
doc.FieldOptions.BuiltInTemplatesPaths = new[] { MyDir + "Busniess brochure.dotx" };
DocumentBuilder builder = new DocumentBuilder(doc);
// 下面是两种使用字段显示我们的构建块内容的方法。
// 1 - 使用 AUTOTEXT 字段:
FieldAutoText fieldAutoText = (FieldAutoText)builder.InsertField(FieldType.FieldAutoText, true);
fieldAutoText.EntryName = "MyBlock";
Assert.AreEqual(" AUTOTEXT MyBlock", fieldAutoText.GetFieldCode());
// 2 - 使用 GLOSSARY 字段:
FieldGlossary fieldGlossary = (FieldGlossary)builder.InsertField(FieldType.FieldGlossary, true);
fieldGlossary.EntryName = "MyBlock";
Assert.AreEqual(" GLOSSARY MyBlock", fieldGlossary.GetFieldCode());
doc.UpdateFields();
doc.Save(ArtifactsDir + "Field.AUTOTEXT.GLOSSARY.dotx");
也可以看看
- class Field
- 命名空间 Aspose.Words.Fields
- 部件 Aspose.Words