當前位置: 首頁>>代碼示例>>Java>>正文


Java HSSFCell.CELL_TYPE_BOOLEAN屬性代碼示例

本文整理匯總了Java中org.apache.poi.hssf.usermodel.HSSFCell.CELL_TYPE_BOOLEAN屬性的典型用法代碼示例。如果您正苦於以下問題:Java HSSFCell.CELL_TYPE_BOOLEAN屬性的具體用法?Java HSSFCell.CELL_TYPE_BOOLEAN怎麽用?Java HSSFCell.CELL_TYPE_BOOLEAN使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在org.apache.poi.hssf.usermodel.HSSFCell的用法示例。


在下文中一共展示了HSSFCell.CELL_TYPE_BOOLEAN屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getCellValue

private String getCellValue(HSSFCell cell){
	if(cell == null) return "";
	
	switch (cell.getCellType()) {
	case HSSFCell.CELL_TYPE_STRING: return cell.getStringCellValue();
	case HSSFCell.CELL_TYPE_BOOLEAN : return Boolean.toString(cell.getBooleanCellValue());
	case HSSFCell.CELL_TYPE_NUMERIC : 
		if(HSSFDateUtil.isCellDateFormatted(cell))
			return DateUtils.formatDateTime("yyyyMMdd", HSSFDateUtil.getJavaDate(cell.getNumericCellValue()));
		else
			return new BigDecimal(cell.getNumericCellValue()).toPlainString();
	case HSSFCell.CELL_TYPE_FORMULA : return "";
	case HSSFCell.CELL_TYPE_BLANK : return "";
	default:return "";
	}
}
 
開發者ID:ken8271,項目名稱:parrot,代碼行數:16,代碼來源:XlsParser.java

示例2: getCellValue

private Object getCellValue(Cell cellObject) {
	Object cellValue = null;
	if (cellObject != null) {
		switch (cellObject.getCellType()) {
		case HSSFCell.CELL_TYPE_BOOLEAN:
			cellValue = cellObject.getBooleanCellValue();
			break;

		case HSSFCell.CELL_TYPE_STRING:
			cellValue = cellObject.getStringCellValue();
			break;
		case HSSFCell.CELL_TYPE_NUMERIC:
			if (DateUtil.isCellDateFormatted(cellObject)) {
				cellValue = cellObject.getDateCellValue();
			} else {
				cellValue = cellObject.getNumericCellValue();
			}
			break;

		default:
			break;
		}
	}

	return cellValue;
}
 
開發者ID:sigmah-dev,項目名稱:sigmah,代碼行數:26,代碼來源:ExcelImporter.java

示例3: getValueFromCell

/**
 * <b>描述:</b> 從單元格中獲取到的數據
 * @param cell	單元格對應的HSSFCell對象
 * @return Object 從單元格中獲取到的數據
 */
private Object getValueFromCell(HSSFCell cell){
	if(cell==null)return "";
	switch(cell.getCellType()){
		case HSSFCell.CELL_TYPE_BOOLEAN:
			return cell.getBooleanCellValue();
		case HSSFCell.CELL_TYPE_NUMERIC:
			return cell.getNumericCellValue();
		case HSSFCell.CELL_TYPE_FORMULA:
			return cell.getCellFormula();
		case HSSFCell.CELL_TYPE_STRING:
			return cell.getRichStringCellValue().toString();
		default:
			return cell.getRichStringCellValue().toString();
	}
	
}
 
開發者ID:uiguard,項目名稱:uiguard,代碼行數:21,代碼來源:DataProviderHelper.java

示例4: getCellData

/**
 * Get cell value based on the excel column data type
 *
 * @param myCell
 * @return
 */
