Thetype exposes the following members.
Gets the text that represents the displayed field result.
Gets the node that represents the field end.
Gets a FieldFormat object that provides typed access to field's formatting.
Gets or sets whether the current result of the field is no longer correct (stale) due to other modifications made to the document.
Gets or sets whether the field is locked (should not recalculate its result).
Gets or sets the LCID of the field.
Gets or sets text that is between the field separator and field end.
Gets the node that represents the field separator. Can be null.
Gets the node that represents the start of the field.
Gets the Microsoft Word field type.
Determines whether the specified object is equal to the current object.(Inherited from Object.)
Returns text between field start and field separator (or field end if there is no separator). Both field code and field result of child fields are included.
Returns text between field start and field separator (or field end if there is no separator).
Serves as the default hash function.(Inherited from Object.)
Gets the Type of the current instance.(Inherited from Object.)
Removes the field from the document. Returns a node right after the field. If the field's end is the last child of its parent node, returns its parent paragraph. If the field is already removed, returns null.
Returns a string that represents the current object.(Inherited from Object.)
Performs the field unlink.
Performs the field update. Throws if the field is being updated already.
Performs a field update. Throws if the field is being updated already.
A field in a Word document is a complex structure consisting of multiple nodes that include field start, field code, field separator, field result and field end. Fields can be nested, contain rich content and span multiple paragraphs or sections in a document. Theclass is a "facade" object that provides properties and methods that allow to work with a field as a single object.
The content between the field start and separator is the field code. The content between the field separator and field end is the field result. The field code typically consists of one or more Run objects that specify instructions. The processing application is expected to execute the field code to calculate the field result.
The process of calculating field results is called the field update. Aspose.Words can update field results of most of the field types in exactly the same way as Microsoft Word does it. Most notably, Aspose.Words can calculate results of even the most complex formula fields. To calculate the field result of a single field use the Update method. To update fields in the whole document use UpdateFields.
You can get the plain text version of the field code using the GetFieldCode(Boolean) method. You can get and set the plain text version of the field result using the Result property. Both the field code and field result can contain complex content, such as nested fields, paragraphs, shapes, tables and in this case you might want to work with the field nodes directly if you need more control.
You do not create instances of the InsertField(String) method.class directly. To create a new field use the
Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); Field field = builder.InsertField("DATE \\@ \"dddd, MMMM dd, yyyy\""); Assert.AreEqual(FieldType.FieldDate, field.Type); Assert.AreEqual("DATE \\@ \"dddd, MMMM dd, yyyy\"", field.GetFieldCode()); // This overload of the InsertField method automatically updates inserted fields. Assert.That(DateTime.Parse(field.Result), Is.EqualTo(DateTime.Today).Within(1).Days);