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

Free Support Forum - aspose.com

Issue with number format of decimals

Hello.

I am facing an issue regarding number formatting for Decimal fields. The issue occurs only for a specific customer and cannot be reproduced internally.

In brief, the data is fetched from an SQL Server and is “fed” into a word document. The word document is (for testing purposes) very simple:
image.png (3.1 KB)

When executing, the integer field is formatted successfully, but the decimal field shows 4 digits, instead of 2:
image.png (1.3 KB)

When I run the same configuration on our server, the document is produced correctly, both fields have 2 decimal fields. Still, on the customer’s server, it doesn’t work. I checked the regional settings, nothing out of the ordinary. I tried all kinds of formats and other decimal fields, with no luck: in general it completely ignores formatting for decimal fields.

I am using a paid 17.3.0 version of Aspose.Words. Please do look into it, I am at your disposal for any further clarifications.

Thank you in advance,
Kyriakos

@klakkas

Thanks for your inquiry. I am afraid it is difficult to suggest you anything without replicating the issue at our end. It seems system specific issue. Please double check the formatting switch of the Mail Merge field in template. You may Mail Merge the simplest template with hard coded values to localize the issue at that specific server.

// Open an existing document.
Document doc = new Document("E:/Data/Decimal_format_issue.docx");

// Fill the fields in the document with user data.
doc.MailMerge.Execute(
    new string[] { "CASE_CODE", "CASE_DEBT_AMT" },
    new object[] { "10", "10.20" });
doc.Save("E:/data/test.docx");