Package org.apache.poi.hssf.util

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


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

    setFirstRow(  (short) frstCell.getRow() );
    setFirstColumn(     frstCell.getCol() );
    setLastRow(   (short) lastCell.getRow() );
    setLastColumn(      lastCell.getCol() );
    setFirstColRelative( !frstCell.isColAbsolute() );
    setLastColRelative!lastCell.isColAbsolute() );
    setFirstRowRelative( !frstCell.isRowAbsolute() );
    setLastRowRelative!lastCell.isRowAbsolute() );
  }
View Full Code Here


      //Required for clone methods
    }
  
    public AreaPtg(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());
        setLastColRelative(!lastCell.isColAbsolute());
        setFirstRowRelative(!firstCell.isRowAbsolute());
        setLastRowRelative(!lastCell.isRowAbsolute());       
    }
View Full Code Here

    public String toFormulaString(HSSFWorkbook book)
    {
      return toFormulaString(this, book);
    }
    protected static String toFormulaString(AreaI area, HSSFWorkbook book) {
      CellReference topLeft = new CellReference(area.getFirstRow(),area.getFirstColumn(),!area.isFirstRowRelative(),!area.isFirstColRelative());
      CellReference botRight = new CellReference(area.getLastRow(),area.getLastColumn(),!area.isLastRowRelative(),!area.isLastColRelative());
     
      if(AreaReference.isWholeColumnReference(topLeft, botRight)) {
        return (new AreaReference(topLeft, botRight)).formatAsString();
      } else {
        return topLeft.formatAsString() + ":" + botRight.formatAsString();
      }
    }
View Full Code Here

  private static String formatTestCaseDetails(String sheetName, int rowNum, HSSFCell c, String currentGroupComment,
      String rowComment) {
   
    StringBuffer sb = new StringBuffer();
    CellReference cr = new CellReference(sheetName, rowNum, c.getCellNum(), false, false);
    sb.append(cr.formatAsString());
    sb.append(" {=").append(c.getCellFormula()).append("}");
   
    if(currentGroupComment != null) {
      sb.append(" '");
      sb.append(currentGroupComment);
View Full Code Here

    // retrieve the cell at the named range and test its contents
    AreaReference aref = new AreaReference(aNamedCell.getReference());
    assertTrue("Should be exactly 1 cell in the named cell :'" +cellName+"'", aref.isSingleCell());

    CellReference cref = aref.getFirstCell();
    assertNotNull(cref);
    HSSFSheet s = wb.getSheet(cref.getSheetName());
    assertNotNull(s);
    HSSFRow r = sheet.getRow(cref.getRow());
    HSSFCell c = r.getCell(cref.getCol());
    String contents = c.getRichStringCellValue().getString();
    assertEquals("Contents of cell retrieved by its named reference", contents, cellValue);
  }
View Full Code Here

    int namedCellIdx = wb.getNameIndex(cname);
    HSSFName aNamedCell = wb.getNameAt(namedCellIdx);
    assertNotNull(aNamedCell);

    // retrieve the cell at the named range and test its contents
    CellReference cref = new CellReference(aNamedCell.getReference());
    assertNotNull(cref);
    HSSFSheet s = wb.getSheet(cref.getSheetName());
    HSSFRow r = sheet.getRow(cref.getRow());
    HSSFCell c = r.getCell(cref.getCol());
    String contents = c.getStringCellValue();
    assertEquals("Contents of cell retrieved by its named reference", contents, cvalue);
  }
View Full Code Here

      }
      FormulaRecordAggregate record = (FormulaRecordAggregate) cell.getCellValueRecord();
      FormulaRecord r = record.getFormulaRecord();
      List ptgs = r.getParsedExpression();
     
      String cellRef = new CellReference(row.getRowNum(), cell.getCellNum(), false, false).formatAsString();
      if(false && cellRef.equals("BP24")) { // TODO - replace System.out.println()s with asserts
        System.out.print(cellRef);
        System.out.println(" - has " + r.getNumberOfExpressionTokens()
                + " ptgs over " + r.getExpressionLength()  + " tokens:");
        for(int i=0; i<ptgs.size(); i++) {
View Full Code Here

                    refy1=(short)(y-4);
                    refy2=(short)(y-3);
                }

                c = r.getCell((short) y);
                CellReference cr= new CellReference(refx1,refy1, false, false);
                ref=cr.formatAsString();
                cr=new CellReference(refx2,refy2, false, false);
                ref2=cr.formatAsString();

                c = r.createCell((short) y);
                c.setCellFormula("" + ref + operator + ref2);

View Full Code Here

                    refy1=(short)(y-4);
                    refy2=(short)(y-3);
                }

                c = r.getCell((short) y);
                CellReference cr= new CellReference(refx1, refy1, false, false);
                ref=cr.formatAsString();
                cr=new CellReference(refx2,refy2, false, false);
                ref2=cr.formatAsString();


                assertTrue("loop Formula is as expected "+ref+operator+ref2+"!="+c.getCellFormula(),(
                (""+ref+operator+ref2).equals(c.getCellFormula())
                                                         )
View Full Code Here

        field_4_last_column = column;
    }

    public String toFormulaString(Workbook book)
    {
         return (new CellReference(getFirstRow(),getFirstColumn(),!isFirstRowRelative(),!isFirstColRelative())).toString() + ":" +
                (new CellReference(getLastRow(),getLastColumn(),!isLastRowRelative(),!isLastColRelative())).toString();
    }
View Full Code Here

TOP

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

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.