POI中HSSFCELL表格类型转换

原理就不用多说了,直接上方法

private String getCellValue(HSSFCell hssfCell) {
        
   String cellValue = "";

   if (hssfCell == null) {
		return null;
   }
        
   DecimalFormat decimalFormat = new DecimalFormat("#");
   //根据自己的情况进行类型添加
   switch (hssfCell.getCellType()) {
	 case HSSFCell.CELL_TYPE_NUMERIC:               
       cellValue=decimalFormat.format(hssfCell.getNumericCellValue()).toString().trim();
				break;
	 case HSSFCell.CELL_TYPE_STRING:
		cellValue = hssfCell.getStringCellValue().toString().trim();
			break;
		}

		return cellValue;

	}

 

你可能感兴趣的:(springboot)