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


Java HSSFCell.CELL_TYPE_ERROR屬性代碼示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: getValue

public Object getValue(int row, String column) throws DataSetException {
    if (logger.isDebugEnabled())
        logger.debug("getValue(row={}, columnName={}) - start", Integer.toString(row), column);

    assertValidRowIndex(row);

    int columnIndex = getColumnIndex(column);
    HSSFCell cell = _sheet.getRow(row + 1).getCell(columnIndex);
    if (cell == null) {
        return null;
    }

    int type = cell.getCellType();
    switch (type) {
    case HSSFCell.CELL_TYPE_NUMERIC:
        HSSFCellStyle style = cell.getCellStyle();
        if (HSSFDateUtil.isCellDateFormatted(cell)) {
            return getDateValue(cell);
        } else if (XlsDataSetWriter.DATE_FORMAT_AS_NUMBER_DBUNIT.equals(style.getDataFormatString())) {
            // The special dbunit date format
            return getDateValueFromJavaNumber(cell);
        } else {
            return getNumericValue(cell);
            }

    case HSSFCell.CELL_TYPE_STRING:
        return cell.getRichStringCellValue().getString();

        case HSSFCell.CELL_TYPE_FORMULA:
        throw new DataTypeException("Formula not supported at row=" +
                row + ", column=" + column);

        case HSSFCell.CELL_TYPE_BLANK:
        return null;

        case HSSFCell.CELL_TYPE_BOOLEAN:
        return cell.getBooleanCellValue() ? Boolean.TRUE : Boolean.FALSE;

        case HSSFCell.CELL_TYPE_ERROR:
        throw new DataTypeException("Error at row=" + row +
                ", column=" + column);

        default:
        throw new DataTypeException("Unsupported type at row=" + row +
                ", column=" + column);
    }
}
 
開發者ID:sapientTest,項目名稱:Sapient,代碼行數:47,代碼來源:XlsTable.java

示例10: getCellValue

/**
 * This is a helper method to retrieve the value of a
 * cell regardles of its type, which will be converted
 * into a String.
 *
 * @param cell
 * @return
 */
private String getCellValue(HSSFCell cell) {
    if (cell == null) {
        return null;
    }

    String result = null;

    int cellType = cell.getCellType();
    switch (cellType) {
    case HSSFCell.CELL_TYPE_BLANK:
        result = "";
        break;
    case HSSFCell.CELL_TYPE_BOOLEAN:
        result = cell.getBooleanCellValue() ?
                 "true" : "false";
        break;
    case HSSFCell.CELL_TYPE_ERROR:
        result = "ERROR: " + cell.getErrorCellValue();
        break;
    case HSSFCell.CELL_TYPE_FORMULA:
        result = cell.getCellFormula();
        break;
    case HSSFCell.CELL_TYPE_NUMERIC:
        HSSFCellStyle cellStyle = cell.getCellStyle();
        short dataFormat = cellStyle.getDataFormat();

        // assumption is made that dataFormat = 15,
        // when cellType is HSSFCell.CELL_TYPE_NUMERIC
        // is equal to a DATE format.
        if (dataFormat == 15) {
            result = cell.getDateCellValue().toString();
        } else {
            result = String.valueOf(
                    cell.getNumericCellValue());
        }

        break;
    case HSSFCell.CELL_TYPE_STRING:
        result = cell.getStringCellValue();
        break;
    default:
        break;
    }

    return result;
}
 
開發者ID:meisamhe,項目名稱:GPLshared,代碼行數:54,代碼來源:excelParser.java

示例11: compareTwoCells

