Free Support Forum - aspose.com

Default number or percentage format does not work anymore (7.3.2)

Hi,

I have upgraded aspose cell from 2.0.1 to 7.3.2.
After migrating our code, I found a difference between 2.0.1 and 7.3.2: the default percentage format is different between both version when a xls file is read.

Example:
Cell A1 (percentage format):
=> value =0
=> displayed value (in excel) =0,00%
The separator “,” depends on the regional settings of windows (here, I use french settings).
With english settings, the displayed value is 0.00%.

As we need to read the formatted value of the cell, we call cell.getStringValue().

With apose cells 2.0.1, the separator seems to depend on the settings of the JVM:
- with -Duser.language=en -Duser.country=US, the separator is “.” so cell.getStringValue() returns “0.00%”
- with -Duser.language=fr -Duser.country=FR, the separator is “,” so cell.getStringValue() returns "0,00%"

With aspose cells 7.3.2, the separator seems to be the separator displayed by excel when it was saved.
So cell.getStringValue() always return “0,00%” if the file was saved with french settings.

Is it possible to configure aspose cells to use english settings when it reads a file even if the file was saved with french settings?

Thanks

clhclh








Hi,

Thanks for your posting and using Aspose.Cells for Java.

Please download and use the latest version:
Aspose.Cells
for Java v7.3.2.4



Please use the following code. Now it will read your string formatted according to English locale no matter if your locale has been set for French.

Java

String filePath = "F:\\Shak-Data-RW\\Downloads\\source.xlsx";

Workbook workbook = new Workbook(filePath);

//Or you can comment this line and uncomment the next one, it will also have same effect
workbook.getSettings().setLocale(Locale.ENGLISH);
//workbook.getSettings().setRegion(CountryCode.USA);

String strValue = workbook.getWorksheets().get(0).getCells().get("A1").getStringValue();

System.out.println(strValue);