如何使用Apache POI从Excel获取货币代码?
我正在使用POI来解析Excel文件和reg。 用于检测NumericCellValue
货币的NumericCellValue
。 我在Excel文件中有2个字段,有2种不同的货币(100美元和100欧元),我需要获取他们的货币代码(“USD”,“EUR”)。
case Cell.CELL_TYPE_NUMERIC: { Pattern p = Pattern.compile(currencyFilter); Matcher m = p.matcher(dataFormat); if (m.find()) { BigDecimal aCurrency = currentCell.getNumericCellValue(); //I need to pass my currency code from cell field to money instance Money money = new Money(aCurrency, "USD"); } }
String currencyCode = ""; if (dataFormat.contains("$$")) { currencyCode = "USD"; } else if (dataFormat.contains("$€")) { currencyCode = "EUR"; } moneyCurrency = new Money(bd, currencyCode);