private static String getCellData(HSSFCell myCell) throws Exception {
    String cellData = "";
    if (myCell == null) {
        cellData += CVS_SEPERATOR_CHAR;;
    } else {
        switch (myCell.getCellType()) {
            case HSSFCell.CELL_TYPE_STRING:
            case HSSFCell.CELL_TYPE_BOOLEAN:
                cellData += myCell.getRichStringCellValue() + CVS_SEPERATOR_CHAR;
                break;
            case HSSFCell.CELL_TYPE_NUMERIC:
                cellData += getNumericValue(myCell);
                break;
            case HSSFCell.CELL_TYPE_FORMULA:
                cellData += getFormulaValue(myCell);
            default:
                cellData += CVS_SEPERATOR_CHAR;
                ;
        }
    }
    return cellData;
}
 
開發者ID:rmage,項目名稱:gnvc-ims,代碼行數:28,代碼來源:ReportModel.java

示例5: getCellStringValue

public static String getCellStringValue(HSSFCell cell) {
	String cellValue = "";
	switch (cell.getCellType()) {
	case HSSFCell.CELL_TYPE_STRING:
		cellValue = cell.getStringCellValue();
		if (cellValue.trim().equals("") || cellValue.trim().length() <= 0) {
			cellValue = " ";
		}
		break;
	case HSSFCell.CELL_TYPE_NUMERIC:
		// cellValue = String.valueOf(cell.getNumericCellValue());
		DecimalFormat formatter = new DecimalFormat("######");
		cellValue = formatter.format(cell.getNumericCellValue());
		break;
	case HSSFCell.CELL_TYPE_FORMULA:
		cell.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
		cellValue = String.valueOf(cell.getNumericCellValue());
		break;
	case HSSFCell.CELL_TYPE_BLANK:
		cellValue = " ";
		break;
	case HSSFCell.CELL_TYPE_BOOLEAN:
		break;
	case HSSFCell.CELL_TYPE_ERROR:
		break;
	default:
		break;
	}
	return cellValue;
}
 
開發者ID:wkeyuan,項目名稱:DWSurvey,代碼行數:30,代碼來源:ReadExcelUtil.java

示例6: copyCell

/**
 * @param oldCell
 * @param newCell
 * @param styleMap
 */
public static void copyCell(HSSFCell oldCell, HSSFCell newCell, Map<Integer, HSSFCellStyle> styleMap) {
    if (styleMap != null) {
        if (oldCell.getSheet().getWorkbook() == newCell.getSheet().getWorkbook()) {
            newCell.setCellStyle(oldCell.getCellStyle());
        } else {
            int stHashCode = oldCell.getCellStyle().hashCode();
            HSSFCellStyle newCellStyle = styleMap.get(stHashCode);
            if (newCellStyle == null) {
                newCellStyle = newCell.getSheet().getWorkbook().createCellStyle();
                newCellStyle.cloneStyleFrom(oldCell.getCellStyle());
                styleMap.put(stHashCode, newCellStyle);
            }
            newCell.setCellStyle(newCellStyle);
        }
    }
    switch (oldCell.getCellType()) {
        case HSSFCell.CELL_TYPE_STRING:
            newCell.setCellValue(oldCell.getStringCellValue());
            break;
        case HSSFCell.CELL_TYPE_NUMERIC:
            newCell.setCellValue(oldCell.getNumericCellValue());
            break;
        case HSSFCell.CELL_TYPE_BLANK:
            newCell.setCellType(HSSFCell.CELL_TYPE_BLANK);
            break;
        case HSSFCell.CELL_TYPE_BOOLEAN:
            newCell.setCellValue(oldCell.getBooleanCellValue());
            break;
        case HSSFCell.CELL_TYPE_ERROR:
            newCell.setCellErrorValue(oldCell.getErrorCellValue());
            break;
        case HSSFCell.CELL_TYPE_FORMULA:
            newCell.setCellFormula(oldCell.getCellFormula());
            break;
        default:
            break;
    }

}
 
開發者ID:likelet,項目名稱:DAtools,代碼行數:44,代碼來源:Util.java

示例7: getCellData

