Package org.apache.poi.hssf.record

Examples of org.apache.poi.hssf.record.FormulaRecord


            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();
    }
View Full Code Here


            case CELL_TYPE_NUMERIC:
                return ((NumberRecord)_record).getValue() != 0;

            case CELL_TYPE_FORMULA:
                // use cached formula result if it's the right type:
                FormulaRecord fr = ((FormulaRecordAggregate)_record).getFormulaRecord();
                checkFormulaCachedValueType(CELL_TYPE_BOOLEAN, fr);
                return fr.getCachedBooleanValue();
            // Other cases convert to false
            // These choices are not well justified.
            case CELL_TYPE_ERROR:
            case CELL_TYPE_BLANK:
                return false;
View Full Code Here

                break;
            default:
                throw new IllegalStateException("Unexpected cell type (" + _cellType + ")");
        }
        FormulaRecordAggregate fra = ((FormulaRecordAggregate)_record);
        FormulaRecord fr = fra.getFormulaRecord();
        switch (fr.getCachedResultType()) {
            case CELL_TYPE_BOOLEAN:
                return fr.getCachedBooleanValue() ? "TRUE" : "FALSE";
            case CELL_TYPE_STRING:
                return fra.getStringValue();
            case CELL_TYPE_NUMERIC:
                return NumberToTextConverter.toText(fr.getValue());
            case CELL_TYPE_ERROR:
                   return HSSFErrorConstants.getText(fr.getCachedErrorValue());
        }
        throw new IllegalStateException("Unexpected formula result type (" + _cellType + ")");
    }
View Full Code Here

            default:
                throw typeMismatch(CELL_TYPE_BOOLEAN, _cellType, false);
            case CELL_TYPE_FORMULA:
                break;
        }
        FormulaRecord fr = ((FormulaRecordAggregate)_record).getFormulaRecord();
        checkFormulaCachedValueType(CELL_TYPE_BOOLEAN, fr);
        return fr.getCachedBooleanValue();
    }
View Full Code Here

            default:
                throw typeMismatch(CELL_TYPE_ERROR, _cellType, false);
            case CELL_TYPE_FORMULA:
                break;
        }
        FormulaRecord fr = ((FormulaRecordAggregate)_record).getFormulaRecord();
        checkFormulaCachedValueType(CELL_TYPE_ERROR, fr);
        return (byte) fr.getCachedErrorValue();
    }
View Full Code Here

            case SSTRecord.sid: // holds all the strings for LabelSSTRecords
                sstRecord = (SSTRecord) record;
                break;

            case FormulaRecord.sid: // Cell value from a formula
                FormulaRecord formula = (FormulaRecord) record;
                addCell(record, new NumberCell(formula.getValue(), format));
                break;

            case LabelRecord.sid: // strings stored directly in the cell
                LabelRecord label = (LabelRecord) record;
                addTextCell(record, label.getValue());
View Full Code Here

            case SSTRecord.sid: // holds all the strings for LabelSSTRecords
                sstRecord = (SSTRecord) record;
                break;

            case FormulaRecord.sid: // Cell value from a formula
                FormulaRecord formula = (FormulaRecord) record;
                if (formula.hasCachedResultString()) {
                   // The String itself should be the next record
                   stringFormulaRecord = formula;
                } else {
                   addTextCell(record, formatListener.formatNumberDateCell(formula));
                }
View Full Code Here

              BoolErrRecord berec = (BoolErrRecord) record;
                thisRow = berec.getRow();
                thisColumn = berec.getColumn();
                break;
            case FormulaRecord.sid:
              FormulaRecord frec = (FormulaRecord) record;
              thisRow = frec.getRow();
              thisColumn = frec.getColumn();
                break;
            case LabelRecord.sid:
              LabelRecord lrec = (LabelRecord) record;
                thisRow = lrec.getRow();
                thisColumn = lrec.getColumn();
View Full Code Here

      case SSTRecord.sid:
        sstRecord = (SSTRecord)record;
        break;
     
          case FormulaRecord.sid:
            FormulaRecord frec = (FormulaRecord) record;
            thisRow = frec.getRow();
           
            if(formulasNotResults) {
              thisText = FormulaParser.toFormulaString(null, frec.getParsedExpression());
            } else {
              if(Double.isNaN( frec.getValue() )) {
                // Formula result is a string
                // This is stored in the next record
                outputNextStringValue = true;
                  nextRow = frec.getRow();
              } else {
                thisText = formatNumberDateCell(frec, frec.getValue());
              }
            }
              break;
          case StringRecord.sid:
            if(outputNextStringValue) {
View Full Code Here

      HSSFCell cell = (HSSFCell)it.next();
      if(cell.getCellType() != HSSFCell.CELL_TYPE_FORMULA) {
          continue;
      }
      FormulaRecordAggregate record = (FormulaRecordAggregate) cell.getCellValueRecord();
      FormulaRecord r = record.getFormulaRecord();
      List ptgs = r.getParsedExpression();
     
      String cellRef = new CellReference(row.getRowNum(), cell.getCellNum(), false, false).formatAsString();
      if(false && cellRef.equals("BP24")) { // TODO - replace System.out.println()s with asserts
        System.out.print(cellRef);
        System.out.println(" - has " + r.getNumberOfExpressionTokens()
                + " ptgs over " + r.getExpressionLength()  + " tokens:");
        for(int i=0; i<ptgs.size(); i++) {
          String c = ptgs.get(i).getClass().toString();
          System.out.println("\t" + c.substring(c.lastIndexOf('.')+1) );
        }
        System.out.println("-> " + cell.getCellFormula());
View Full Code Here

TOP

Related Classes of org.apache.poi.hssf.record.FormulaRecord

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.