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

The following examples show how to use org.apache.poi.ss.usermodel.FormulaError#isValidCode() . 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
/**
 * Converts error codes to text.  Handles non-standard error codes OK.  
 * For debug/test purposes (and for formatting error messages).
 * @return the String representation of the specified Excel error code.
 */
public static String getText(int errorCode) {
    if(FormulaError.isValidCode(errorCode)) {
        return FormulaError.forInt(errorCode).getString();
    }
    // Give a special string, based on ~, to make clear this isn't a standard Excel error
    return "~non~std~err(" + errorCode + ")~";
}
 
Example 3
Source File: ErrPtg.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/** Creates new ErrPtg */

    private ErrPtg(int errorCode) {
        if(!FormulaError.isValidCode(errorCode)) {
            throw new IllegalArgumentException("Invalid error code (" + errorCode + ")");
        }
        field_1_error_code = errorCode;
    }
 
Example 4
Source File: ErrorConstant.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public String getText() {
	if(FormulaError.isValidCode(_errorCode)) {
		return FormulaError.forInt(_errorCode).getString();
	}
	return "unknown error code (" + _errorCode + ")";
}