public static boolean compareTwoCells(XSSFCell cell1, XSSFCell cell2) {
    if ((cell1 == null) && (cell2 == null)) {
        return true;
    } else if ((cell1 == null) || (cell2 == null)) {
        return false;
    }

    boolean equalCells = false;
    int type1 = cell1.getCellTypeEnum().getCode();
    int type2 = cell2.getCellTypeEnum().getCode();
    if (type1 == type2) {
        if (cell1.getCellStyle().equals(cell2.getCellStyle())) {
            // Compare cells based on its type
            switch (cell1.getCellTypeEnum().getCode()) {
            case HSSFCell.CELL_TYPE_FORMULA:
                if (cell1.getCellFormula().equals(cell2.getCellFormula())) {
                    equalCells = true;
                }
                break;
            case HSSFCell.CELL_TYPE_NUMERIC:
                if (cell1.getNumericCellValue() == cell2.getNumericCellValue()) {
                    equalCells = true;
                }
                break;
            case HSSFCell.CELL_TYPE_STRING:
                if (cell1.getStringCellValue().equals(cell2.getStringCellValue())) {
                    equalCells = true;
                }
                break;
            case HSSFCell.CELL_TYPE_BLANK:
                if (cell2.getCellType() == HSSFCell.CELL_TYPE_BLANK) {
                    equalCells = true;
                }
                break;
            case HSSFCell.CELL_TYPE_BOOLEAN:
                if (cell1.getBooleanCellValue() == cell2.getBooleanCellValue()) {
                    equalCells = true;
                }
                break;
            case HSSFCell.CELL_TYPE_ERROR:
                if (cell1.getErrorCellValue() == cell2.getErrorCellValue()) {
                    equalCells = true;
                }
                break;
            default:
                if (cell1.getStringCellValue().equals(cell2.getStringCellValue())) {
                    equalCells = true;
                }
                break;
            }
        } else {
            return false;
        }
    } else {
        return false;
    }
    return equalCells;
}
 
開發者ID:Talend,項目名稱:data-prep,代碼行數:58,代碼來源:ExcelComparator.java

示例12: isTextEmpty

protected boolean isTextEmpty( HSSFCell cell )
{
    final String value;
    switch ( cell.getCellType() )
    {
    case HSSFCell.CELL_TYPE_STRING:
        // XXX: enrich
        value = cell.getRichStringCellValue().getString();
        break;
    case HSSFCell.CELL_TYPE_FORMULA:
        switch ( cell.getCachedFormulaResultType() )
        {
        case HSSFCell.CELL_TYPE_STRING:
            HSSFRichTextString str = cell.getRichStringCellValue();
            if ( str == null || str.length() <= 0 )
                return false;

            value = str.toString();
            break;
        case HSSFCell.CELL_TYPE_NUMERIC:
            HSSFCellStyle style = cell.getCellStyle();
            if ( style == null )
            {
                return false;
            }

            value = ( _formatter.formatRawCellContents(
                    cell.getNumericCellValue(), style.getDataFormat(),
                    style.getDataFormatString() ) );
            break;
        case HSSFCell.CELL_TYPE_BOOLEAN:
            value = String.valueOf( cell.getBooleanCellValue() );
            break;
        case HSSFCell.CELL_TYPE_ERROR:
            value = ErrorEval.getText( cell.getErrorCellValue() );
            break;
        default:
            value = ExcelToHtmlUtils.EMPTY;
            break;
        }
        break;
    case HSSFCell.CELL_TYPE_BLANK:
        value = ExcelToHtmlUtils.EMPTY;
        break;
    case HSSFCell.CELL_TYPE_NUMERIC:
        value = _formatter.formatCellValue( cell );
        break;
    case HSSFCell.CELL_TYPE_BOOLEAN:
        value = String.valueOf( cell.getBooleanCellValue() );
        break;
    case HSSFCell.CELL_TYPE_ERROR:
        value = ErrorEval.getText( cell.getErrorCellValue() );
        break;
    default:
        return true;
    }

    return ExcelToHtmlUtils.isEmpty( value );
}
 
開發者ID:rmage,項目名稱:gnvc-ims,代碼行數:59,代碼來源:AbstractExcelConverter.java


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