@SuppressWarnings("null")
public static String getCellData(String reqValue, HSSFSheet reqSheet,
		int rowIndex, HashMap<String, Object> inputHashTable)
		throws IOException {
	HSSFCell reqCell = null;
	Object actualvalue = null;
	String req = "";
	DataFormatter fmt = new DataFormatter();
	if (inputHashTable.isEmpty() == true) {
		inputHashTable = getValueFromHashMap(reqSheet);
	}
	HSSFRow rowActual = reqSheet.getRow(rowIndex);
	if (inputHashTable.get(reqValue) == null) {
		report.setStrMessage("Column " + reqValue
				+ " not Found. Please Check input Sheet");
		pauseFun("Column " + reqValue
				+ " not Found. Please Check input Sheet");
	} else {
		actualvalue = inputHashTable.get(reqValue);// rowHeader.getCell(colIndex).toString();
		if (actualvalue != null) {
			int colIndex = Integer.parseInt(actualvalue.toString());
			reqCell = rowActual.getCell(colIndex);
			if (reqCell == null) {
				System.out.println(reqValue + " is Null");
			} else {
				int type = reqCell.getCellType();
				switch (type) {
				case HSSFCell.CELL_TYPE_BLANK:
					req = "";
					break;
				case HSSFCell.CELL_TYPE_NUMERIC:
					req = fmt.formatCellValue(reqCell);
					break;
				case HSSFCell.CELL_TYPE_STRING:
					req = reqCell.getStringCellValue();
					break;
				case HSSFCell.CELL_TYPE_BOOLEAN:
					req = Boolean.toString(reqCell.getBooleanCellValue());
					break;
				case HSSFCell.CELL_TYPE_ERROR:
					req = "error";
					break;
				case HSSFCell.CELL_TYPE_FORMULA:
					req = reqCell.getCellFormula();
					break;
				}
			}
		}

		else {
			req = reqCell.getStringCellValue();
			System.out.println("null");
		}
	}
	return req;
}
 
開發者ID:MastekLtd,項目名稱:SwiftLite,代碼行數:56,代碼來源:TransactionMapping.java

示例8: getCellString

private Object getCellString(HSSFCell cell) {
	// TODO Auto-generated method stub
	Object result = null;
	if (cell != null) {
		// 單元格類型:Numeric:0,String:1,Formula:2,Blank:3,Boolean:4,Error:5
		int cellType = cell.getCellType();
		switch (cellType) {
		case HSSFCell.CELL_TYPE_STRING:
			result = cell.getRichStringCellValue().getString();
			break;
		case HSSFCell.CELL_TYPE_NUMERIC:
			result = cell.getNumericCellValue();
			break;
		case HSSFCell.CELL_TYPE_FORMULA:
			result = cell.getNumericCellValue();
			break;
		case HSSFCell.CELL_TYPE_BOOLEAN:
			result = cell.getBooleanCellValue();
			break;
		case HSSFCell.CELL_TYPE_BLANK:
			result = null;
			break;
		case HSSFCell.CELL_TYPE_ERROR:
			result = null;
			break;
		default:
			System.out.println("枚舉了所有類型");
			break;
		}
	}
	return result;
}
 
開發者ID:Wccczy,項目名稱:Student_Register,代碼行數:32,代碼來源:ExcelSheetParser.java

示例9: getHSSFCellValue

public String getHSSFCellValue(HSSFCell cell) {
	String value = "";
	switch (cell.getCellType()) {
	case HSSFCell.CELL_TYPE_NUMERIC:
		if (HSSFDateUtil.isCellDateFormatted(cell)) {
			value = HSSFDateUtil.getJavaDate(cell.getNumericCellValue())
					.toString();
		} else {
			value = String.valueOf(cell.getNumericCellValue());
		}
		break;
	case HSSFCell.CELL_TYPE_STRING:
		value = cell.getRichStringCellValue().toString();
		break;
	case HSSFCell.CELL_TYPE_FORMULA:
		value = String.valueOf(cell.getNumericCellValue());
		if (value.equals("NaN")) {
			value = cell.getRichStringCellValue().toString();
		}
		break;
	case HSSFCell.CELL_TYPE_BOOLEAN:
		value = "" + cell.getBooleanCellValue();
		break;
	case HSSFCell.CELL_TYPE_BLANK:
		value = "";
		break;
	case HSSFCell.CELL_TYPE_ERROR:
		value = "";
		break;
	default:
		value = cell.getRichStringCellValue().toString();
	}
	return value;
}
 
