You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by on...@apache.org on 2016/06/13 10:29:38 UTC

svn commit: r1748172 - /poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java

Author: onealj
Date: Mon Jun 13 10:29:38 2016
New Revision: 1748172

URL: http://svn.apache.org/viewvc?rev=1748172&view=rev
Log:
type check error code when setting cell error value on HSSFCell

Modified:
    poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java

Modified: poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java?rev=1748172&r1=1748171&r2=1748172&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java Mon Jun 13 10:29:38 2016
@@ -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/>
      *



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org