Apply Custom Formatting to Fields
Sometimes users need to apply custom formatting to fields. In this article, we will look at a couple of examples of how this can be done.
To learn more options, see the full list of properties for each field type in the corresponding class in the Fields namespace.
How to Apply Custom Formatting to Field Result
Aspose.Words provides API for custom formatting of field’s result. You can implement IFieldResultFormatter interface to control how the field result is formatted. You can apply numeric format switch, i.e. # “#.##”, date/time format switch, i.e. @ “dd.MM.yyyy”, and number format switch, i.e. * Ordinal.
The following code example shows how to apply custom formatting for the field result:
How to evaluate IF
condition
If you want to evaluate IF
condition after mail merge, you can use the EvaluateCondition method that immediately returns the result of the expression evaluation.
The following code example shows how to use this method:
How to Apply Custom Formatting to Time Field
By default Aspose.Words updates TIME
field with current culture short time format. If you want to format the TIME
field according to your requirement, you can achieve this by implementing IFieldUpdateCultureProvider interface.
The following code examples shows how to apply custom formatting to the TIME
field: