Package org.apache.poi.ss.formula.ptg

Examples of org.apache.poi.ss.formula.ptg.NamePtg


  /* package */ EvaluationWorkbook getWorkbook() {
    return _workbook;
  }

  /* package */ EvaluationName getName(String name, int sheetIndex) {
        NamePtg namePtg = _workbook.getName(name, sheetIndex).createPtg();

    if(namePtg == null) {
      return null;
    } else {
      return _workbook.getName(namePtg);
View Full Code Here


  private ValueEval getEvalForPtg(Ptg ptg, OperationEvaluationContext ec) {
    //  consider converting all these (ptg instanceof XxxPtg) expressions to (ptg.getClass() == XxxPtg.class)

    if (ptg instanceof NamePtg) {
      // named ranges, macro functions
      NamePtg namePtg = (NamePtg) ptg;
      EvaluationName nameRecord = _workbook.getName(namePtg);
      if (nameRecord.isFunctionName()) {
        return new NameEval(nameRecord.getNameText());
      }
      if (nameRecord.hasFormula()) {
View Full Code Here

    public boolean isRange() {
      return hasFormula(); // TODO - is this right?
    }
    public NamePtg createPtg() {
      return new NamePtg(_index);
    }
View Full Code Here

  /* package */ EvaluationWorkbook getWorkbook() {
    return _workbook;
  }

  /* package */ EvaluationName getName(String name, int sheetIndex) {
        NamePtg namePtg = _workbook.getName(name, sheetIndex).createPtg();

    if(namePtg == null) {
      return null;
    } else {
      return _workbook.getName(namePtg);
View Full Code Here

  private ValueEval getEvalForPtg(Ptg ptg, OperationEvaluationContext ec) {
    //  consider converting all these (ptg instanceof XxxPtg) expressions to (ptg.getClass() == XxxPtg.class)

    if (ptg instanceof NamePtg) {
      // named ranges, macro functions
      NamePtg namePtg = (NamePtg) ptg;
      EvaluationName nameRecord = _workbook.getName(namePtg);
      if (nameRecord.isFunctionName()) {
        return new NameEval(nameRecord.getNameText());
      }
      if (nameRecord.hasFormula()) {
View Full Code Here

  /* package */ EvaluationSheet getSheet(int sheetIndex) {
    return _workbook.getSheet(sheetIndex);
  }
 
  /* package */ EvaluationName getName(String name, int sheetIndex) {
        NamePtg namePtg = _workbook.getName(name, sheetIndex).createPtg();

    if(namePtg == null) {
      return null;
    } else {
      return _workbook.getName(namePtg);
View Full Code Here

  private ValueEval getEvalForPtg(Ptg ptg, OperationEvaluationContext ec) {
    //  consider converting all these (ptg instanceof XxxPtg) expressions to (ptg.getClass() == XxxPtg.class)

    if (ptg instanceof NamePtg) {
      // named ranges, macro functions
      NamePtg namePtg = (NamePtg) ptg;
      EvaluationName nameRecord = _workbook.getName(namePtg);
      if (nameRecord.isFunctionName()) {
        return new NameEval(nameRecord.getNameText());
      }
      if (nameRecord.hasFormula()) {
View Full Code Here

        row.createCell(1).setCellFormula("sales_1");
        row.createCell(2).setCellFormula("sales_1*3");

        //check that NamePtg refers to the correct NameRecord
        Ptg[] ptgs1 = HSSFFormulaParser.parse("sales_1", wb, FormulaType.CELL, 0);
        NamePtg nPtg1 = (NamePtg)ptgs1[0];
        assertSame(nm1, wb.getNameAt(nPtg1.getIndex()));

        Ptg[] ptgs2 = HSSFFormulaParser.parse("sales_1", wb, FormulaType.CELL, 1);
        NamePtg nPtg2 = (NamePtg)ptgs2[0];
        assertSame(nm2, wb.getNameAt(nPtg2.getIndex()));

        //check that the formula evaluator returns the correct result
        HSSFFormulaEvaluator evaluator = new HSSFFormulaEvaluator(wb);
        assertEquals(3.0, evaluator.evaluate(sh1.getRow(0).getCell(1)).getNumberValue(), 0.0);
        assertEquals(6.0, evaluator.evaluate(sh1.getRow(0).getCell(2)).getNumberValue(), 0.0);
View Full Code Here

    Ptg[] ptg = HSSFFormulaParser.parse("myFunc()", w);
    // myFunc() actually takes 1 parameter.  Don't know if POI will ever be able to detect this problem

    // the name gets encoded as the first arg
    NamePtg tname = (NamePtg) ptg[0];
    assertEquals("myFunc", tname.toFormulaString(book));

    AbstractFunctionPtg tfunc = (AbstractFunctionPtg) ptg[1];
    assertTrue(tfunc.isExternalFunction());
  }
View Full Code Here

    }
    public boolean isRange() {
      return _nameRecord.hasFormula(); // TODO - is this right?
    }
    public NamePtg createPtg() {
      return new NamePtg(_index);
    }
View Full Code Here

TOP

Related Classes of org.apache.poi.ss.formula.ptg.NamePtg

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.