monitorjbl / excel-streaming-reader

An easy-to-use implementation of a streaming Excel reader using Apache POI
Apache License 2.0
953 stars 344 forks source link

How to get unformatted cell value #139

Closed StanBertrand closed 3 years ago

StanBertrand commented 6 years ago

Hello !

I'm trying to get the unformatted value of a cell. For example, I have a cell with this value : 1049 and this numericFormat : \€#,##0.00

None of those returns the raw cell content, i.e. 1049 Is it possible to have a getter on rawContents in StreamingCell or a method which return unformatted String value ?

Thanks in advance.

sharan-arumugam commented 6 years ago

Tried FormulaEvaluator?

import org.apache.poi.ss.usermodel.FormulaEvaluator;
import org.apache.poi.xssf.usermodel.XSSFFormulaEvaluator;
FormulaEvaluator evaluator = new XSSFFormulaEvaluator(new XSSFWorkbook());
FormulaEvaluator evaluator = new HSSFFormulaEvaluator(new HSSFWorkbook());

or

FormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator();

Usage: evaluator.evaluateFormulaCell(cell); XSSFFormulaEvaluator.evaluateAllFormulaCells(wb);

Eval - POI Doc XSSFFormulaEvaluator

StanBertrand commented 6 years ago

Hello !

Thanks for your answer, but when I try to use CellValue cellValue = evaluator.evaluate(cell), I get these results :

N.B : my cell type is NUMERIC