開發者ID:HuaweiSNC,項目名稱:OpsDev,代碼行數:34,代碼來源:Alarm.java

示例10: getCellValue

public static String getCellValue(HSSFCell cell) {
	String value = "";
	if (cell==null) 
		return "";
	switch (cell.getCellType()) {
	case HSSFCell.CELL_TYPE_STRING:
		value = cell.getStringCellValue();
		break;
	case HSSFCell.CELL_TYPE_NUMERIC:
		double tp=Double.valueOf(cell.getNumericCellValue());
		value=String.format("%.2f", tp);
		break;
	case HSSFCell.CELL_TYPE_FORMULA:
		value = cell.getCellFormula();
		break;
	case HSSFCell.CELL_TYPE_ERROR:
		value = String.valueOf(cell.getErrorCellValue());
		break;
	case HSSFCell.CELL_TYPE_BOOLEAN:
		value = String.valueOf(cell.getBooleanCellValue());
		break;
	case HSSFCell.CELL_TYPE_BLANK:
		value = "";
		break;
	default:
		break;
	}
	return value;
}
 
開發者ID:zhanggh,項目名稱:mtools,代碼行數:29,代碼來源:ExcelTool.java

示例11: getCellValue2

public static String getCellValue2(HSSFCell cell) {
	String value = "";
	if (cell==null) 
		return "";
	switch (cell.getCellType()) {
	case HSSFCell.CELL_TYPE_STRING:
		value = cell.getStringCellValue();
		break;
	case HSSFCell.CELL_TYPE_NUMERIC:
		double tp=Double.valueOf(cell.getNumericCellValue());
		value=String.format("%.0f", tp);
		break;
	case HSSFCell.CELL_TYPE_FORMULA:
		value = cell.getCellFormula();
		break;
	case HSSFCell.CELL_TYPE_ERROR:
		value = String.valueOf(cell.getErrorCellValue());
		break;
	case HSSFCell.CELL_TYPE_BOOLEAN:
		value = String.valueOf(cell.getBooleanCellValue());
		break;
	case HSSFCell.CELL_TYPE_BLANK:
		value = "";
		break;
	default:
		break;
	}
	return value;
}
 
開發者ID:zhanggh,項目名稱:mtools,代碼行數:29,代碼來源:ExcelTool.java

示例12: getStringCellValue

/**
 * 獲取單元格數據內容為字符串類型的數據
 * 
 * @param cell
 *            Excel單元格
 * @return String 單元格數據內容
 */
private static String getStringCellValue(HSSFCell cell) {
	String strCell = "";
	switch (cell.getCellType()) {
	case HSSFCell.CELL_TYPE_STRING:
		strCell = cell.getStringCellValue();
		break;
	case HSSFCell.CELL_TYPE_NUMERIC:
		strCell = String.valueOf(cell.getNumericCellValue());
		break;
	case HSSFCell.CELL_TYPE_BOOLEAN:
		strCell = String.valueOf(cell.getBooleanCellValue());
		break;
	case HSSFCell.CELL_TYPE_BLANK:
		strCell = "";
		break;
	default:
		strCell = "";
		break;
	}
	if (strCell.equals("") || strCell == null) {
		return "";
	}
	if (cell == null) {
		return "";
	}
	return strCell;
}
 
開發者ID:findix,項目名稱:GPMS,代碼行數:34,代碼來源:ExcelPOI.java

示例13: extractRowData

