entzik
entzik

Reputation: 654

Excel currency format with Apache POI

I use Apache POI to write excel sheets. I'm very happy with it, but I have the following problem: my program is multi-currency and internationalized. In the excel sheet I write, I want my currency cells to be properly formatted. For that,

I need a routine that would build the right Excel currency format (eg: "[$$-409]#,##0.00;-[$$-409]#,##0.00") from java.util.Currency and java..util.Locale parameters.

Something like: public String getExcelCurrencyFormat(Currency currency, Locale locale);

Is anyone aware of such a library?

Upvotes: 4

Views: 4070

Answers (1)

Jamie Love
Jamie Love

Reputation: 5626

Couldn't you just flag the field as being a currency field, and let Excel figure out the right format to use? Or does Excel require you to specify the format to produce the relevant 'type'?

I would have suggested using java.text.NumberFormat.getCurrencyInstance() but there appears to be no way to get the actual format used by the instance from the object itself (unless tostring() returns it).

Off the top of my head I can't think of anything else sorry.

Upvotes: 1

Related Questions