Click or drag to resize

FieldUpdateCultureSource Enumeration

Indicates what culture to use during field update.

Namespace:  Aspose.Words.Fields
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.7.0


public enum FieldUpdateCultureSource


  Member nameValueDescription
CurrentThread0 The culture of the current execution thread is used to update fields.
FieldCode1 The culture specified in the field formatting properties via language setting is used.


Shows how to specify where the culture used for date formatting during field update and mail merge is chosen from.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Insert two merge fields with German locale
builder.Font.LocaleId = 1031;
builder.InsertField("MERGEFIELD Date1 \\@ \"dddd, d MMMM yyyy\"");
builder.Write(" - ");
builder.InsertField("MERGEFIELD Date2 \\@ \"dddd, d MMMM yyyy\"");

// Store the current culture in a variable and explicitly set it to US English
CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture;
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");

// Execute a mail merge for the first MERGEFIELD using the current culture (US English) for date formatting
doc.MailMerge.Execute(new[] { "Date1" }, new object[] { new DateTime(2020, 1, 01) });

// Execute a mail merge for the second MERGEFIELD using the field's culture (German) for date formatting
doc.FieldOptions.FieldUpdateCultureSource = FieldUpdateCultureSource.FieldCode;
doc.MailMerge.Execute(new[] { "Date2" }, new object[] { new DateTime(2020, 1, 01) });

// The first MERGEFIELD has received a date formatted in English, while the second one is in German
Assert.AreEqual("Wednesday, 1 January 2020 - Mittwoch, 1 Januar 2020", doc.Range.Text.Trim());

// Restore the original culture
Thread.CurrentThread.CurrentCulture = currentCulture;

See Also