Package org.apache.poi.hssf.record

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


            thisRow = berec.getRow();
            thisColumn = berec.getColumn();
            thisStr = "";
            break;
        case FormulaRecord.sid:
          FormulaRecord frec = (FormulaRecord) record;
         
          thisRow = frec.getRow();
          thisColumn = frec.getColumn();
         
          if(outputFormulaValues) {
                thisStr = formatNumberDateCell(frec, frec.getValue());
          } else {
            // TODO: Output the formula string
            thisStr = '"' + frec.toString() + '"';
          }
            break;
        case LabelRecord.sid:
          LabelRecord lrec = (LabelRecord) record;
         
View Full Code Here


      case SSTRecord.sid:
        sstRecord = (SSTRecord)record;
        break;

      case FormulaRecord.sid:
        FormulaRecord frec = (FormulaRecord) record;
        thisRow = frec.getRow();

        if(_formulasNotResults) {
          thisText = HSSFFormulaParser.toFormulaString((HSSFWorkbook)null, frec.getParsedExpression());
        } else {
          if(frec.hasCachedResultString()) {
            // 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

    records.add(Sheet.createBOF());
    records.add(new DimensionsRecord());
    records.add(new RowRecord(0));
    records.add(new RowRecord(1));
    FormulaRecord formulaRecord = new FormulaRecord();
    formulaRecord.setCachedResultTypeString();
    records.add(formulaRecord);
    records.add(new StringRecord());
    records.add(new RowRecord(2));
    records.add(createWindow2Record());
    records.add(EOFRecord.instance);
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();
      Ptg[] ptgs = r.getParsedExpression();

      String cellRef = new CellReference(row.getRowNum(), cell.getColumnIndex(), false, false).formatAsString();
      if(false && cellRef.equals("BP24")) { // TODO - replace System.out.println()s with asserts
        System.out.print(cellRef);
        System.out.println(" - has " + ptgs.length + " ptgs:");
View Full Code Here

   * Processes a single cell value record
   * @param sfh used to resolve any shared-formulas/arrays/tables for the current sheet
   */
  public void construct(CellValueRecordInterface rec, RecordStream rs, SharedValueManager sfh) {
    if (rec instanceof FormulaRecord) {
      FormulaRecord formulaRec = (FormulaRecord)rec;
      // read optional cached text value
      StringRecord cachedText;
      Class<? extends Record> nextClass = rs.peekNextClass();
      if (nextClass == StringRecord.class) {
        cachedText = (StringRecord) rs.getNext();
View Full Code Here

        continue;
      }
      for (int j = 0; j < rowCells.length; j++) {
        CellValueRecordInterface cell = rowCells[j];
        if (cell instanceof FormulaRecordAggregate) {
          FormulaRecord fr = ((FormulaRecordAggregate)cell).getFormulaRecord();
          Ptg[] ptgs = fr.getParsedExpression(); // needs clone() inside this getter?
          if (shifter.adjustFormula(ptgs, currentExternSheetIndex)) {
            fr.setParsedExpression(ptgs);
          }
        }
      }
    }
  }
View Full Code Here

      ((FormulaRecordAggregate)cvRec).notifyFormulaChanging();
    }
    _valuesAgg.removeCell(cvRec);
  }
  public FormulaRecordAggregate createFormula(int row, int col) {
    FormulaRecord fr = new FormulaRecord();
    fr.setRow(row);
    fr.setColumn((short) col);
    return new FormulaRecordAggregate(fr, null, _sharedValueManager);
  }
View Full Code Here

        }
        int sheetIndex = _book.getSheetIndex(_sheet);
        Ptg[] ptgs = HSSFFormulaParser.parse(formula, _book, FormulaType.CELL, sheetIndex);
        setCellType(CELL_TYPE_FORMULA, false, row, col, styleIndex);
        FormulaRecordAggregate agg = (FormulaRecordAggregate) _record;
        FormulaRecord frec = agg.getFormulaRecord();
        frec.setOptions((short) 2);
        frec.setValue(0);

        //only set to default if there is no extended format index already set
        if (agg.getXFIndex() == (short)0) {
            agg.setXFIndex((short) 0x0f);
        }
View Full Code Here

            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

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.