private String[] extractRowData(Row row) {
    if (row == null || row.getLastCellNum() == -1) {
        return null;
    }
    String[] data = new String[row.getLastCellNum()];
    Cell cell;
    for (int i = 0; i < data.length; i++) {
        cell = row.getCell(i);
        if (cell == null) {
            data[i] = "";
            continue;
        }
        switch (cell.getCellType()) {
            case HSSFCell.CELL_TYPE_STRING:
                data[i] = cell.getRichStringCellValue().getString();
                break;
            case HSSFCell.CELL_TYPE_BLANK:
                data[i] = "";
                break;
            case HSSFCell.CELL_TYPE_BOOLEAN:
                data[i] = String.valueOf(cell.getBooleanCellValue());
                break;
            case HSSFCell.CELL_TYPE_FORMULA:
                data[i] = "{formula}";
                break;
            case HSSFCell.CELL_TYPE_NUMERIC:
                data[i] = processNumericValue(cell.getNumericCellValue());
                break;
        }
    }
    return data;
}
 
開發者ID:wso2,項目名稱:carbon-data,代碼行數:32,代碼來源:ExcelQuery.java

示例14: getFormulaValue

/**
 * Get the formula value from a cell
 *
 * @param myCell
 * @return
 * @throws Exception
 */
private static String getFormulaValue(HSSFCell myCell) throws Exception {
    String cellData = "";
    if (myCell.getCachedFormulaResultType() == HSSFCell.CELL_TYPE_STRING || myCell.getCellType() == HSSFCell.CELL_TYPE_BOOLEAN) {
        cellData += myCell.getRichStringCellValue() + CVS_SEPERATOR_CHAR;
    } else if (myCell.getCachedFormulaResultType() == HSSFCell.CELL_TYPE_NUMERIC) {
        cellData += getNumericValue(myCell) + CVS_SEPERATOR_CHAR;
    }
    return cellData;
}
 
開發者ID:rmage,項目名稱:gnvc-ims,代碼行數:16,代碼來源:ReportModel.java

示例15: copyCell

public static void copyCell(HSSFCell oldCell, HSSFCell newCell, Map<Integer, HSSFCellStyle> styleMap) {  
    if(styleMap != null) {  
        if(oldCell.getSheet().getWorkbook() == newCell.getSheet().getWorkbook()){  
            newCell.setCellStyle(oldCell.getCellStyle());  
        } else{  
            int stHashCode = oldCell.getCellStyle().hashCode();  
            HSSFCellStyle newCellStyle = styleMap.get(stHashCode);  
            if(newCellStyle == null){  
                newCellStyle = newCell.getSheet().getWorkbook().createCellStyle();  
                newCellStyle.cloneStyleFrom(oldCell.getCellStyle());  
                styleMap.put(stHashCode, newCellStyle);  
            }  
            newCell.setCellStyle(newCellStyle);  
        }  
    }  
    switch(oldCell.getCellType()) {  
        case HSSFCell.CELL_TYPE_STRING:  
            newCell.setCellValue(oldCell.getStringCellValue());  
            break;  
        case HSSFCell.CELL_TYPE_NUMERIC:  
            newCell.setCellValue(oldCell.getNumericCellValue());  
            break;  
        case HSSFCell.CELL_TYPE_BLANK:  
            newCell.setCellType(HSSFCell.CELL_TYPE_BLANK);  
            break;  
        case HSSFCell.CELL_TYPE_BOOLEAN:  
            newCell.setCellValue(oldCell.getBooleanCellValue());  
            break;  
        case HSSFCell.CELL_TYPE_ERROR:  
            newCell.setCellErrorValue(oldCell.getErrorCellValue());  
            break;  
        case HSSFCell.CELL_TYPE_FORMULA:  
            newCell.setCellFormula(oldCell.getCellFormula());  
            break;  
        default:  
            break;  
    }  
      
}
 
開發者ID:rmage,項目名稱:gnvc-ims,代碼行數:39,代碼來源:MultiPageReportModel.java


注:本文中的org.apache.poi.hssf.usermodel.HSSFCell.CELL_TYPE_BOOLEAN屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。