Apache POI : How to format numeric cell values

前端 未结 4 594
青春惊慌失措
青春惊慌失措 2020-12-19 21:28

I am using Apache POI 3.9 for XLS/XLSX file processing.

In the XLS sheet, there is a column with numeric value like \"3000053406\".

When I read it with POI w

4条回答
  •  半阙折子戏
    2020-12-19 22:33

    Problem can be strictly Java-related, not POI related, too. Since your call returns a double,

    double val = cell.getNumericCellValue();

    You may want to get this

    DecimalFormat df = new DecimalFormat("#"); int fractionalDigits = 2; // say 2 df.setMaximumFractionDigits(fractionalDigits); double val = df.format(val);

提交回复
热议问题