乔山办公网我们一直在努力
您的位置:乔山办公网 > excel表格制作 > <em>poi</em>读取excel中为空的单元格的类型是什么麻烦告诉我

<em>poi</em>读取excel中为空的单元格的类型是什么麻烦告诉我

作者:乔山办公网日期:

返回目录:excel表格制作


public static String getStringCellValue(Cell cell) {
if(cell==null){
return null;
}
String value = "";
switch (cell.getCellType()) {
case Cell.CELL_TYPE_STRING:
value = cell.getStringCellValue();
break;
case Cell.CELL_TYPE_NUMERIC:
if (DateUtil.isCellDateFormatted(cell)) {
Date date = cell.getDateCellValue();
if (date != null) {
value = new SimpleDateFormat("yyyy-MM-dd").format(date);
} else {
value = "";
}
} else {
value =
new DecimalFormat("0").format(cell.getNumericCellValue());
}
break;
case Cell.CELL_TYPE_FORMULA: //导入e69da5e6ba90e799bee5baa6362时如果为公式生成的数据则无值
// System.out.println("Formula:" + cell.getStringCellValue());
if (!cell.getStringCellValue().equals("")) {
value = cell.getStringCellValue();
} else {
value = cell.getNumericCellValue() + "";
}
break;
case Cell.CELL_TYPE_BLANK:
break;
case Cell.CELL_TYPE_ERROR:
value = "";
break;
case Cell.CELL_TYPE_BOOLEAN:
value = (cell.getBooleanCellValue() == true ? "Y" : "N");
break;
default:
value = "";
}
return value;
}


1)情景描述:为了实现Excel中Column之间的联动关系,需要把某列单元格的类型置为Text022)初次解决方案中的错误(红色标注):
POI中设置Excel单元格的类型1)情景描述:为了实现Excel中Column之间的联动关系,需要把某列单元格的类型置为Text

1)情景描述:为了实现Excel中Column之间的联动关系,需要把某列单元格的类型置为Text

相关阅读

关键词不能为空
极力推荐

ppt怎么做_excel表格制作_office365_word文档_365办公网