package com.mvc.utils;

import org.apache.poi.ss.usermodel.Cell;

public class PoiUtils {

    /**
     * 获取单元格字符串格式内容
     * @param cell
     * @return
     */
    public static String getCellValueAsString(Cell cell) {
        switch (cell.getCellType()) {
            case STRING:
                return cell.getStringCellValue();
            case NUMERIC:
                return String.valueOf(cell.getNumericCellValue());
                /*if (cell.getDateCellValue() != null) {//判断不严谨
                    return cell.getDateCellValue().toString();
                } else {
                    return String.valueOf(cell.getNumericCellValue());
                }*/
            case BOOLEAN:
                return String.valueOf(cell.getBooleanCellValue());
            case FORMULA:
                return cell.getCellFormula();
            case ERROR:
                return "ERROR";
            case BLANK:
            default:
                return "";
        }
    }
}
