Package org.apache.poi.hssf.record.formula

Examples of org.apache.poi.hssf.record.formula.RefPtg


        if (!(ptgB instanceof RefPtg)) {
            // only when second ref is simple 2-D ref can the range
            // expression be converted to an area ref
            return null;
        }
        RefPtg refB = (RefPtg) ptgB;

        if (ptgA instanceof RefPtg) {
            RefPtg refA = (RefPtg) ptgA;
            return new AreaPtg(refA.getRow(), refB.getRow(), refA.getColumn(), refB.getColumn(),
                    refA.isRowRelative(), refB.isRowRelative(), refA.isColRelative(), refB.isColRelative());
        }
        if (ptgA instanceof Ref3DPtg) {
            Ref3DPtg refA = (Ref3DPtg) ptgA;
            return new Area3DPtg(refA.getRow(), refB.getRow(), refA.getColumn(), refB.getColumn(),
                    refA.isRowRelative(), refB.isRowRelative(), refA.isColRelative(), refB.isColRelative(),
                    refA.getExternSheetIndex());
        }
        // Note - other operand types (like AreaPtg) which probably can't evaluate
        // do not cause validation errors at parse time
        return null;
    }
View Full Code Here


 
  public void testReserialize() {
    FormulaRecord formulaRecord = new FormulaRecord();
    formulaRecord.setRow(1);
    formulaRecord.setColumn((short) 1);
    formulaRecord.setParsedExpression(new Ptg[] { new RefPtg("B$5"), });
    formulaRecord.setValue(3.3);
    byte[] ser = formulaRecord.serialize();
    assertEquals(31, ser.length);

    RecordInputStream in = TestcaseRecordInputStream.create(ser);
    FormulaRecord fr2 = new FormulaRecord(in);
    assertEquals(3.3, fr2.getValue(), 0.0);
    Ptg[] ptgs = fr2.getParsedExpression();
    assertEquals(1, ptgs.length);
    RefPtg rp = (RefPtg) ptgs[0];
    assertEquals("B$5", rp.toFormulaString());
  }
View Full Code Here

    int encodedLen = in.readUShort();
    Ptg[] sharedFormula = Ptg.readTokens(encodedLen, in);
   
    Ptg[] convertedFormula = SharedFormulaRecord.convertSharedFormulas(sharedFormula, 100, 200);
   
    RefPtg refPtg = (RefPtg) convertedFormula[1];
    assertEquals("$C101", refPtg.toFormulaString());
    if (refPtg.getPtgClass() == Ptg.CLASS_REF) {
      throw new AssertionFailedError("Identified bug 45123");
    }
   
    confirmOperandClasses(sharedFormula, convertedFormula);
  }
View Full Code Here

TOP

Related Classes of org.apache.poi.hssf.record.formula.RefPtg

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.