@Override protected void appendValueText(StringBuilder sb) { if (isBoolean()) { sb.append(" .boolVal = "); sb.append(getBooleanValue()); } else { sb.append(" .errCode = "); sb.append(FormulaError.forInt(getErrorValue()).getString()); sb.append(" (").append(HexDump.byteToHex(getErrorValue())).append(")"); } } @Override
case BoolErrRecord.sid: // 布尔类型 BoolErrRecord berec = (BoolErrRecord) record; rowCellList.add(berec.getColumn(), berec.getBooleanValue()); break; case FormulaRecord.sid: // 公式类型
boolRec = new BoolErrRecord(); boolRec.setColumn(col); if (setValue) boolRec.setValue(convertCellValueToBoolean()); boolRec.setXFIndex(styleIndex); boolRec.setRow(row); _record = boolRec; break; errRec = new BoolErrRecord(); errRec.setColumn(col); if (setValue) errRec.setValue(FormulaError.VALUE.getCode()); errRec.setXFIndex(styleIndex); errRec.setRow(row); _record = errRec; break;
@Override public BoolErrRecord clone() { BoolErrRecord rec = new BoolErrRecord(); copyBaseFields(rec); rec._value = _value; rec._isError = _isError; return rec; } }
return ""; case BOOLEAN: return ((BoolErrRecord) _record).getBooleanValue() ? "TRUE" : "FALSE"; case STRING: int sstIndex = ((LabelSSTRecord)_record).getSSTIndex(); return NumberToTextConverter.toText(((NumberRecord)_record).getValue()); case ERROR: return FormulaError.forInt(((BoolErrRecord)_record).getErrorValue()).getString(); case FORMULA:
BoolErrRecord berec = (BoolErrRecord) record; if (berec.isBoolean()) { value = berec.getBooleanValue(); indent = formatListener.getIndent(berec); if (indent > 0) { setValue(berec.getRow(), berec.getColumn(), value);
/** * get the value of the cell as a boolean. For strings, numbers, and errors, we throw an exception. * For blank cells we return a false. */ @Override public boolean getBooleanCellValue() { switch(_cellType) { case BLANK: return false; case BOOLEAN: return (( BoolErrRecord ) _record).getBooleanValue(); case FORMULA: break; default: throw typeMismatch(CellType.BOOLEAN, _cellType, false); } FormulaRecord fr = ((FormulaRecordAggregate)_record).getFormulaRecord(); checkFormulaCachedValueType(CellType.BOOLEAN, fr); return fr.getCachedBooleanValue(); }
case BoolErrRecord.sid: // 单元格为布尔类型 BoolErrRecord berec = (BoolErrRecord) record; thisRow = berec.getRow(); thisColumn = berec.getColumn(); thisStr = berec.getBooleanValue() + ""; rowlist.add(thisColumn, thisStr); break;
/** * get the value of the cell as an error code. For strings, numbers, and booleans, we throw an exception. * For blank cells we return a 0. */ @Override public byte getErrorCellValue() { switch(_cellType) { case ERROR: return (( BoolErrRecord ) _record).getErrorValue(); case FORMULA: FormulaRecord fr = ((FormulaRecordAggregate)_record).getFormulaRecord(); checkFormulaCachedValueType(CellType.ERROR, fr); return (byte) fr.getCachedErrorValue(); default: throw typeMismatch(CellType.ERROR, _cellType, false); } }
/** * set the error value for the cell. See {@link FormulaError} for valid codes. * * @param value error representing the error value * this value can only be 0,7,15,23,29,36 or 42 * see bugzilla bug 16560 for an explanation */ public void setValue(byte value) { setValue(FormulaError.forInt(value)); }
/** * used internally -- given a cell value record, figure out its type */ private static CellType determineType(CellValueRecordInterface cval) { if (cval instanceof FormulaRecordAggregate) { return CellType.FORMULA; } // all others are plain BIFF records Record record = ( Record ) cval; switch (record.getSid()) { case NumberRecord.sid : return CellType.NUMERIC; case BlankRecord.sid : return CellType.BLANK; case LabelSSTRecord.sid : return CellType.STRING; case BoolErrRecord.sid : BoolErrRecord boolErrRecord = ( BoolErrRecord ) record; return boolErrRecord.isBoolean() ? CellType.BOOLEAN : CellType.ERROR; } throw new RuntimeException("Bad cell value rec (" + cval.getClass().getName() + ")"); }
BoolErrRecord berec = (BoolErrRecord) record; curCol = berec.getColumn(); curStr = _str.setTo(""); break;
case BlankRecord.sid: return new BlankRecord(in); case BookBoolRecord.sid: return new BookBoolRecord(in); case BoolErrRecord.sid: return new BoolErrRecord(in); case BottomMarginRecord.sid: return new BottomMarginRecord(in); case BoundSheetRecord.sid: return new BoundSheetRecord(in);
return ""; case CELL_TYPE_BOOLEAN: return ((BoolErrRecord) _record).getBooleanValue() ? "TRUE" : "FALSE"; case CELL_TYPE_STRING: int sstIndex = ((LabelSSTRecord)_record).getSSTIndex(); return NumberToTextConverter.toText(((NumberRecord)_record).getValue()); case CELL_TYPE_ERROR: return HSSFErrorConstants.getText(((BoolErrRecord) _record).getErrorValue()); case CELL_TYPE_FORMULA:
return (( BoolErrRecord ) _record).getBooleanValue(); case STRING: int sstIndex = ((LabelSSTRecord)_record).getSSTIndex();
public Object clone() { BoolErrRecord rec = new BoolErrRecord(); copyBaseFields(rec); rec._value = _value; rec._isError = _isError; return rec; } }
return getBooleanCellValue()?"TRUE":"FALSE"; case ERROR: return ErrorEval.getText((( BoolErrRecord ) _record).getErrorValue()); case FORMULA: return getCellFormula();
/** * 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. */ @SuppressWarnings("fallthrough") public void setCellValue(boolean value) { int row=_record.getRow(); short col=_record.getColumn(); short styleIndex=_record.getXFIndex(); switch (_cellType) { default: setCellType(CellType.BOOLEAN, false, row, col, styleIndex); // fall through case BOOLEAN: (( BoolErrRecord ) _record).setValue(value); break; case FORMULA: ((FormulaRecordAggregate)_record).setCachedBooleanResult(value); break; } }