]> source.dussan.org Git - poi.git/commitdiff
type check error code when setting cell error value on HSSFCell
authorJaven O'Neal <onealj@apache.org>
Mon, 13 Jun 2016 10:29:38 +0000 (10:29 +0000)
committerJaven O'Neal <onealj@apache.org>
Mon, 13 Jun 2016 10:29:38 +0000 (10:29 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1748172 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/poi/hssf/usermodel/HSSFCell.java

index 6e247014735b499ac84e4cb64097ba1a1bc2859b..1d97422888d4e73974f0a6ff533d1b84bdb0cf9d 100644 (file)
@@ -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.<p/>
      *