Answers for "apache poi add .0 on a number"

0

apache poi add .0 on a number

InputStream inp =getClass().getResourceAsStream("filename.xls"));
Workbook wb = WorkbookFactory.create(inp);
DataFormatter objDefaultFormat = new DataFormatter();
FormulaEvaluator objFormulaEvaluator = new HSSFFormulaEvaluator((HSSFWorkbook) wb);

Sheet sheet= wb.getSheetAt(0);
Iterator<Row> objIterator = sheet.rowIterator();

while(objIterator.hasNext()){

  Row row = objIterator.next();
  Cell cellValue = row.getCell(0);
  objFormulaEvaluator.evaluate(cellValue); // This will evaluate the cell, And any type of cell will return string value
  String cellValueStr = objDefaultFormat.formatCellValue(cellValue,objFormulaEvaluator);

}
Posted by: Guest on August-28-2020

Browse Popular Code Answers by Language