From: Javen O'Neal Date: Mon, 13 Jun 2016 10:29:38 +0000 (+0000) Subject: type check error code when setting cell error value on HSSFCell X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=ef3564968af1a1dc8ce89187ba32e18645c3a31f;p=poi.git type check error code when setting cell error value on HSSFCell git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1748172 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java b/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java index 6e24701473..1d97422888 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java @@ -771,24 +771,41 @@ public class HSSFCell implements Cell { * 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. */ - @SuppressWarnings("fallthrough") public void setCellErrorValue(byte errorCode) { + FormulaError error = FormulaError.forInt(errorCode); + setCellErrorValue(error); + } + /** + * set a error value for the cell + * + * @param error 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. + */ + @SuppressWarnings("fallthrough") + public void setCellErrorValue(FormulaError error) { int row=_record.getRow(); short col=_record.getColumn(); short styleIndex=_record.getXFIndex(); + byte code = error.getCode(); switch (_cellType) { default: setCellType(CELL_TYPE_ERROR, false, row, col, styleIndex); // fall through case CELL_TYPE_ERROR: - (( BoolErrRecord ) _record).setValue(errorCode); + (( BoolErrRecord ) _record).setValue(code); break; case CELL_TYPE_FORMULA: - ((FormulaRecordAggregate)_record).setCachedErrorResult(errorCode); + ((FormulaRecordAggregate)_record).setCachedErrorResult(code); break; } } + + /** * Chooses a new boolean value for the cell when its type is changing.

*