Java 使用poi打印十进制值和电话号码

Java 使用poi打印十进制值和电话号码,java,apache-poi,Java,Apache Poi,我在MS Excel中有以下数据表 phone no cost 1231231221 10.45 1234234232 12.67 1234234453 30.00 下面的代码正确地打印了电话号码,但省略了成本的小数点 for (int rowNum = rowStart-1; rowNum < rowEnd+1; rowNum++) { List<String> cellTempList = new ArrayList<String>();

我在MS Excel中有以下数据表

phone no    cost
1231231221  10.45
1234234232  12.67
1234234453  30.00
下面的代码正确地打印了电话号码,但省略了成本的小数点

for (int rowNum = rowStart-1; rowNum < rowEnd+1; rowNum++) {
    List<String> cellTempList = new ArrayList<String>();
    Row rowObj = hssfSheet.getRow(rowNum);
    for (int col = 0; col < columnEnd; col++) {
        Cell cell = rowObj.getCell(col, Row.CREATE_NULL_AS_BLANK);
        if (cell.getCellType()==Cell.CELL_TYPE_NUMERIC) {
            DecimalFormat df = new DecimalFormat("#");
            String cellValue=df.format(cell.getNumericCellValue());

            System.out.println(cellValue);
            cellTempList.add(cellValue.toString());
        } else {
            cellTempList.add(cell.toString()+"");
        }
}
cellDataList.add(cellTempList);
System.out.println(cellDataList);  
for(int-rowNum=rowStart-1;rowNum
请将
十进制格式初始化为

DecimalFormat df = new DecimalFormat("#.##");
我想这会解决你的问题。
干杯。!

请将
十进制格式初始化为

DecimalFormat df = new DecimalFormat("#.##");
我想这会解决你的问题。 干杯。!

So#小数点后给出小数点总数。对于2位小数-
DecimalFormat df=new DecimalFormat(“#.###”);
对于5位小数-
DecimalFormat df=new DecimalFormat(“#.###”
So#小数点后给出小数点总数。对于2位小数-
DecimalFormat=new DecimalFormat(“#.###”)
对于5位小数-
小数格式df=新的小数格式(“#.####””;