returning decimal instead of string (POI jar)

后端 未结 3 1548
醉酒成梦
醉酒成梦 2020-12-07 05:46

I need to read xls or xlsx sheet. successfully I read the sheet, but it returning decimal value instead of string (eg: for 3 -- it is returning 3.0). I need to read the cell

3条回答
  •  臣服心动
    2020-12-07 06:04

    use switch and cases like this code :

    switch (cell.getCellType()) { 
                        case STRING: 
                            String c = cell.getStringCellValue();
    
                            break; 
                        case NUMERIC: 
                            int n = (int) cell.getNumericCellValue();
    
                            break; 
                        case BOOLEAN:
                            boolean b = cell.getBooleanCellValue();
    
                        break; 
                        default : 
                            } 
    

提交回复
热议问题