Date and number format mismatch for non-English locale

Hi,


One of our customer is using a different locale while creating Office document, they use Czech (Czech Republic) format for date and numbers (Control Panel -> Region and Language) in their environment.

MS Excel uses this system format while displaying the file, e.g. it changes the numbers from ‘11,000’ to ‘11 000’ and dates from American format to Czech format like ‘25. 11. 2014’ … Problem is that Aspose continues to use only English US locale / format while generating PDF, so we will still see numbers like ‘25,362’ and so on, and hence there’s a mismatch between input and output, which is not acceptable for the customer.

Are non-English formats not supported or something ? I don’t see it documented in any Aspose documentation. Is there any way to specify the locale while generating PDF ? Please check and explore the possibility of fixing it, this is a serious issue / limitation.

Thanks,
Rajiv

Hi Rajiv,


Thank you for contacting Aspose support.

You can set the number formats according to any region for the rendered PDF while using the WorkbookSettings.setRegion method. Please review the following piece of code and its resultant PDF as attached.

Java

Workbook wb = new Workbook(“D:/temp/OL50000012 (repaired).xlsm”);
wb.getSettings().setRegion(CountryCode.CZECH);
wb.save(“D:/output.pdf”, SaveFormat.PDF);


Here is the list of regions currently supported by Aspose.Cells APIs. Please note, both versions of Aspose.Cells APIs (.NET & Java) share the common CountryCode enumeration.

Hi Babar,


Thanks for quick response.

Instead of hard-coding, is it not possible to set the system locale dynamically (whichever locale it may be) ? Is there any such technique available in Aspose ?

Thanks,
Rajiv

Hi Rajiv,


I am afraid, Aspose.Cells APIs do not provide the means to automatically set the locale/region for the workbook for rendering purposes. You have to set it manually in your code as demonstrated earlier in this thread.

Hi Rajiv,


Adding more to my previous response, if you meant to format the numbers with the system’s default locale (system on which conversion is taking place) then it is just the way Aspose.Cells APIs format numbers by default for spreadsheet formats such as XLSX/XLSM/XMLB. Aspose.Cells for Java API uses the locale got by Locale.getDefault() to format numbers if it isn’t specified explicitly for the workbook’s region/locale. However, for Locale.getDefault(), its behavior has changed since JDK1.7. Please see the bug link. So, if you are using JDK1.7/1.8, maybe the used locale by Aspose.Cells(Locale.getDefault()) is not the expected one you set for your machine. It is issue of JDK and cannot be solved by our component.
As an workaround, we think you can specify the default locale when starting your java application by setting the JVM options such as:

java -Duser.language=cs -Duser.country=CZ …


or by code:
Locale.setDefault(new Locale(“cs”, "CZ”));