Mail Merge: Number formats (decimals) have changed after 24.4

Decimal merge field number formatting has changed, starting from 24.5 (current version 24.7). This breaks many of our customer’s reports, and we’ve had to downgrade to 24.4.

Expected number format (prior to 24.5): “1 500 000,50”
Actual number format (24.5 and onwards): “15 000.01”

Attached is a minimal .NET 8 project that can reproduce results. Simply change the Aspose.Words version and re-run. The (simplified) template file, an XML file and pre-produced result files are also attached. See the Period as decimal separator value.

NOTE! This change has been reported from several of our customers.

Result_24.4.0.docx (21.4 KB)
Result_24.5.0.docx (21.5 KB)

AsposeIssue.MailMergeDecimals.zip (109.3 KB)

template.docx (13.8 KB)
mergedata.zip (244 Bytes)

Thank you!

@sigbjorn I do not think that this is the defect since in your template an incorrect number format is used. By default Aspose.Words uses the current thread culture to format the values. Let suppose the current thread culture is English, in this case dot is used as a decimal separator, so the following number format is invalid for English culture ### ### ##0,00. The opposite situation will be if you specify, for example, Ukrainian culture, where coma is used as a decimal separator, in this case number format with dot ### ### ##0.00 is invalid.
So to have correct number format it is required to use correct decimal separators for the culture.

@alexey.noskov Thanks for your reply!

Although it may be an explanation, how come that this behavior has suddenly changed, starting with version 24.5? I have not been able to find a relevant release note.

As stated, this breaks many of our customer’s templates, that we are not in charge of. In other words, we do not want to impose this hassle on them unless required. Can this change of behavior be explained by a change in 24.5?

@sigbjorn What culture is used in your environment? In invariant culture I got the same output with 24.4 and 24.7 versions of Aspose.Words and the following test code:

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.InsertField("MERGEFIELD Amount \\# \"### ### ##0,00\"");
builder.Writeln();
builder.InsertField("MERGEFIELD Amount \\# \"### ### ##0.00\"");
doc.MailMerge.Execute(new string[] { "Amount" }, new object[] { 1500000.5 });
doc.Save(@"C:\Temp\out.docx");

out_24.4.docx (7.0 KB)
out_24.7.docx (7.0 KB)

Could you please run the above code on your side?

@alexey.noskov Thanks again.

Your example reflects the changed behavior when I run it on my computer:

out_24.4.docx (17.4 KB)
out_24.7.docx (17.6 KB)

The culture in my environment (CultureInfo.CurrentCulture) is Norwegian Bokmål (nb-NO).

@sigbjorn Thank you for additional information. The problem is reproducible with Norwegian culture.

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): WORDSNET-27221

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

1 Like

@sigbjorn We have completed analyzing the issue and concluded it is not a bug. MS Word produces the same result under the nb-NO locale
MS.docx (13.3 KB)
data.zip (167 Bytes)

The nb-NO locale uses , as decimal separator and nbsp (non-breaking space) as group separator. Therefore, the format ### ### ##0.00 contains no decimal separator, so the formatted value 1500000.5 is rounded up to 1500001 . Then, the . symbol is inserted between 2nd and 3rd digits because it’s not used in the nb-NO locale and is treated as regular text. Leading # placeholders without a corresponding digit are replaced by spaces.

@alexey.noskov Thank you. We agree that this is not a bug, even though the behavior has changed.

We will solve this issue properly on our side too.

Thanks for the quick attention!

1 Like

The issues you have found earlier (filed as WORDSNET-27221) have been fixed in this Aspose.Words for .NET 24.9 update also available on NuGet.