I have written a Java program to read an Excel file cell-by-cell using POI API. The setting of the currency is done explicitly using the MS Excel - "Format Cell" option.
However, is there any way in which I can recognize the currency that has been applied to the cell using POI?
So far, I have tried using getCellStyle().getDataFormat() and it returns a unique number. However, the problem is that it is based on the cell style, and can change with a change in the cell formatting(font, size, etc.).
I tried this:
if(Cell.CELL_TYPE_NUMERIC)
{
System.out.println("Value in Excel cell:: " + cell.getNumericCellValue());
short styleType = cell.getCellStyle().getDataFormat();
System.out.println("style (currency):: " + styleType);
if(styleType == <Some unique number>) //want this unique number
{
System.out.println("Currency applied to this cell:: " + <Currency name>);
}
}
So, either I get the unique number which identifies the currency name or if I get the currency name directly, then that would be the best.