我正在使用POI来解析Excel文件和reg。用于检测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");
}
}
答案 0 :(得分:1)
String currencyCode = "";
if (dataFormat.contains("$$")) {
currencyCode = "USD";
}
else if (dataFormat.contains("$€")) {
currencyCode = "EUR";
}
moneyCurrency = new Money(bd, currencyCode);