Please forward us your MS Excel file and the code, in order to let us know what you are trying to do. This will help us to understand and investigate the issue.
The code above inserts number 1234567.89 into B1 (cell [0, 0]) and saves file into XLS and PDF format. Output value is "1,234,567.89" - grouping separator is a comma (please see the attached XML file). My task is to set correct grouping and decimal separator for number to have it as "1 234 567.89" or as "1'234'567'.89".
I tried to use setting locale and/or language with methods
Workbook.setLocale()
and setLanguage() are just to set the "COUNTRY" properties of
Workbook which will be saved when saving a workbook in MS Excel. But the actual
formattings of the workbook's data still depends on the locale in
effect when viewing the data in MS Excel. For data formattings, the output
of Aspose.Cells is just same with what you can get in MS Excel. That
is, current locale in effect will determine the formattings.
Well, as
a workaround I think you can change the default locale before calling
Workbook.save() method and recover the default locale after Workbook.save(),
Well I am afraid, it requires us to change the internal model of formatting numbers to
support custom Locales. We have recorded your requirement into our issue tracking
system with id CELLSJAVA-19910. We will looking into this feature later when we
finish some other important tasks (on hand).
Can you please explain the solution? I’m also trying to create PDFs for many different locales on a single server, so we can’t change the default locale.
One of the earlier messages in this thread suggests workbook.setLocale, but that method no longer exists (I’m using aspose-cell-7.1). setRegion and setLanguage are both marked as deprecated, but I can’t find any information on what should be used instead.
Sorry - that doesn’t work for me, even with 7.1.2.2. If I change the Java default then the PDF changes, but as others have said that isn’t suitable for a multi-user system.
If I set the locale in the workbook settings the PDF still uses the default locale.
We are working on this feature now and we will try to provide a fix/version in about one month that supports to format numbers according with the Locale specified by user(settings of Workbook.Settings.Locale/Region).
The previous post by the ASPOSE team suggested that a fix for the locale setting would be ready in approximately one month (posted - 03-23-2012). We are now nearly three months on. Is there an update on when this functionality will be included (or if it has been included) and more importantly when will it be released?
and log statements confirm it is setting the correct locale (I’ve been using nl_BE in my tests). But the PDF still uses English number formats (123,456.89) instead of 123.456,89 as I’d expect.
Thanks for your posting and using Aspose.Cells for Java.
I was able to replicate the problem using the source file (attachment). When I changed the locale to Germany, the output pdf is still showing in English locale format.
From this fix, we format cell values by the setting:
WorkbookSettings.Region/Locale. Users can specify the locale for formatting
values by Workbook.getSettings().setRegion()/setLocale().
A notable change for formatting existing excel97-2003 files: For existing
excel97-2003 template files, the region value may has been saved in it and
different from the default locale of application. We will format values by the
saved region value if user did not change it explicitly after loading the
template file. So the output for this template file will be different from what
created by old versions because in old versions we always format value by the
default locale of java application.
To make sure that existing template files be
formatted with system default locale, user should add following code before get
any formatted values:
Workbook.getSettings().setRegion(CountryCode.DEFAULT); // or
setLocale(Locale.getDefault());