I’ve had a lot of European users that have not reported any problem in formatting currency in Word merge fields using picture switches, until yesterday. My user is located in Denmark and the currency value he’s trying to display in a Word merge is in kroners.
The problem is that it seems like Aspose.Words is ignoring the decimal place in the field. For example, the merge field has the value “69025.0”, but the output after merging is “690250,00”.
Here’s my code and the template. Thanks so much for taking a look.
protected void Button1_Click(object sender, EventArgs e)
// 2007-09-03: This sets the users locale information… critical for proper number formatting by Aspose
string UserLocale = “da-DK”;
System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(UserLocale);
// Sample Data
DataTable dt = new DataTable(“Main”);
dt.Columns.Add(new DataColumn(“OPPORTUNITY_AMOUNT”, Type.GetType(“System.String”)));
DataRow dr = dt.NewRow();
dr[“OPPORTUNITY_AMOUNT”] = “69025.0”;
// Use Aspose to grab the mail merge template
string templateFileName = Server.MapPath(@“App_Data\Thor.doc”);
// Perform the merge. Notice the numeric formatting on the second field
Document doc = new Document(templateFileName);
doc.Save(""" + “output.doc” + “”", SaveFormat.Doc, Aspose.Words.SaveType.OpenInWord, Response);
Here are the values displayed in the output Word document:
Unformatted field value:
Formatted field value: