public static String getCellValue(Cell cell){System.out.println(cell);String value = null;if(cell != null){System.out.println(cell.getCellType());switch (cell.getCellType()){case BLANK:value = "";break;case BOOLEAN:value = String.valueOf(cell.getBooleanCellValue());break;case FORMULA:switch (cell.getCachedFormulaResultType()){case NUMERIC:if(org.apache.poi.ss.usermodel.DateUtil.isCellDateFormatted(cell)){Date date = cell.getDateCellValue();SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");value = sdf.format(date);}else{BigDecimal n = new BigDecimal(cell.getNumericCellValue());DecimalFormat decimalFormat = new DecimalFormat("0");decimalFormat.setMaximumFractionDigits(18);value = decimalFormat.format(n.doubleValue());}break;case STRING:value = String.valueOf(cell.getStringCellValue());if(value != null){value = value.trim();}break;case BOOLEAN:value = String.valueOf(cell.getBooleanCellValue());break;case ERROR: value = "";break;default:value = cell.getRichStringCellValue().getString();break;}break;case NUMERIC:if(org.apache.poi.ss.usermodel.DateUtil.isCellDateFormatted(cell)){Date date = cell.getDateCellValue();SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");value = sdf.format(date);}else{BigDecimal n = new BigDecimal(cell.getNumericCellValue());DecimalFormat decimalFormat = new DecimalFormat("0");decimalFormat.setMaximumFractionDigits(18);value = decimalFormat.format(n.doubleValue());}break;case STRING:value = String.valueOf(cell.getStringCellValue());if(value != null){value = value.trim();}break;default:value = cell.getRichStringCellValue().getString();break;}}return value;}