Package org.apache.poi.ss.util

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


    int absColIx = getFirstColumn() + columnIndex;
    return new LazyAreaEval(getFirstRow(), absColIx, getLastRow(), absColIx, _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.getSheetNameRange());
    sb.append('!');
    sb.append(crA.formatAsString());
    sb.append(':');
    sb.append(crB.formatAsString());
    sb.append("]");
    return sb.toString();
  }
View Full Code Here


        for(Cell acell : cr){
            try {
                sheet.removeArrayFormula(acell);
                fail("expected exception");
            } catch (IllegalArgumentException e){
                String ref = new CellReference(acell).formatAsString();
                assertEquals("Cell "+ref+" is not part of an array formula.", e.getMessage());
            }
        }
    }
View Full Code Here

            try {
                assertEquals(Cell.CELL_TYPE_FORMULA, mcell.getCellType());
                mcell.setCellType(Cell.CELL_TYPE_NUMERIC);
                fail("expected exception");
            } catch (IllegalStateException e){
                CellReference ref = new CellReference(mcell);
                String msg = "Cell "+ref.formatAsString()+" is part of a multi-cell array formula. You cannot change part of an array.";
                assertEquals(msg, e.getMessage());
            }
            // a failed invocation of Cell.setCellType leaves the cell
            // in the state that it was in prior to the invocation
            assertEquals(Cell.CELL_TYPE_FORMULA, mcell.getCellType());
View Full Code Here

            try {
                assertEquals("A1:A3*B1:B3", mcell.getCellFormula());
                mcell.setCellFormula("A1+A2");
                fail("expected exception");
            } catch (IllegalStateException e){
                CellReference ref = new CellReference(mcell);
                String msg = "Cell "+ref.formatAsString()+" is part of a multi-cell array formula. You cannot change part of an array.";
                assertEquals(msg, e.getMessage());
            }
            // a failed invocation of Cell.setCellFormula leaves the cell
            // in the state that it was in prior to the invocation
            assertEquals("A1:A3*B1:B3", mcell.getCellFormula());
View Full Code Here

            Row mrow = mcell.getRow();
            try {
                mrow.removeCell(mcell);
                fail("expected exception");
            } catch (IllegalStateException e){
                CellReference ref = new CellReference(mcell);
                String msg = "Cell "+ref.formatAsString()+" is part of a multi-cell array formula. You cannot change part of an array.";
                assertEquals(msg, e.getMessage());
            }
            // a failed invocation of Row.removeCell leaves the row
            // in the state that it was in prior to the invocation
            assertSame(mcell, mrow.getCell(columnIndex));
View Full Code Here

     * @param cellName
     * @return
     */
    private Cell getCell(String cellName) {

        CellReference cellRef = new CellReference(cellName);
        String sheetName = cellRef.getSheetName();
        Sheet sheet = workbook.getSheet(sheetName);
        if(sheet == null) {
            throw new BuildException("Sheet not found: " + sheetName);
        }

        int rowIdx = cellRef.getRow();
        int colIdx = cellRef.getCol();
        Row row = sheet.getRow(rowIdx);

        if( row == null ) {
          row = sheet.createRow( rowIdx ) ;
        }
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

                   
                    if (e instanceof NotImplementedFunctionException) {
                        NotImplementedFunctionException nie = (NotImplementedFunctionException)e;
                        unsupportedFunctions.add(nie.getFunctionName());
                    }
                    unevaluatableCells.put(new CellReference(c), e);
                }
            }
        }
       
        return new FormulaEvaluationProblems(unsupportedFunctions, unevaluatableCells);
View Full Code Here

        agg.setParsedExpression(ptgsForCell);
    }

    public CellRangeAddress getArrayFormulaRange() {
        if (_cellType != CELL_TYPE_FORMULA) {
            String ref = new CellReference(this).formatAsString();
            throw new IllegalStateException("Cell " + ref
                    + " is not part of an array formula.");
        }
        return ((FormulaRecordAggregate)_record).getArrayFormulaRange();
    }
View Full Code Here

TOP

Related Classes of org.apache.poi.ss.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.