Merge pull request #8463 from wugangca/BAEL-3656
BAEL-3656 Read Numeric Strings in Excel Cells as a String with Apache…
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
package com.baeldung.poi.excel;
|
||||
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
import org.apache.poi.ss.usermodel.DataFormatter;
|
||||
import org.apache.poi.ss.usermodel.FormulaEvaluator;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
|
||||
public class ExcelCellFormatter {
|
||||
|
||||
public String getCellStringValue(Cell cell) {
|
||||
DataFormatter formatter = new DataFormatter();
|
||||
return formatter.formatCellValue(cell);
|
||||
}
|
||||
|
||||
public String getCellStringValueWithFormula(Cell cell, Workbook workbook) {
|
||||
DataFormatter formatter = new DataFormatter();
|
||||
FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator();
|
||||
return formatter.formatCellValue(cell, evaluator);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user