1
私はapache.poiを使用してExcelから数値を読み取りました。apache.poi HSSFCell getNumericCellValue不正確な読み取り
hssfCell.getNumericCellValue()
ただし、結果が間違っているExcelファイルの例です。
セルN14の正しい結果が11115(またはExcelフォーマットを有する11,12)です。しかし、hssfCell.getNumericCellValue()の結果は11.114999999999998です。
これは式のセルなので、dateFormatterを使用でき、結果は11,11です。
HSSFWorkbook wb = new HSSFWorkbook(new ByteArrayInputStream(importFile));
FormulaEvaluator formulaEvaluator = new HSSFFormulaEvaluator(wb);
DataFormatter dataFormatter = new DataFormatter();
formulaEvaluator.evaluate(hssfCell);
dataFormatter.formatCellValue(hssfCell, formulaEvaluator);
Excelは私に11,12を示します。どのようにしてこの価値を得ることができますか?