Examples of FormulaRecordAggregate


Examples of org.apache.poi.hssf.record.aggregates.FormulaRecordAggregate

        // IntesectionPtg.  However it is still not capable of parsing it.
        // So FormulaEvalTestData.xls now contains a few formulas that produce errors here.
        System.err.println(e.getMessage());
      }
    }
    FormulaRecordAggregate fra = (FormulaRecordAggregate) cell.getCellValueRecord();
    return fra.getFormulaTokens();
  }
View Full Code Here

Examples of org.apache.poi.hssf.record.aggregates.FormulaRecordAggregate

   * operands to the range (:) operator.
   *
   */
  private static void pokeInOffsetFormula(HSSFCell cell) {
    cell.setCellFormula("1");
    FormulaRecordAggregate fr;
    try {
      Field field = HSSFCell.class.getDeclaredField("_record");
      field.setAccessible(true);
      fr = (FormulaRecordAggregate) field.get(cell);
    } catch (IllegalArgumentException e) {
      throw new RuntimeException(e);
    } catch (IllegalAccessException e) {
      throw new RuntimeException(e);
    } catch (NoSuchFieldException e) {
      throw new RuntimeException(e);
    }
    Ptg[] ptgs = {
        new RefPtg("C1"),
        new RefPtg("C1"),
        new IntPtg(0),
        new RefPtg("B1"),
        FuncVarPtg.create("OFFSET", (byte)3),
        RangePtg.instance,
        AttrPtg.SUM,
      };
    fr.setParsedExpression(ptgs);
  }
View Full Code Here

Examples of org.apache.poi.hssf.record.aggregates.FormulaRecordAggregate

                (( BlankRecord ) record).setXFIndex(( short ) 0);
                break;

            case CELL_TYPE_FORMULA :
                FormulaRecord formulaRecord = new FormulaRecord();
                record = new FormulaRecordAggregate(formulaRecord,null);
                formulaRecord.setColumn(col);
                formulaRecord.setRow(row);
                formulaRecord.setXFIndex(( short ) 0);
            case CELL_TYPE_BOOLEAN :
                record = new BoolErrRecord();
View Full Code Here

Examples of org.apache.poi.hssf.record.aggregates.FormulaRecordAggregate

        }
        switch (cellType)
        {

            case CELL_TYPE_FORMULA :
                FormulaRecordAggregate frec = null;

                if (cellType != this.cellType)
                {
                    frec = new FormulaRecordAggregate(new FormulaRecord(),null);
                }
                else
                {
                    frec = ( FormulaRecordAggregate ) record;
                }
                frec.setColumn(getCellNum());
                if (setValue)
                {
                    frec.getFormulaRecord().setValue(getNumericCellValue());
                }
                frec.setXFIndex(( short ) cellStyle.getIndex());
                frec.setRow(row);
                record = frec;
                break;

            case CELL_TYPE_NUMERIC :
                NumberRecord nrec = null;
View Full Code Here

Examples of org.apache.poi.hssf.record.aggregates.FormulaRecordAggregate

        //Workbook.currentBook=book;
        if (formula==null) {
            setCellType(CELL_TYPE_BLANK,false);
        } else {
            setCellType(CELL_TYPE_FORMULA,false);
            FormulaRecordAggregate rec = (FormulaRecordAggregate) record;
            rec.getFormulaRecord().setOptions(( short ) 2);
            rec.getFormulaRecord().setValue(0);
           
            //only set to default if there is no extended format index already set
            if (rec.getXFIndex() == (short)0) rec.setXFIndex(( short ) 0x0f);
            FormulaParser fp = new FormulaParser(formula+";",book);
            fp.parse();
            Ptg[] ptg  = fp.getRPNPtg();
            int   size = 0;
            //System.out.println("got Ptgs " + ptg.length);
            for (int k = 0; k < ptg.length; k++) {
                size += ptg[ k ].getSize();
                rec.getFormulaRecord().pushExpressionToken(ptg[ k ]);
            }
            rec.getFormulaRecord().setExpressionLength(( short ) size);
            //Workbook.currentBook = null;
        }
    }
View Full Code Here

Examples of org.apache.poi.hssf.record.aggregates.FormulaRecordAggregate

          ValueRecordsAggregate vrAgg = (ValueRecordsAggregate)rec;
          for (Iterator cellIter = vrAgg.getIterator();cellIter.hasNext();) {
            Record valRec = (Record)cellIter.next();
           
            if (valRec instanceof FormulaRecordAggregate) {
                FormulaRecordAggregate fmAgg = (FormulaRecordAggregate)valRec;
                Record fmAggRec = fmAgg.getFormulaRecord();
                if (fmAggRec != null)
                  clonedRecords.add(fmAggRec);
                fmAggRec =   fmAgg.getStringRecord();
                if (fmAggRec != null)
                  clonedRecords.add(fmAggRec);
              } else {
                clonedRecords.add(valRec);
              }
          }
        } else if (rec instanceof FormulaRecordAggregate) {  //Is this required now??
          FormulaRecordAggregate fmAgg = (FormulaRecordAggregate)rec;
          Record fmAggRec = fmAgg.getFormulaRecord();
          if (fmAggRec != null)
            clonedRecords.add(fmAggRec);
          fmAggRec =   fmAgg.getStringRecord();
          if (fmAggRec != null)
            clonedRecords.add(fmAggRec);
        } else {
          clonedRecords.add(rec);
        }
View Full Code Here

Examples of org.apache.poi.hssf.record.aggregates.FormulaRecordAggregate

        }
        switch (cellType)
        {

            case CELL_TYPE_FORMULA :
                FormulaRecordAggregate frec;

                if (cellType != _cellType) {
                    frec = _sheet.getSheet().getRowsAggregate().createFormula(row, col);
                } else {
                    frec = (FormulaRecordAggregate) _record;
                    frec.setRow(row);
                    frec.setColumn(col);
                }
                if (setValue)
                {
                    frec.getFormulaRecord().setValue(getNumericCellValue());
                }
                frec.setXFIndex(styleIndex);
                _record = frec;
                break;

            case CELL_TYPE_NUMERIC :
                NumberRecord nrec = null;
View Full Code Here

Examples of org.apache.poi.hssf.record.aggregates.FormulaRecordAggregate

            return;
        }
        if (_cellType == CELL_TYPE_FORMULA) {
            // Set the 'pre-evaluated result' for the formula
            // note - formulas do not preserve text formatting.
            FormulaRecordAggregate fr = (FormulaRecordAggregate) _record;
            fr.setCachedStringResult(hvalue.getString());
            // Update our local cache to the un-formatted version
            _stringValue = new HSSFRichTextString(value.getString());

            // All done
            return;
View Full Code Here

Examples of org.apache.poi.hssf.record.aggregates.FormulaRecordAggregate

            return;
        }
        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);
        }
        agg.setParsedExpression(ptgs);
    }
View Full Code Here

Examples of org.apache.poi.hssf.record.aggregates.FormulaRecordAggregate

            default:
                throw typeMismatch(CELL_TYPE_STRING, _cellType, false);
            case CELL_TYPE_FORMULA:
                break;
        }
        FormulaRecordAggregate fra = ((FormulaRecordAggregate)_record);
        checkFormulaCachedValueType(CELL_TYPE_STRING, fra.getFormulaRecord());
        String strVal = fra.getStringValue();
        return new HSSFRichTextString(strVal == null ? "" : strVal);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.