FieldChar class
FieldChar class
Base class for nodes that represent field characters in a document. To learn more, visit the Working with Fields documentation article.
Remarks
A complete field in a Microsoft Word document is a complex structure consisting of a field start character, field code, field separator character, field result and field end character. Some fields only have field start, field code and field end.
To easily insert a new field into a document, use the DocumentBuilder.insert_field() method.
Inheritance: FieldChar → SpecialChar → Inline → Node
Properties
Name | Description |
---|---|
custom_node_id | Specifies custom node identifier. (Inherited from Node) |
document | Gets the document to which this node belongs. (Inherited from Node) |
field_type | Returns the type of the field. |
font | Provides access to the font formatting of this object. (Inherited from Inline) |
is_composite | Returns True if this node can contain other nodes.(Inherited from Node) |
is_delete_revision | Returns true if this object was deleted in Microsoft Word while change tracking was enabled. (Inherited from Inline) |
is_dirty | Gets or sets whether the current result of the field is no longer correct (stale) due to other modifications made to the document. |
is_format_revision | Returns true if formatting of the object was changed in Microsoft Word while change tracking was enabled. (Inherited from Inline) |
is_insert_revision | Returns true if this object was inserted in Microsoft Word while change tracking was enabled. (Inherited from Inline) |
is_locked | Gets or sets whether the parent field is locked (should not recalculate its result). |
is_move_from_revision | Returns True if this object was moved (deleted) in Microsoft Word while change tracking was enabled.(Inherited from Inline) |
is_move_to_revision | Returns True if this object was moved (inserted) in Microsoft Word while change tracking was enabled.(Inherited from Inline) |
next_sibling | Gets the node immediately following this node. (Inherited from Node) |
node_type | Gets the type of this node. (Inherited from Node) |
parent_node | Gets the immediate parent of this node. (Inherited from Node) |
parent_paragraph | Retrieves the parent Paragraph of this node. (Inherited from Inline) |
previous_sibling | Gets the node immediately preceding this node. (Inherited from Node) |
range | Returns a Range object that represents the portion of a document that is contained in this node. (Inherited from Node) |
Methods
Name | Description |
---|---|
accept(visitor) | Accepts a visitor. (Inherited from Node) |
clone(is_clone_children) | Creates a duplicate of the node. (Inherited from Node) |
get_ancestor(ancestor_type) | Gets the first ancestor of the specified object type. (Inherited from Node) |
get_ancestor(ancestor_type) | Gets the first ancestor of the specified NodeType. (Inherited from Node) |
get_field() | Returns a field for the field char. |
get_text() | Gets the text of this node and of all its children. (Inherited from Node) |
next_pre_order(root_node) | Gets next node according to the pre-order tree traversal algorithm. (Inherited from Node) |
node_type_to_string(node_type) | A utility method that converts a node type enum value into a user friendly string. (Inherited from Node) |
previous_pre_order(root_node) | Gets the previous node according to the pre-order tree traversal algorithm. (Inherited from Node) |
remove() | Removes itself from the parent. (Inherited from Node) |
to_string(save_format) | Exports the content of the node into a string in the specified format. (Inherited from Node) |
to_string(save_options) | Exports the content of the node into a string using the specified save options. (Inherited from Node) |
Examples
Shows how to work with a FieldStart node.
doc = aw.Document()
builder = aw.DocumentBuilder(doc)
field = builder.insert_field(aw.fields.FieldType.FIELD_DATE, True).as_field_date()
field.format.date_time_format = 'dddd, MMMM dd, yyyy'
field.update()
field_start = field.start
self.assertEqual(aw.fields.FieldType.FIELD_DATE, field_start.field_type)
self.assertFalse(field_start.is_dirty)
self.assertFalse(field_start.is_locked)
# Retrieve the facade object which represents the field in the document.
field = field_start.get_field().as_field_date()
self.assertFalse(field.is_locked)
self.assertEqual(' DATE \\@ "dddd, MMMM dd, yyyy"', field.get_field_code())
# Update the field to show the current date.
field.update()
See Also
- module aspose.words.fields
- class SpecialChar
- class FieldStart
- class FieldSeparator
- class FieldEnd