当前位置: 首页>>代码示例>>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;未经允许,请勿转载。