Package org.apache.poi.hssf.util

Examples of org.apache.poi.hssf.util.AreaReference


    assertEquals(2, wb.getNumberOfNames());

    HSSFName name1 = wb.getNameAt(0);
    assertEquals("a", name1.getNameName());
    assertEquals("Sheet1!$A$1", name1.getReference());
    AreaReference ref1 = new AreaReference(name1.getReference());
    assertTrue("Successfully constructed first reference", true);

    HSSFName name2 = wb.getNameAt(1);
    assertEquals("b", name2.getNameName());
    assertEquals("#REF!", name2.getReference());
    assertTrue(name2.isDeleted());
    try {
      AreaReference ref2 = new AreaReference(name2.getReference());
      fail("attempt to supply an invalid reference to AreaReference constructor results in exception");
    } catch (StringIndexOutOfBoundsException e) { // TODO - use a different exception for this condition
      // expected during successful test
    }
   }
View Full Code Here


        return new ParseNode(parseNameOrReference(name));
    }

    private Ptg parseNameOrReference(String name) {
       
        AreaReference areaRef = parseArea(name);
        if (areaRef != null) {
            // will happen if dots are used instead of colon
            return new AreaPtg(areaRef.formatAsString());
        }

        if (look == ':' || look == '.') { // this is a AreaReference
            GetChar();

            while (look == '.') { // formulas can have . or .. or ... instead of :
                GetChar();
            }

            String first = name;
            String second = parseIdentifier();
            return new AreaPtg(first+":"+second);
        }

        if (look == '!') {
            Match('!');
            String sheetName = name;
            String first = parseIdentifier();
            short externIdx = (short)book.getExternalSheetIndex(book.getSheetIndex(sheetName));
            areaRef = parseArea(name);
            if (areaRef != null) {
                // will happen if dots are used instead of colon
                return new Area3DPtg(areaRef.formatAsString(), externIdx);
            }
            if (look == ':') {
                Match(':');
                String second=parseIdentifier();
                if (look == '!') {
View Full Code Here

        if (!isValidCellReference(partB)) {
            return null;
        }
        CellReference topLeft = new CellReference(partA);
        CellReference bottomRight = new CellReference(partB);
        return new AreaReference(topLeft, bottomRight);
    }
View Full Code Here

    private final static BitField   rowRelative = BitFieldFactory.getInstance(0x8000);
    private final static BitField   colRelative = BitFieldFactory.getInstance(0x4000);
    private final static BitField   columnMask      = BitFieldFactory.getInstance(0x3FFF);

    protected AreaPtgBase(String arearef) {
        AreaReference ar = new AreaReference(arearef);
        CellReference firstCell = ar.getFirstCell();
        CellReference lastCell = ar.getLastCell();
        setFirstRow(firstCell.getRow());
        setFirstColumn(firstCell.getCol());
        setLastRow(lastCell.getRow());
        setLastColumn(lastCell.getCol());
        setFirstColRelative(!firstCell.isColAbsolute());
View Full Code Here

    return result;
  }*/

  public void setArea( String ref )
  {
    AreaReference ar = new AreaReference( ref );
   
    CellReference frstCell = ar.getFirstCell();
    CellReference lastCell = ar.getLastCell();

    setFirstRow(  (short) frstCell.getRow() );
    setFirstColumn(  (short) frstCell.getCol() );
    setLastRow(     (short) lastCell.getRow() );
    setLastColumn(  (short) lastCell.getCol() );
View Full Code Here

    ValueEval[] args = {
      createRefEval(refA),
      createRefEval(refB),
    };
    AreaReference ar = new AreaReference(expectedAreaRef);
    ValueEval result = EvalInstances.Range.evaluate(args, 0, (short)0);
    assertTrue(result instanceof AreaEval);
    AreaEval ae = (AreaEval) result;
    assertEquals(ar.getFirstCell().getRow(), ae.getFirstRow());
    assertEquals(ar.getLastCell().getRow(), ae.getLastRow());
    assertEquals(ar.getFirstCell().getCol(), ae.getFirstColumn());
    assertEquals(ar.getLastCell().getCol(), ae.getLastColumn());
  }
View Full Code Here

  protected AreaPtgBase() {
    // do nothing
  }
 
  protected AreaPtgBase(String arearef) {
    AreaReference ar = new AreaReference(arearef);
    CellReference firstCell = ar.getFirstCell();
    CellReference lastCell = ar.getLastCell();
    setFirstRow(firstCell.getRow());
    setFirstColumn(firstCell.getCol());
    setLastRow(lastCell.getRow());
    setLastColumn(lastCell.getCol());
    setFirstColRelative(!firstCell.isColAbsolute());
View Full Code Here

  protected final String formatReferenceAsString() {
    CellReference topLeft = new CellReference(getFirstRow(),getFirstColumn(),!isFirstRowRelative(),!isFirstColRelative());
    CellReference botRight = new CellReference(getLastRow(),getLastColumn(),!isLastRowRelative(),!isLastColRelative());
   
    if(AreaReference.isWholeColumnReference(topLeft, botRight)) {
      return (new AreaReference(topLeft, botRight)).formatAsString();
    }
    return topLeft.formatAsString() + ":" + botRight.formatAsString();
  }
View Full Code Here

            // 3-D ref
            // this code assumes iden is a sheetName
            // TODO - handle <book name> ! <named range name>
            int externIdx = getExternalSheetIndex(iden.getName());
            String secondIden = parseUnquotedIdentifier();
            AreaReference areaRef = parseArea(secondIden);
            if (areaRef == null) {
                return new Ref3DPtg(secondIden, externIdx);
            }
            // will happen if dots are used instead of colon
            return new Area3DPtg(areaRef.formatAsString(), externIdx);
        }

        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);
View Full Code Here

        if (!isValidCellReference(partB)) {
            return null;
        }
        CellReference topLeft = new CellReference(partA);
        CellReference bottomRight = new CellReference(partB);
        return new AreaReference(topLeft, bottomRight);
    }
View Full Code Here

TOP

Related Classes of org.apache.poi.hssf.util.AreaReference

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.