Пример #1
0
 void setType(int type) {
   switch (type) {
     case CELL_TYPE_NUMERIC:
       {
         _value = new NumericValue();
         break;
       }
     case CELL_TYPE_STRING:
       {
         PlainStringValue sval = new PlainStringValue();
         if (_value != null) {
           // if a cell is not blank then convert the old value to string
           String str = convertCellValueToString();
           sval.setValue(str);
         }
         _value = sval;
         break;
       }
     case CELL_TYPE_FORMULA:
       {
         _value = new NumericFormulaValue();
         break;
       }
     case CELL_TYPE_BLANK:
       {
         _value = new BlankValue();
         break;
       }
     case CELL_TYPE_BOOLEAN:
       {
         BooleanValue bval = new BooleanValue();
         if (_value != null) {
           // if a cell is not blank then convert the old value to string
           boolean val = convertCellValueToBoolean();
           bval.setValue(val);
         }
         _value = bval;
         break;
       }
     case CELL_TYPE_ERROR:
       {
         _value = new ErrorValue();
         break;
       }
     default:
       {
         throw new IllegalArgumentException("Illegal type " + type);
       }
   }
 }
Пример #2
0
 /**
  * Set a boolean value for the cell
  *
  * @param value the boolean value to set this cell to. For formulas we'll set the precalculated
  *     value, for booleans we'll set its value. For other types we will change the cell to a
  *     boolean cell and set its value.
  */
 public void setCellValue(boolean value) {
   ensureTypeOrFormulaType(CELL_TYPE_BOOLEAN);
   if (_value.getType() == CELL_TYPE_FORMULA)
     ((BooleanFormulaValue) _value).setPreEvaluatedValue(value);
   else ((BooleanValue) _value).setValue(value);
 }