본문 바로가기

Programming/과거포스팅

poi excel geCellValue

public static String getExcelCulumValue(Cell cell) {
    	String value = "";
    	try {
    		switch (cell.getCellType()) {
    			case Cell.CELL_TYPE_FORMULA:
					value = cell.getCellFormula();
					break;
				case Cell.CELL_TYPE_NUMERIC:
					value = "" + (int)cell.getNumericCellValue();
					break;
				case Cell.CELL_TYPE_STRING:
					value = "" + cell.getStringCellValue();
					break;
				case Cell.CELL_TYPE_BLANK:
					value = "";
					break;
				case Cell.CELL_TYPE_ERROR:
					value = "" + cell.getErrorCellValue();
					break;
				default:
    		}
    	} catch(Exception e) {
    		e.printStackTrace();
    		value="";
    	}
    	return value;
    }