java excel 2003

来源:互联网 发布:vb cmd 切换目录 编辑:程序博客网 时间:2024/06/05 06:43
public static Object getCellData(Cell cell){
  CellType cellType = cell.getType();
  Object data = null;
   if(cellType == CellType.DATE || cellType == CellType.DATE_FORMULA){
    data =  ((DateCell)cell).getDate();
   } else if (cellType == CellType.NUMBER || cellType == CellType.NUMBER_FORMULA){
    data = Double.valueOf(((NumberCell)cell).getValue());
       }else if (cellType == CellType.LABEL || cellType == CellType.STRING_FORMULA){
    data = ((LabelCell)cell).getString();
       } else if (cellType == CellType.BOOLEAN || cellType == CellType.BOOLEAN_FORMULA){
    data = Boolean.valueOf(((BooleanCell)cell).getValue());
   } else if (cellType == CellType.EMPTY || cellType == CellType.ERROR || cellType == CellType.FORMULA_ERROR) {
    data = null;
   }
  
  return data;
 }
原创粉丝点击