Examples of AreaPtg


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

        String name = iden.getName();
        AreaReference areaRef = parseArea(name);
        if (areaRef != null) {
            // will happen if dots are used instead of colon
            return new AreaPtg(areaRef.formatAsString());
        }
        // This can be either a cell ref or a named range


        int nameType = CellReference.classifyCellReference(name);
        if (nameType == NameType.CELL) {
            return new RefPtg(name);
        }
        if (look == ':') {
            if (nameType == NameType.COLUMN) {
                GetChar();
                String secondIden = parseUnquotedIdentifier();
                if (CellReference.classifyCellReference(secondIden) != NameType.COLUMN) {
                    throw new FormulaParseException("Expected full column after '" + name
                            + ":' but got '" + secondIden + "'");
                }
                return new AreaPtg(name + ":" + secondIden);
            }
        }
        if (nameType != NameType.NAMED_RANGE) {
            new FormulaParseException("Name '" + name
                + "' does not look like a cell reference or named range");
View Full Code Here

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

  private static Ptg readRefPtg(byte[] formulaRawBytes) {
    LittleEndianInput in = new LittleEndianInputStream(new ByteArrayInputStream(formulaRawBytes));
    byte ptgSid = in.readByte();
    switch(ptgSid) {
      case AreaPtg.sid:   return new AreaPtg(in);
      case Area3DPtg.sid: return new Area3DPtg(in);
      case RefPtg.sid:    return new RefPtg(in);
      case Ref3DPtg.sid:  return new Ref3DPtg(in);
    }
    return null;
View Full Code Here

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

    return true;
  }

  private static CellRangeAddress shiftRange(FormulaShifter shifter, CellRangeAddress cra, int currentExternSheetIx) {
    // FormulaShifter works well in terms of Ptgs - so convert CellRangeAddress to AreaPtg (and back) here
    AreaPtg aptg = new AreaPtg(cra.getFirstRow(), cra.getLastRow(), cra.getFirstColumn(), cra.getLastColumn(), false, false, false, false);
    Ptg[] ptgs = { aptg, };
   
    if (!shifter.adjustFormula(ptgs, currentExternSheetIx)) {
      return cra;
    }
    Ptg ptg0 = ptgs[0];
    if (ptg0 instanceof AreaPtg) {
      AreaPtg bptg = (AreaPtg) ptg0;
      return new CellRangeAddress(bptg.getFirstRow(), bptg.getLastRow(), bptg.getFirstColumn(), bptg.getLastColumn());
    }
    if (ptg0 instanceof AreaErrPtg) {
      return null;
    }
    throw new IllegalStateException("Unexpected shifted ptg class (" + ptg0.getClass().getName() + ")");
View Full Code Here

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

    }
    private static Ptg readRefPtg(byte[] formulaRawBytes) {
      LittleEndianInput in = new LittleEndianByteArrayInputStream(formulaRawBytes);
      byte ptgSid = in.readByte();
      switch(ptgSid) {
        case AreaPtg.sid:   return new AreaPtg(in);
        case Area3DPtg.sid: return new Area3DPtg(in);
        case RefPtg.sid:    return new RefPtg(in);
        case Ref3DPtg.sid:  return new Ref3DPtg(in);
      }
      return null;
View Full Code Here

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

  private static Ptg readRefPtg(byte[] formulaRawBytes) {
    LittleEndianInput in = new LittleEndianInputStream(new ByteArrayInputStream(formulaRawBytes));
    byte ptgSid = in.readByte();
    switch(ptgSid) {
      case AreaPtg.sid:   return new AreaPtg(in);
      case Area3DPtg.sid: return new Area3DPtg(in);
      case RefPtg.sid:    return new RefPtg(in);
      case Ref3DPtg.sid:  return new Ref3DPtg(in);
    }
    return null;
View Full Code Here

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

  public void testColumnOperand() {

    short firstRow = (short)8;
    short lastRow = (short)12;
    short colNum = (short)5;
    AreaPtg areaPtg = new AreaPtg(firstRow, lastRow, colNum, colNum, false, false, false, false);
    ValueEval[] values = {
        new NumberEval(27),
        new NumberEval(29),
        new NumberEval(35)// value in row 10
        new NumberEval(37),
View Full Code Here

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

    assertEquals(AreaPtg.class, ops[0].getClass());
    assertEquals(FuncVarPtg.class, ops[1].getClass());

    // Actually stored as C1 to C65536
    // (last row is -1 === 65535)
    AreaPtg ptg = (AreaPtg) ops[0];
    assertEquals(2, ptg.getFirstColumn());
    assertEquals(2, ptg.getLastColumn());
    assertEquals(0, ptg.getFirstRow());
    assertEquals(65535, ptg.getLastRow());
    assertEquals("C:C", ptg.toFormulaString());

    // Will show as C:C, but won't know how many
    // rows it covers as we don't have the sheet
    // to hand when turning the Ptgs into a string
    assertEquals("SUM(C:C)", cellSUM.getCellFormula());
View Full Code Here

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

                HSSFRow row = xsheet.getRow(rownum);
                HSSFCell cell = (row != null) ? row.getCell(colnum) : null;
                pushRef3DEval(ptg, stack, cell, row, xsheet, workbook);
            }
            else if (ptgs[i] instanceof AreaPtg) {
                AreaPtg ap = (AreaPtg) ptgs[i];
                short row0 = ap.getFirstRow();
                short col0 = ap.getFirstColumn();
                short row1 = ap.getLastRow();
                short col1 = ap.getLastColumn();
                ValueEval[] values = new ValueEval[(row1 - row0 + 1) * (col1 - col0 + 1)];
                for (short x = row0; sheet != null && x < row1 + 1; x++) {
                    HSSFRow row = sheet.getRow(x);
                    for (short y = col0; row != null && y < col1 + 1; y++) {
                        values[(x - row0) * (col1 - col0 + 1) + (y - col0)] =
View Full Code Here

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

                HSSFRow row = xsheet.getRow(rowIx);
                HSSFCell cell = (row != null) ? row.getCell(colIx) : null;
                stack.push(createRef3DEval(refPtg, cell, row, xsheet, workbook));
            }
            else if (ptg instanceof AreaPtg) {
                AreaPtg ap = (AreaPtg) ptg;
                AreaEval ae = evaluateAreaPtg(sheet, workbook, ap);
                stack.push(ae);
            }
            else if (ptg instanceof Area3DPtg) {
                Area3DPtg a3dp = (Area3DPtg) ptg;
View Full Code Here

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

    assertEquals(AreaPtg.class, ops.get(0).getClass());
    assertEquals(FuncVarPtg.class, ops.get(1).getClass());

    // Actually stored as C1 to C65536
    // (last row is -1 === 65535)
    AreaPtg ptg = (AreaPtg) ops.get(0);
    assertEquals(2, ptg.getFirstColumn());
    assertEquals(2, ptg.getLastColumn());
    assertEquals(0, ptg.getFirstRow());
    assertEquals(65535, ptg.getLastRow());
    assertEquals("C:C", ptg.toFormulaString(wb));

    // Will show as C:C, but won't know how many
    // rows it covers as we don't have the sheet
    // to hand when turning the Ptgs into a string
    assertEquals("SUM(C:C)", cellSUM.getCellFormula());
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.