Shah
Shah

Reputation: 5018

POI Currency issues

I am trying to generate excel file using various currencies.

This works fine public HSSFCellStyle moneyStyle;

SSFDataFormat format = excelUtils.wb.createDataFormat();
        moneyStyle = excelUtils.wb.createCellStyle();
        moneyStyle.setDataFormat(format.getFormat("$##,###,###,###,##0"));

However if i change the $ to INR (Indian Rupees) it will not work.

public HSSFCellStyle moneyStyle;
SSFDataFormat format = excelUtils.wb.createDataFormat();
        moneyStyle = excelUtils.wb.createCellStyle();
        moneyStyle.setDataFormat(format.getFormat("INR##,###,###,###,##0"));

In the Excel spreadsheet the INR does not show up but '$' or 'A$' works just fine

Any help will be appreciated.

Upvotes: 1

Views: 425

Answers (1)

James Montagne
James Montagne

Reputation: 78630

That is not a valid excel format. If you want to do this you need to either surround INR in double quotes or \ before each character.

The format you are using would not work if set directly in Excel either.

"\\I\\N\\R##,###,###,###,##0"

"\"INR\"##,###,###,###,##0"

I believe either should work, though I have only tested directly in Excel.

Upvotes: 4

Related Questions