当前位置: 首页>>代码示例>>Java>>正文


Java Cell.CELL_TYPE_BOOLEAN属性代码示例

本文整理汇总了Java中org.apache.poi.ss.usermodel.Cell.CELL_TYPE_BOOLEAN属性的典型用法代码示例。如果您正苦于以下问题:Java Cell.CELL_TYPE_BOOLEAN属性的具体用法?Java Cell.CELL_TYPE_BOOLEAN怎么用?Java Cell.CELL_TYPE_BOOLEAN使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.apache.poi.ss.usermodel.Cell的用法示例。


在下文中一共展示了Cell.CELL_TYPE_BOOLEAN属性的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getCellValue

public Object getCellValue(Cell cell){
    Object value = null;
    DecimalFormat df = new DecimalFormat("0");  //格式化number String字符
    DecimalFormat df2 = new DecimalFormat("0.00");  //格式化数字
    switch (cell.getCellType()) {
        case Cell.CELL_TYPE_STRING:
            value = cell.getRichStringCellValue().getString();
            break;
        case Cell.CELL_TYPE_NUMERIC:
            if("General".equals(cell.getCellStyle().getDataFormatString())) {
                value = df.format(cell.getNumericCellValue());
            } else {
                value = df2.format(cell.getNumericCellValue());
            }
            break;
        case Cell.CELL_TYPE_BOOLEAN:
            value = cell.getBooleanCellValue();
            break;
        case Cell.CELL_TYPE_BLANK:
            value = "";
            break;
        default:
            break;
    }
    return value;
}
 
开发者ID:junrui-zhao,项目名称:Educational-Management-System,代码行数:26,代码来源:ClassroomServiceImpl.java

示例2: objectFrom

private Object objectFrom(final HSSFWorkbook workbook, final Cell cell) {
    Object cellValue = null;
    if (cell.getCellType() == Cell.CELL_TYPE_STRING) {
        cellValue = cell.getRichStringCellValue().getString();
    } else if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
        cellValue = getNumericCellValue(cell);
    } else if (cell.getCellType() == Cell.CELL_TYPE_BOOLEAN) {
        cellValue = cell.getBooleanCellValue();
    } else if (cell.getCellType()  == Cell.CELL_TYPE_FORMULA) {
        cellValue = evaluateCellFormula(workbook, cell);
    }
    return cellValue;

}
 
开发者ID:cyber-coders-j2017a,项目名称:modern.core.java.repo,代码行数:14,代码来源:ExcelXlsReaderParameter.java

示例3: getStringValue

private String getStringValue(Cell cell) {
	int vType = getCellType(cell);
	switch (vType) {
	case Cell.CELL_TYPE_STRING:
		return cell.getStringCellValue();
	case Cell.CELL_TYPE_BOOLEAN:
		return String.valueOf(cell.getBooleanCellValue());
	case Cell.CELL_TYPE_NUMERIC:
		double vValue = cell.getNumericCellValue();
		if (doubleIsInt(vValue))
			return String.valueOf((int) vValue);
		return String.valueOf(vValue);
	case Cell.CELL_TYPE_BLANK:
		return "";
	default:
		throw new IllegalArgumentException("Can't get String from type " + vType);
	}
}
 
开发者ID:xinufo,项目名称:teemo,代码行数:18,代码来源:RowExcelImpl.java

示例4: isBlankRow

/**
 * 判断空行
 */
private static boolean isBlankRow(Row row) {
    if (row == null) {
        return true;
    }
    boolean result = true;
    Iterator<Cell> cells = row.cellIterator();
    String value = "";
    while (cells.hasNext()) {
        Cell cell = cells.next();
        int cellType = cell.getCellType();
        switch (cellType) {
            case Cell.CELL_TYPE_NUMERIC:
                value = String.valueOf(cell.getNumericCellValue());
                break;
            case Cell.CELL_TYPE_STRING:
                value = cell.getStringCellValue();
                break;
            case Cell.CELL_TYPE_BOOLEAN:
                value = String.valueOf(cell.getBooleanCellValue());
                break;
            case Cell.CELL_TYPE_FORMULA:
                value = String.valueOf(cell.getCellFormula());
                break;
        }
        if (StringUtils.isNotBlank(value)) {
            result = false;
            break;
        }
    }

    return result;
}
 
