Class WField
Represents the field in the document.
Inheritance
Inherited Members
Namespace: Syncfusion.DocIO.DLS
Assembly: Syncfusion.DocIO.Portable.dll
Syntax
public class WField : WTextRange, IXDLSSerializable, IOfficeRun, IStringWidget, ISplitLeafWidget, ITextMeasurable, IWField, IWTextRange, IParagraphItem, IEntity, ILeafWidget, IWidget
Constructors
WField(IWordDocument)
Creates a new instance of the WField class with specified IWordDocument instance.
Declaration
public WField(IWordDocument doc)
Parameters
Type | Name | Description |
---|---|---|
IWordDocument | doc | The Word document instance |
Fields
m_bConvertedToText
Declaration
protected bool m_bConvertedToText
Field Value
Type |
---|
System.Boolean |
m_fieldType
Declaration
protected FieldType m_fieldType
Field Value
Type |
---|
FieldType |
m_fieldValue
Declaration
protected string m_fieldValue
Field Value
Type |
---|
System.String |
m_formattingString
Declaration
protected string m_formattingString
Field Value
Type |
---|
System.String |
m_paraItemType
Declaration
protected ParagraphItemType m_paraItemType
Field Value
Type |
---|
ParagraphItemType |
m_textFormat
Declaration
protected TextFormat m_textFormat
Field Value
Type |
---|
TextFormat |
Properties
EntityType
Gets the type of the entity. Read-only.
Declaration
public override EntityType EntityType { get; }
Property Value
Type | Description |
---|---|
EntityType | The EntityType of the current item. |
Overrides
FieldCode
Gets or sets the field code.
Declaration
public string FieldCode { get; set; }
Property Value
Type | Description |
---|---|
System.String | The field code information used to evaluate the resultant value of the field. |
FieldPattern
Gets or sets field pattern.
Declaration
public string FieldPattern { get; set; }
Property Value
Type |
---|
System.String |
FieldType
Gets or sets field type.
Declaration
public FieldType FieldType { get; set; }
Property Value
Type | Description |
---|---|
FieldType | the FieldType represents the type of the field. |
FieldValue
Gets the field value. Read-only.
Declaration
public string FieldValue { get; }
Property Value
Type | Description |
---|---|
System.String | The field value. |
Text
Gets or sets the text.
Declaration
public override string Text { get; set; }
Property Value
Type | Description |
---|---|
System.String | The string that specifies the text. |
Overrides
TextFormat
Gets or sets the text format field switch that defines how to display field results.
Declaration
public TextFormat TextFormat { get; set; }
Property Value
Type |
---|
TextFormat |
Methods
CloneImpl()
Clones itself.
Declaration
protected override object CloneImpl()
Returns
Type | Description |
---|---|
System.Object | Returns cloned object. |
Overrides
ConvertSwitchesToString()
Converts the switches to string.
Declaration
protected virtual string ConvertSwitchesToString()
Returns
Type |
---|
System.String |
CreateLayoutInfo()
Declaration
protected override void CreateLayoutInfo()
Overrides
GetClonedTable(Entity, Boolean)
Gets the cloned table.
Declaration
protected Entity GetClonedTable(Entity entity, bool isRefFieldUpdate)
Parameters
Type | Name | Description |
---|---|---|
Entity | entity | The entity. |
System.Boolean | isRefFieldUpdate |
Returns
Type |
---|
Entity |
GetTextRange(String)
Gets the text range.
Declaration
protected WTextRange GetTextRange(string text)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | The text. |
Returns
Type |
---|
WTextRange |
ParseField(String)
Parses the field.
Declaration
protected void ParseField(string fieldCode)
Parameters
Type | Name | Description |
---|---|---|
System.String | fieldCode | The field code. |
ParseFieldCode(String)
Declaration
protected virtual void ParseFieldCode(string fieldCode)
Parameters
Type | Name | Description |
---|---|---|
System.String | fieldCode |
ParseFieldFormat(String[])
Parses the field format.
Declaration
protected void ParseFieldFormat(string[] fieldValues)
Parameters
Type | Name | Description |
---|---|---|
System.String[] | fieldValues | The field values. |
ReadXmlAttributes(IXDLSAttributeReader)
Reads object data from xml attributes.
Declaration
protected override void ReadXmlAttributes(IXDLSAttributeReader reader)
Parameters
Type | Name | Description |
---|---|---|
IXDLSAttributeReader | reader | The IXDLSAttributeReader object. |
Overrides
RemoveMergeFormat(String)
Removes the merge format.
Declaration
protected string RemoveMergeFormat(string text)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | The text. |
Returns
Type |
---|
System.String |
RemovePreviousResult()
Removes the previous result.
Declaration
protected void RemovePreviousResult()
RemoveText(String, String)
Removes the text.
Declaration
protected string RemoveText(string text, string textToRevome)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | The text. |
System.String | textToRevome | The text to revome. |
Returns
Type |
---|
System.String |
SplitIfArguments(String, ref List<Int32>, ref String)
Splits if arguments.
Declaration
protected List<string> SplitIfArguments(string text, ref List<int> operatorIndexForDoubleQuotes, ref string operatorValue)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | |
System.Collections.Generic.List<System.Int32> | operatorIndexForDoubleQuotes | |
System.String | operatorValue |
Returns
Type |
---|
System.Collections.Generic.List<System.String> |
Unlink()
Replaces the field with its most recent result.
Declaration
public void Unlink()
Remarks
When you unlink a field, its current result is converted to text or a graphic and can no longer be updated automatically. Note that the fields such as XE (Index Entry) fields and SEQ (Sequence) fields cannot be unlinked.
Examples
The following example illustrates how to unlink the specified field.
//Creates an instance of WordDocument class
WordDocument document = new WordDocument();
//Adds a new section into the Word Document
IWSection section = document.AddSection();
//Adds a new paragraph into Word document and appends text into paragraph
IWParagraph paragraph = section.AddParagraph();
paragraph.AppendText("Today's Date: ");
//Adds the new Date field in Word document with field name and its type
WField field = paragraph.AppendField("Date", FieldType.FieldDate) as WField;
//Updates the field
field.Update();
//Unlink the field
field.Unlink();
//Saves the document in the given name and format
document.Save("Sample.docx", FormatType.Docx);
//Releases the resources occupied by WordDocument instance
document.Close();
'Creates an instance of WordDocument class
Dim document As WordDocument = New WordDocument()
'Adds a new section into the Word Document
Dim section As IWSection = document.AddSection()
'Adds a new paragraph into Word document and appends text into paragraph
Dim paragraph As IWParagraph = section.AddParagraph()
paragraph.AppendText("Today's Date: ")
'Adds the new Date field in Word document with field name and its type
Dim field As WField = CType(paragraph.AppendField("Date", FieldType.FieldDate), WField)
'Updates the field
field.Update()
'Unlink the field
field.Unlink()
'Saves the document in the given name and format
document.Save("Sample.docx", FormatType.Docx)
'Releases the resources occupied by WordDocument instance
document.Close()
Update()
Updates the field result for this WField.
Declaration
public void Update()
Remarks
Essential DocIO currently support the updating of field result for the following field types only:
Also while updating of NUMPAGES field and Cross Reference field with Page number and Paragraph number options are not supported in Silverlight, WinRT, Universal, Windows Phone and Xamarin platforms.
Currently group shapes, drawing canvas, and table auto resizing are not supported in Word to PDF lay outing, and this may lead to update incorrect page number and total number of pages.
UpdateCondition(String, List<Int32>, String)
Updates the condition.
Declaration
protected string UpdateCondition(string text, List<int> operatorIndex, string operatorValue)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | The Text which is the fieldcode after removing the true and false part |
System.Collections.Generic.List<System.Int32> | operatorIndex | The index of operator in text |
System.String | operatorValue | The value of operator |
Returns
Type |
---|
System.String |
UpdateFieldCode(String)
Updates Field code
Declaration
protected virtual void UpdateFieldCode(string fieldCode)
Parameters
Type | Name | Description |
---|---|---|
System.String | fieldCode |
UpdateTextForParagraphItem(Entity, Boolean)
Updates the text for paragraph item.
Declaration
protected string UpdateTextForParagraphItem(Entity entity, bool isUpdateNestedFields)
Parameters
Type | Name | Description |
---|---|---|
Entity | entity | The entity. |
System.Boolean | isUpdateNestedFields |
Returns
Type |
---|
System.String |
UpdateTextForTextBodyItem(Entity, Boolean)
Updates the text for text body item.
Declaration
protected string UpdateTextForTextBodyItem(Entity entity, bool isUpdateNestedFields)
Parameters
Type | Name | Description |
---|---|---|
Entity | entity | The entity. |
System.Boolean | isUpdateNestedFields |
Returns
Type |
---|
System.String |
WriteXmlAttributes(IXDLSAttributeWriter)
Writes object data as xml attributes.
Declaration
protected override void WriteXmlAttributes(IXDLSAttributeWriter writer)
Parameters
Type | Name | Description |
---|---|---|
IXDLSAttributeWriter | writer | The IXDLSAttributeWriter object. |