Java Code Examples for org.apache.poi.ss.usermodel.FormulaError#forInt()

The following examples show how to use org.apache.poi.ss.usermodel.FormulaError#forInt() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ErrorConstant.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
public static ErrorConstant valueOf(int errorCode) {
    if (FormulaError.isValidCode(errorCode)) {
   		switch (FormulaError.forInt(errorCode)) {
   			case NULL:  return NULL;
   			case DIV0:  return DIV_0;
   			case VALUE: return VALUE;
   			case REF:   return REF;
   			case NAME:  return NAME;
   			case NUM:   return NUM;
   			case NA:	return NA;
   			default:    break;
   		}
    }
	logger.log( POILogger.WARN, "Warning - unexpected error code (" + errorCode + ")");
	return new ErrorConstant(errorCode);
}
 
Example 2
Source File: ErrorEval.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Translates an Excel internal error code into the corresponding POI ErrorEval instance
 * @param errorCode An error code listed in {@link FormulaError}
 * @throws RuntimeException If an unknown errorCode is specified
 */
public static ErrorEval valueOf(int errorCode) {
    FormulaError error = FormulaError.forInt(errorCode);
    ErrorEval eval = evals.get(error);
    if (eval != null) {
        return eval;
    } else {
        throw new RuntimeException("Unhandled error type for code " + errorCode);
    }
}
 
Example 3
Source File: ErrPtg.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public static ErrPtg valueOf(int code) {
    switch(FormulaError.forInt(code)) {
        case DIV0: return DIV_ZERO;
        case NA: return N_A;
        case NAME: return NAME_INVALID;
        case NULL: return NULL_INTERSECTION;
        case NUM: return NUM_ERROR;
        case REF: return REF_INVALID;
        case VALUE: return VALUE_INVALID;
        default:
            throw new RuntimeException("Unexpected error code (" + code + ")");
    }
}
 
Example 4
Source File: Errortype.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
private int translateErrorCodeToErrorTypeValue(int errorCode) {
	switch (FormulaError.forInt(errorCode)) {
		case NULL:  return 1;
		case DIV0:  return 2;
		case VALUE: return 3;
		case REF:   return 4;
		case NAME:  return 5;
		case NUM:   return 6;
		case NA:    return 7;
		default:
	        throw new IllegalArgumentException("Invalid error code (" + errorCode + ")");
	}
}
 
Example 5
Source File: HSSFCell.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * set a error value for the cell
 *
 * @param errorCode the error value to set this cell to.  For formulas we'll set the
 *        precalculated value , for errors we'll set
 *        its value. For other types we will change the cell to an error
 *        cell and set its value.
 *        For error code byte, see {@link FormulaError}.
 * @deprecated 3.15 beta 2. Use {@link #setCellErrorValue(FormulaError)} instead.
 */
public void setCellErrorValue(byte errorCode) {
    FormulaError error = FormulaError.forInt(errorCode);
    setCellErrorValue(error);
}