开发者ID:goribun,项目名称:excel-rw-annotation,代码行数:35,代码来源:BaseReadUtil.java

示例5: 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() + "]");

}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:36,代码来源:AbstractExcelParser.java

示例6: 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;
}
 
开发者ID:long47964,项目名称:excel-utils,代码行数:45,代码来源:ExcelImportUtil.java

示例7: 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;
}
 
开发者ID:sombie007,项目名称:ExcelHandle,代码行数:41,代码来源:ImportExcel.java

示例8: evaluateCellFormula

private Object evaluateCellFormula(final HSSFWorkbook workbook, final Cell cell) {
    FormulaEvaluator evaluator = workbook.getCreationHelper()
            .createFormulaEvaluator();
    CellValue cellValue = evaluator.evaluate(cell);
    Object result = null;
    if (cellValue.getCellType() == Cell.CELL_TYPE_BOOLEAN) {
        result = cellValue.getBooleanValue();
    } else if (cellValue.getCellType() == Cell.CELL_TYPE_NUMERIC) {
        result = cellValue.getNumberValue();
    } else if (cellValue.getCellType() == Cell.CELL_TYPE_STRING) {
        result = cellValue.getStringValue();
    }
    return result;
}
 
开发者ID:cyber-coders-j2017a,项目名称:modern.core.java.repo,代码行数:14,代码来源:ExcelXlsReaderParameter.java

示例9: getBooleanValue

private boolean getBooleanValue(Cell cell) {
	switch (getCellType(cell)) {
	case Cell.CELL_TYPE_BOOLEAN:
		return cell.getBooleanCellValue();
	case Cell.CELL_TYPE_NUMERIC:
		return Double.compare(cell.getNumericCellValue(), 0) != 0;
	case Cell.CELL_TYPE_STRING:
		return Boolean.valueOf(cell.getStringCellValue());
	default:
		return false;
	}
}
 
开发者ID:xinufo,项目名称:teemo,代码行数:12,代码来源:RowExcelImpl.java

示例10: getValue

@SuppressWarnings("deprecation")
private Object getValue(Cell raw, String fieldType) throws CellParsingException {
	switch (raw.getCellType()) {
	case Cell.CELL_TYPE_BOOLEAN:
		return raw.getBooleanCellValue();

	case Cell.CELL_TYPE_STRING: {
		String s = raw.getStringCellValue();
		String boolString = s.toLowerCase();
		if (boolString.equals("yes"))
			return true;
		if (boolString.equals("no"))
			return false;
		return s;
	}
	case Cell.CELL_TYPE_NUMERIC:
		if (DateUtil.isCellDateFormatted(raw)) {
			Date date = raw.getDateCellValue();
			return LocalDate.of(date.getYear() + 1900, date.getMonth() + 1, date.getDate());
		}
		return (int) raw.getNumericCellValue();

	// formula parsing doesnot work
	// can be done using FormulaEvaluater
	case Cell.CELL_TYPE_FORMULA:
		return true;

	case Cell.CELL_TYPE_BLANK: {

		return getInstance(fieldType);
	}
	}
	return null;
}
 
开发者ID:NeebalLearningPvtLtd,项目名称:Excel-to-POJO,代码行数:34,代码来源:RowParser.java

示例11: getBoolean

public static Boolean getBoolean(Cell cell) {
    if (isNullCell(cell)) {
        return null;
    }
    if (Cell.CELL_TYPE_BOOLEAN == cell.getCellType()) {
        return cell.getBooleanCellValue();
    }
    if (Cell.CELL_TYPE_STRING == cell.getCellType()) {
        String value = cell.getStringCellValue();
        return "1".equals(value) || "是".equals(value);
    }
    throw new RuntimeException("can not convertWithConstructor cell value to Boolean!");
}
 
开发者ID:dengxiangjun,项目名称:OfficeAutomation,代码行数:13,代码来源:CellConvert.java

示例12: isMatchingCellType

@Override
public boolean isMatchingCellType(StreamingCell cell) {
    return cell.getCellType() == Cell.CELL_TYPE_BOOLEAN;
}
 
开发者ID:kenshoo,项目名称:file-format-streaming-converter,代码行数:4,代码来源:BooleanCellDataHandler.java


注:本文中的org.apache.poi.ss.usermodel.Cell.CELL_TYPE_BOOLEAN属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。