We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Display the currency symbol based on system culture setting

Hi,

I want to display the currency symbol based on system culture setting. Is there any possible way to do that in Aspose.Words for .NET or this feature is unavailable.

This message was posted using Email2Forum by Mudassir Fayyaz.

Hi Sathish,

Yes, you can do that. Please share your scenario where you want to implement this. If you want to display these symbols during mail merge, you can use FieldMergingCallback in your code e.g.

Document doc = new Document("Sample.docx");
doc.MailMerge.FieldMergingCallback = new HandleMergeField();
doc.MailMerge.Execute(
new string[] { "Field1", "Field2", "Field3" },
new object[] { 300, 400, 500 });

and implement **IFieldMergingCallback * * as you can see in the following code.

class HandleMergeField : IFieldMergingCallback
{
    private DocumentBuilder mBuilder;
    void IFieldMergingCallback.FieldMerging(FieldMergingArgs args)
    {
        if (mBuilder == null)
            mBuilder = new DocumentBuilder(args.Document);
        // This way we catch the beginning of a new row.
        if (args.FieldName == "Field1")
        {
            System.Globalization.NumberFormatInfo nfi = new System.Globalization.CultureInfo(System.Globalization.CultureInfo.CurrentCulture.Name).NumberFormat;
            //System.Globalization.NumberFormatInfo nfi = new System.Globalization.CultureInfo("fr-FR").NumberFormat;
            double oldValue = Convert.ToDouble(args.FieldValue);
            string updatedValue = oldValue.ToString("C", nfi);
            mBuilder.MoveToMergeField(args.FieldName);
            mBuilder.Write(updatedValue);
        }
    }

    void IFieldMergingCallback.ImageFieldMerging(ImageFieldMergingArgs e)
    {
        // Do nothing.
    }
}

I have changed the format of one filed, you can do that for specific or all fields according to your requirement.

Please feel free to contact us in case you have further comments or questions.

Best Regards,