poi导入excel表格时遇到公式的单元格导入失败的解决方法

public static String getCellValueAsString(HSSFRow row,int column,boolean isDate){
	HSSFCell cell = row.getCell(column, HSSFRow.CREATE_NULL_AS_BLANK);
	int type = cell.getCellType();
	String str = "";
	if(type == HSSFCell.CELL_TYPE_FORMULA){
		 try {
			 str = String.valueOf(cell.getNumericCellValue());    
		    } catch (IllegalStateException e) {
		    	str = String.valueOf(cell.getRichStringCellValue());
		    }
	}
	str = str == null ? "" : str;
	return str;
}

你可能感兴趣的:(poi导入excel表格时遇到公式的单元格导入失败的解决方法)