Version 24.5 broke number formatting for mail merge

Dear Aspose!

merge field definition
{ MERGEFIELD C12628_0 \# "### ### ### ### ##0.0000" \* MERGEFORMAT }

Value: 35000
The output with 24.4

The output with 24.5

Hungarian locale/environment.

Thank you!

@EPluribusUnum

The number formatting issue you are experiencing with the mail merge in version 24.5 is likely due to changes in how formatting is handled in that version. Here’s how to address the problem:

  1. Cause: The issue may stem from the locale settings or changes in the formatting rules in version 24.5.

  2. Solution:

    • Check Locale Settings: Ensure your environment is set to the Hungarian locale, as this can significantly impact number formatting.
    • Test with Different Formats: Adjust the format string in your MERGEFIELD definition. For example, simplify the format to:
      MERGEFIELD C12628_0 \# "0.0000" \* MERGEFORMAT
      
    • Review Release Notes: Look at the release notes for version 24.5 for any documented changes related to number formatting or mail merge functionality.
  3. Next Steps:

    • If the issue persists, consider reverting to version 24.4 temporarily while you continue to investigate.
    • If none of these steps resolve the issue, please contact Aspose support with detailed information about your environment and the specific problem.

Please follow these steps, and let me know if you need further assistance!

The customer has control over formatting, we don’t have control.

@EPluribusUnum Which culture is used? Could you please attach sample input and output documents along with simple code that will allow us to reproduce the problem? We will check the issue and provide you more information.

@alexey.noskov , culture does not help here, the IFieldUpdateCultureProvider not called. It supports only date/time. (see : FieldOptions | Aspose.Words for Java )

Attached the example code, dotx and output generated with Asposw.words with 24.4 and 24.5.
317137.zip (32.5 KB)

@EPluribusUnum The output is actually expected for Hungarian culture. In hu-HU locale coma is used as decimal separator. But in your mergefield dot is specified as decimal separator:

{ MERGEFIELD NUM \# "### ### ### ### ##0.0000" \* MERGEFORMAT }

To get the expected value in Hungarian culture you should change format code like this:

{ MERGEFIELD NUM \# "### ### ### ### ##0,0000" \* MERGEFORMAT }
// Set locale
Locale current = CurrentThreadSettings.getLocale();
CurrentThreadSettings.setLocale(Locale.forLanguageTag("hu-HU"));

DataTable dt = new DataTable("TABLE");
dt.getColumns().add("NUM");
dt.getRows().add(35000);
        
Document doc = new Document("C:\\Temp\\in.docx");
doc.getMailMerge().executeWithRegions(dt);
doc.save("C:\\Temp\\out.pdf");

// Restore locale.
CurrentThreadSettings.setLocale(current);

in.docx (12.6 KB)
out.pdf (24.7 KB)

Checked in MS Word. It behaves as 24.5, not as 24.4.
So this break was due to follow MS Word behaviour.

1 Like