@Override protected void serializeValue(LittleEndianOutput out) { out.writeDouble(getValue()); }
double value; if (cell instanceof NumberRecord) { value = ((NumberRecord) cell).getValue(); } else if (cell instanceof FormulaRecord) { value = ((FormulaRecord) cell).getValue();
/** * Get the value of the cell as a number. * For strings we throw an exception. * For blank cells we return a 0. * See {@link HSSFDataFormatter} for turning this * number into a string similar to that which * Excel would render this number as. */ public double getNumericCellValue() { switch(_cellType) { case BLANK: return 0.0; case NUMERIC: return ((NumberRecord)_record).getValue(); default: throw typeMismatch(CellType.NUMERIC, _cellType, false); case FORMULA: break; } FormulaRecord fr = ((FormulaRecordAggregate)_record).getFormulaRecord(); checkFormulaCachedValueType(CellType.NUMERIC, fr); return fr.getValue(); }
return Boolean.valueOf(text).booleanValue(); case NUMERIC: return ((NumberRecord)_record).getValue() != 0;
handleNumericCell(text, nr.getValue()); break; case OldFormulaRecord.biff2_sid:
NumberRecord numrec = (NumberRecord) record; curCol = numrec.getColumn(); curNum = numrec.getValue(); break; case RKRecord.sid:
return _book.getWorkbook().getSSTString(sstIndex).getString(); case NUMERIC: return NumberToTextConverter.toText(((NumberRecord)_record).getValue()); case ERROR: return FormulaError.forInt(((BoolErrRecord)_record).getErrorValue()).getString();
@Override public String formatNumberDateCell(CellValueRecordInterface cell) { String formatString = this.getFormatString(cell); if (formatString != null && ! formatString.equals("General")) { return super.formatNumberDateCell(cell); } double value; if(cell instanceof NumberRecord) { value = ((NumberRecord)cell).getValue(); } else { if(!(cell instanceof FormulaRecord)) { throw new IllegalArgumentException("Unsupported CellValue Record passed in " + cell); } value = ((FormulaRecord)cell).getValue(); } return generalFormat.format(value); } }
@Override protected void serializeValue(LittleEndianOutput out) { out.writeDouble(getValue()); }
@Override protected void serializeValue(LittleEndianOutput out) { out.writeDouble(getValue()); }
@Override protected void serializeValue(LittleEndianOutput out) { out.writeDouble(getValue()); }
@Override public String formatNumberDateCell(CellValueRecordInterface cell) { String formatString = this.getFormatString(cell); if (formatString != null && ! formatString.equals("General")) { return super.formatNumberDateCell(cell); } double value; if(cell instanceof NumberRecord) { value = ((NumberRecord)cell).getValue(); } else { if(!(cell instanceof FormulaRecord)) { throw new IllegalArgumentException("Unsupported CellValue Record passed in " + cell); } value = ((FormulaRecord)cell).getValue(); } return generalFormat.format(value); } }
@Override public String formatNumberDateCell(CellValueRecordInterface cell) { String formatString = this.getFormatString(cell); if (formatString != null && ! formatString.equals("General")) { return super.formatNumberDateCell(cell); } double value; if(cell instanceof NumberRecord) { value = ((NumberRecord)cell).getValue(); } else { if(!(cell instanceof FormulaRecord)) { throw new IllegalArgumentException("Unsupported CellValue Record passed in " + cell); } value = ((FormulaRecord)cell).getValue(); } return generalFormat.format(value); } }
/** * Formats the given numeric of date Cell's contents as a String, in as * close as we can to the way that Excel would do so. Uses the various * format records to manage this. * * TODO - move this to a central class in such a way that hssf.usermodel can * make use of it too */ public String formatNumberDateCell(CellValueRecordInterface cell) { double value; if (cell instanceof NumberRecord) { value = ((NumberRecord) cell).getValue(); } else if (cell instanceof FormulaRecord) { value = ((FormulaRecord) cell).getValue(); } else { throw new IllegalArgumentException("Unsupported CellValue Record passed in " + cell); } // Get the built in format, if there is one int formatIndex = getFormatIndex(cell); String formatString = getFormatString(cell); if (formatString == null) { return _defaultFormat.format(value); } // Format, using the nice new // HSSFDataFormatter to do the work for us return _formatter.formatRawCellContents(value, formatIndex, formatString); }
/** * Formats the given numeric of date Cell's contents as a String, in as * close as we can to the way that Excel would do so. Uses the various * format records to manage this. * * TODO - move this to a central class in such a way that hssf.usermodel can * make use of it too */ public String formatNumberDateCell(CellValueRecordInterface cell) { double value; if (cell instanceof NumberRecord) { value = ((NumberRecord) cell).getValue(); } else if (cell instanceof FormulaRecord) { value = ((FormulaRecord) cell).getValue(); } else { throw new IllegalArgumentException("Unsupported CellValue Record passed in " + cell); } // Get the built in format, if there is one int formatIndex = getFormatIndex(cell); String formatString = getFormatString(cell); if (formatString == null) { return _defaultFormat.format(value); } // Format, using the nice new // HSSFDataFormatter to do the work for us return _formatter.formatRawCellContents(value, formatIndex, formatString); }
/** * Get the value of the cell as a number. * For strings we throw an exception. * For blank cells we return a 0. * See {@link HSSFDataFormatter} for turning this * number into a string similar to that which * Excel would render this number as. */ public double getNumericCellValue() { switch(_cellType) { case CELL_TYPE_BLANK: return 0.0; case CELL_TYPE_NUMERIC: return ((NumberRecord)_record).getValue(); default: throw typeMismatch(CELL_TYPE_NUMERIC, _cellType, false); case CELL_TYPE_FORMULA: break; } FormulaRecord fr = ((FormulaRecordAggregate)_record).getFormulaRecord(); checkFormulaCachedValueType(CELL_TYPE_NUMERIC, fr); return fr.getValue(); }
/** * Get the value of the cell as a number. * For strings we throw an exception. * For blank cells we return a 0. * See {@link HSSFDataFormatter} for turning this * number into a string similar to that which * Excel would render this number as. */ public double getNumericCellValue() { switch(_cellType) { case CELL_TYPE_BLANK: return 0.0; case CELL_TYPE_NUMERIC: return ((NumberRecord)_record).getValue(); default: throw typeMismatch(CELL_TYPE_NUMERIC, _cellType, false); case CELL_TYPE_FORMULA: break; } FormulaRecord fr = ((FormulaRecordAggregate)_record).getFormulaRecord(); checkFormulaCachedValueType(CELL_TYPE_NUMERIC, fr); return fr.getValue(); }
/** * Get the value of the cell as a number. * For strings we throw an exception. * For blank cells we return a 0. * See {@link HSSFDataFormatter} for turning this * number into a string similar to that which * Excel would render this number as. */ public double getNumericCellValue() { switch(_cellType) { case BLANK: return 0.0; case NUMERIC: return ((NumberRecord)_record).getValue(); default: throw typeMismatch(CellType.NUMERIC, _cellType, false); case FORMULA: break; } FormulaRecord fr = ((FormulaRecordAggregate)_record).getFormulaRecord(); checkFormulaCachedValueType(CellType.NUMERIC, fr); return fr.getValue(); }