Package org.apache.poi.hssf.util

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


    /**
     * Takes in a String representation of a cell reference and fills out the
     * numeric fields.
     */
    protected RefPtgBase(String cellref) {
        CellReference c= new CellReference(cellref);
        setRow(c.getRow());
        setColumn(c.getCol());
        setColRelative(!c.isColAbsolute());
        setRowRelative(!c.isRowAbsolute());
    }
View Full Code Here


        field_1_row = in.readUShort();
        field_2_col = in.readUShort();
    }

    public final String toString() {
        CellReference cr = new CellReference(getRow(), getColumn(), !isRowRelative(),!isColRelative());
        StringBuffer sb = new StringBuffer();
        sb.append(getClass().getName());
        sb.append(" [");
        sb.append(cr.formatAsString());
        sb.append("]");
        return sb.toString();
    }
View Full Code Here

        return SIZE;
    }

    public final String toFormulaString(HSSFWorkbook book) {
        //TODO -- should we store a cellreference instance in this ptg?? but .. memory is an issue, i believe!
        return (new CellReference(getRowAsInt(),getColumn(),!isRowRelative(),!isColRelative())).formatAsString();
    }
View Full Code Here

  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

        if (workbook == null) {
          FileInputStream fin = new FileInputStream( FILENAME );
          workbook = new HSSFWorkbook( fin );
          fin.close();       
        }
        this.beginCell = new CellReference(beginCell);
    }
View Full Code Here

    /**
     * Takes in a String represnetation of a cell reference and fills out the
     * numeric fields.
     */
    public ReferencePtg(String cellref) {
        CellReference c= new CellReference(cellref);
        setRow((short) c.getRow());
        setColumn((short) c.getCol());
        setColRelative(!c.isColAbsolute());
        setRowRelative(!c.isRowAbsolute());
    }
View Full Code Here

    }

    public String toFormulaString(SheetReferences refs)
    {
        //TODO -- should we store a cellreference instance in this ptg?? but .. memory is an issue, i believe!
        return (new CellReference(getRow(),getColumn(),!isRowRelative(),!isColRelative())).toString();
    }
View Full Code Here

   */
  public void setPrintArea(int sheetIndex, int startColumn, int endColumn,
                int startRow, int endRow) {
                 
    //using absolute references because they dont get copied and pasted anyway                 
    CellReference cell = new CellReference(startRow, startColumn, true, true);
    String reference = cell.toString();
   
    cell = new CellReference(endRow, endColumn, true, true);
    reference = reference+":"+cell.toString();
   
    setPrintArea(sheetIndex, reference);                 
  }
View Full Code Here

        field_4_last_column = column;
    }

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

        return scorecard;
    }

    private void fulfillExpectation(int currentRowCtr, int currentColCtr, Object cellValue, Class expectedClass) throws ScorecardParseException {
        List<DataExpectation> dataExpectations = resolveExpectations(currentRowCtr, currentColCtr);
        CellReference cellRef = new CellReference(currentRowCtr, currentColCtr);
        Method method = null;
        for (DataExpectation dataExpectation : dataExpectations) {
            try {
                if (dataExpectation != null && dataExpectation.object != null) {
                    if ( cellValue == null || StringUtils.isEmpty(cellValue.toString())){
                        if ( dataExpectation.errorMessage != null && !StringUtils.isEmpty(dataExpectation.errorMessage)) {
                            parseErrors.add(new ScorecardError(cellRef.formatAsString(), dataExpectation.errorMessage));
                            return;
                        }
                    }
                    String setter = "set" + Character.toUpperCase(dataExpectation.property.charAt(0)) + dataExpectation.property.substring(1);
                    method = getSuitableMethod(cellValue, expectedClass, dataExpectation, setter);
                    if ( method == null ) {
                        if (cellValue != null && !StringUtils.isEmpty(cellValue.toString())) {
                            parseErrors.add(new ScorecardError(cellRef.formatAsString(), "Unexpected Value! Wrong Datatype?"));
                        }
                        return;
                    }
                    if (method.getParameterTypes()[0] == Double.class) {
                        cellValue = Double.parseDouble(cellValue.toString());
                    }
                    if (method.getParameterTypes()[0] == Boolean.class) {
                        cellValue = Boolean.valueOf(cellValue.toString());
                    }
                    if (method.getParameterTypes()[0] == String.class && !(cellValue instanceof String) && cellValue != null) {
                        cellValue = cellValue.toString();
                    }
                    method.invoke(dataExpectation.object, cellValue);
                    if (dataExpectation.object instanceof Extension && ("cellRef".equals(((Extension) dataExpectation.object).getName()))) {
                        ((Extension) dataExpectation.object).setValue(cellRef.formatAsString());
                    }
                    //dataExpectations.remove(dataExpectation);
                }
            } catch (Exception e) {
                throw new ScorecardParseException(e);
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.