0
BigDecimal myNumber = new BigDecimal(1234.56);
NumberFormat instance = NumberFormat.getInstance(Locale.GERMAN);
String localizedNumber = instance.format(myNumber);
System.out.print("\nformatting " + localizedNumber); o/p ->1.234,56

Till here code works fine but below line gives NumberFormatter exception as given string contains comma in it.

BigDecimal bigDecimal = new BigDecimal(localizedNumber);

I want numeric values to be localized but I cannot return string as putting number as string shows below error in excel Number in this cell is formatter as text or preceded by an apostrophe

Is there any way by which I can return back numeric value(BigDecimal / Integer / BigInteger etc) in localized format So that I won't get above error in excel and I can perform filter operations on excel data.

I've also tried new BigDecimalType().valueToString(value, locale); and new BigDecimalType().stringToValue(s, locale); of dynamic jasper reports api.

Archana Mundaye
  • 523
  • 1
  • 5
  • 19

1 Answers1

2

Happy to answer this question which asked me only and quite surprised that no one replied to this. Actually we don't have to do anything for number localization in excel export because it's done by our operating system settings automatically.

Go to "Region and Language" -> Format -> Select language/country name -> Apply and check your excel earlier generated in English.

You will see numbers in currently selected country's number format. :)

Archana Mundaye
  • 523
  • 1
  • 5
  • 19
  • For those who are wondering where "Region and Language" is, click on start and type "Region and Language" :) – Xpleria Apr 12 '18 at 08:55