Package org.apache.poi.hssf.util

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


        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);
        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 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 = new Double(Double.parseDouble(cellValue.toString()));
                    }
                    if (method.getParameterTypes()[0] == Boolean.class) {
                        cellValue = Boolean.valueOf(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


      }
      return cce.getValue();
    }
    if (isDebugLogEnabled()) {
      String sheetName = getSheetName(sheetIndex);
      CellReference cr = new CellReference(rowIndex, columnIndex);
      logDebug("Evaluated " + sheetName + "!" + cr.formatAsString() + " to " + result.toString());
    }
    // Usually (result === cce.getValue())
    // But sometimes: (result==ErrorEval.CIRCULAR_REF_ERROR, cce.getValue()==null)
    // When circular references are detected, the cache entry is only updated for
    // the top evaluation frame
View Full Code Here

   */
  private NotImplementedException addExceptionInfo(NotImplementedException inner, int sheetIndex, int rowIndex, int columnIndex) {

    try {
      String sheetName = _workbook.getSheetName(sheetIndex);
      CellReference cr = new CellReference(sheetName, rowIndex, columnIndex, false, false);
      String msg =  "Error evaluating cell " + cr.formatAsString();
      return new NotImplementedException(msg, inner);
    } catch (Exception e) {
      // avoid bombing out during exception handling
      e.printStackTrace();
      return inner; // preserve original exception
View Full Code Here

        relFirstRowIx, relLastRowIx, relFirstColIx, relLastColIx);

    return new LazyAreaEval(area, _evaluator);
  }
  public String toString() {
    CellReference crA = new CellReference(getFirstRow(), getFirstColumn());
    CellReference crB = new CellReference(getLastRow(), getLastColumn());
    StringBuffer sb = new StringBuffer();
    sb.append(getClass().getName()).append("[");
    sb.append(_evaluator.getSheetName());
    sb.append('!');
    sb.append(crA.formatAsString());
    sb.append(':');
    sb.append(crB.formatAsString());
    sb.append("]");
    return sb.toString();
  }
View Full Code Here

     */
    public void setPrintArea(int sheetIndex, int startColumn, int endColumn,
                              int startRow, int endRow) {

        //using absolute references because they don't get copied and pasted anyway
        CellReference cell = new CellReference(startRow, startColumn, true, true);
        String reference = cell.formatAsString();

        cell = new CellReference(endRow, endColumn, true, true);
        reference = reference+":"+cell.formatAsString();

        setPrintArea(sheetIndex, reference);
    }
View Full Code Here

    assertEquals(ar.getFirstCell().getCol(), ae.getFirstColumn());
    assertEquals(ar.getLastCell().getCol(), ae.getLastColumn());
  }

  private static ValueEval createRefEval(String refStr) {
    CellReference cr = new CellReference(refStr);
    return new MockRefEval(cr.getRow(), cr.getCol());

  }
View Full Code Here

    if ( refs != null )
    {
      retval.append( refs.getSheetName( this.field_1_index_extern_sheet ) );
      retval.append( '!' );
    }
    retval.append( ( new CellReference( getFirstRow(), getFirstColumn(), !isFirstRowRelative(), !isFirstColRelative() ) ).toString() );
    retval.append( ':' );
    retval.append( ( new CellReference( getLastRow(), getLastColumn(), !isLastRowRelative(), !isLastColRelative() ) ).toString() );
    return retval.toString();
  }
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

                    refy1=(short)(y-4);
                    refy2=(short)(y-3);
                }
               
                c = r.getCell((short) y);
                CellReference cr= new CellReference(refx1,refy1);
                ref=cr.toString();
                cr=new CellReference(refx2,refy2);
                ref2=cr.toString();

                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);
                ref=cr.toString();
                cr=new CellReference(refx2,refy2);
                ref2=cr.toString();
               
               
                assertTrue("loop Formula is as expected "+ref+operator+ref2+"!="+c.getCellFormula(),(
                (""+ref+operator+ref2).equals(c.getCellFormula())
                                                         )
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.