本文整理汇总了Java中org.apache.poi.ss.usermodel.Cell.CELL_TYPE_ERROR属性的典型用法代码示例。如果您正苦于以下问题:Java Cell.CELL_TYPE_ERROR属性的具体用法?Java Cell.CELL_TYPE_ERROR怎么用?Java Cell.CELL_TYPE_ERROR使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.poi.ss.usermodel.Cell
的用法示例。
在下文中一共展示了Cell.CELL_TYPE_ERROR属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: intercepterCellValue
public void intercepterCellValue(Cell cell, CellWrapper cellWrapper, String interceptor) throws Exception {
if (cell == null) {
cellWrapper.setValue(null);
} else {
int cellType = cell.getCellType();
switch (cellType) {
case Cell.CELL_TYPE_BLANK:
cellWrapper.setValue(null);
break;
case Cell.CELL_TYPE_BOOLEAN:
cellWrapper.setValue(Boolean.valueOf(cell.getBooleanCellValue()));
break;
case Cell.CELL_TYPE_ERROR:
cellWrapper.setValue(cell.getErrorCellValue());
break;
case Cell.CELL_TYPE_FORMULA:
cellWrapper.setValue(cell.getCellFormula());
break;
case Cell.CELL_TYPE_NUMERIC:
if (DateUtil.isCellDateFormatted(cell)) {
Date date = cell.getDateCellValue();
cellWrapper.setValue(date);
} else {
cellWrapper.setValue(cell.getNumericCellValue());
}
break;
case Cell.CELL_TYPE_STRING:
cellWrapper.setValue(cell.getStringCellValue());
break;
}
}
logger.debug("before interceptor column number[" + cellWrapper.getColumn() + "] cell value[" + cellWrapper.getValue() + "] cell intercepter[" + interceptor + "]");
this.intercepterCellValue(cellWrapper, interceptor);
logger.debug("after interceptor cell value[" + cellWrapper.getValue() + "]");
}
示例2: isMissing
@Override
public boolean isMissing(int columnIndex) {
Cell cell = getCurrentCell(columnIndex);
try {
boolean missing = cell == null || cell.getCellType() == Cell.CELL_TYPE_BLANK
|| cell.getCellType() == Cell.CELL_TYPE_ERROR || "".equals(cell.getStringCellValue().trim());
return missing;
} catch (IllegalStateException e) {
return false;
}
}
示例3: getValue
/** 从表格之中读取数据并进行处理
* @param fieldInfo
* @param cell 当前cell
* @return
* @throws Exception
*/
public static Object getValue(ImportFieldInfo fieldInfo, Cell cell) throws Exception{
int size = fieldInfo.getTypeChain().size();
Class<?> type = fieldInfo.getTypeChain().get(size - 1);
String dateFormat = fieldInfo.getDateFormat();
int cellType = cell.getCellType();
Object obj = null ;
switch (cellType) {
case Cell.CELL_TYPE_BLANK:
return null;
case Cell.CELL_TYPE_BOOLEAN:
obj = cell.getBooleanCellValue();
break;
case Cell.CELL_TYPE_STRING:
obj = cell.getStringCellValue();
break;
case Cell.CELL_TYPE_NUMERIC:
if(DateUtil.isCellDateFormatted(cell)){
obj = DateUtil.getJavaDate(cell.getNumericCellValue());
}else if(Number.class.isAssignableFrom(type) || ClassUtils.isBaseNumberType(type)){
//当pojo字段类型是数字型时以数字形式获取
obj = cell.getNumericCellValue();
}else{
//其他类型都以string获取
obj = DATA_FORMATTER.formatCellValue(cell);
}
break;
case Cell.CELL_TYPE_ERROR:
return null;
}
if(fieldInfo.getImportProcessor() != null){
obj = fieldInfo.getImportProcessor().process(obj);
}
obj = ConvertUtils.convertIfNeccesary(obj, type, dateFormat);
return obj;
}
示例4: getCellValue
/**
* 获取单元格值
*
* @param row 获取的行
* @param column 获取单元格列号
* @return 单元格值
*/
public Object getCellValue(Row row, int column) {
Object val = "";
try {
Cell cell = row.getCell(column);
if (cell != null) {
if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
// val = cell.getNumericCellValue();
// 当excel 中的数据为数值或日期是需要特殊处理
if (HSSFDateUtil.isCellDateFormatted(cell)) {
double d = cell.getNumericCellValue();
Date date = HSSFDateUtil.getJavaDate(d);
SimpleDateFormat dformat = new SimpleDateFormat(
"yyyy-MM-dd");
val = dformat.format(date);
} else {
NumberFormat nf = NumberFormat.getInstance();
nf.setGroupingUsed(false);// true时的格式:1,234,567,890
val = nf.format(cell.getNumericCellValue());// 数值类型的数据为double,所以需要转换一下
}
} else if (cell.getCellType() == Cell.CELL_TYPE_STRING) {
val = cell.getStringCellValue();
} else if (cell.getCellType() == Cell.CELL_TYPE_FORMULA) {
val = cell.getCellFormula();
} else if (cell.getCellType() == Cell.CELL_TYPE_BOOLEAN) {
val = cell.getBooleanCellValue();
} else if (cell.getCellType() == Cell.CELL_TYPE_ERROR) {
val = cell.getErrorCellValue();
}
}
} catch (Exception e) {
return val;
}
return val;
}
示例5: getCellValue
private CellData getCellValue(CellData cellData)
{
//CellData cellData = new CellData();
if(cellData.cell != null)
{
// evaluator.evaluateFormulaCell(cell);
int cellTypeEvaluator = cellData.workBookObject.evaluator.evaluateFormulaCell(cellData.cell);
int cellType = cellTypeEvaluator > -1 ? cellTypeEvaluator : cellData.cell
.getCellType();
switch (cellType)
{
case Cell.CELL_TYPE_BLANK:
// cellData.put("type",HSSFCell.CELL_TYPE_BLANK);
cellData.value = cellData.cell.getStringCellValue();
break;
case Cell.CELL_TYPE_NUMERIC:
// cellData.put("type",HSSFCell.CELL_TYPE_NUMERIC);
cellData.value = Double.toString(cellData.cell.getNumericCellValue());
break;
case Cell.CELL_TYPE_STRING:
// cellData.put("type",HSSFCell.CELL_TYPE_STRING);
cellData.value = cellData.cell.getStringCellValue();
break;
case Cell.CELL_TYPE_ERROR:
cellData.error = FormulaError.forInt(cellData.cell.getErrorCellValue()).name();
cellData.value = "ERROR";
break;
case Cell.CELL_TYPE_FORMULA:
// cellData.put("type", HSSFCell.CELL_TYPE_ERROR);
cellData.value = cellData.cell.getCellFormula();
break;
default:
// cellData.put("type",HSSFCell.CELL_TYPE_STRING);
cellData.value = cellData.cell.getCellStyle().getDataFormatString();
}
// si la celda es pocentaje multiplico por 100
if (cellData.cell.getCellStyle().getDataFormatString().contains("%")
&& cellType == Cell.CELL_TYPE_NUMERIC)
{
Double perceValue = Double.parseDouble(cellData.value) * 100;
cellData.value = perceValue.toString();
}
}
else
{
cellData.value = null;
}
return cellData;
}