Package org.apache.poi.hssf.record.formula.eval

Examples of org.apache.poi.hssf.record.formula.eval.Eval


    assertEquals(ErrorEval.VALUE_INVALID, result);
  }
 
  public void testRoundupWithStringArg() {
   
    Eval strArg = new StringEval("abc");
    Eval[] args = { strArg, new NumberEval(2), };
    Eval result = new Roundup().evaluate(args, -1, (short)-1);
    assertEquals(ErrorEval.VALUE_INVALID, result);
  }
View Full Code Here


   * you specify, with another text string.
   *
   * @see org.apache.poi.hssf.record.formula.eval.Eval
   */
    public Eval evaluate(Eval[] operands, int srcCellRow, short srcCellCol) {   
      Eval retval = null;
        String oldStr = null;
        String newStr = null;
        int startNum = 0;
        int numChars = 0;
       
View Full Code Here

        return ErrorEval.VALUE_INVALID;
      default:
        // too many arguments
        return ErrorEval.VALUE_INVALID;
    }
    Eval firstArg = args[0];
   
    int result;
        if (firstArg instanceof AreaEval) {
            AreaEval ae = (AreaEval) firstArg;
            result = ae.getLastRow() - ae.getFirstRow() + 1;
View Full Code Here

* @author Amol S. Deshmukh < amolweb at ya hoo dot com >
*
*/
public class Istext extends LogicalFunction {
    public Eval evaluate(Eval[] operands, int srcCellRow, short srcCellCol) {
        Eval retval = BoolEval.FALSE;
       
        switch (operands.length) {
        default:
            retval = ErrorEval.VALUE_INVALID;
            break;
        case 1:
            Eval eval = operands[0];
            if (eval instanceof StringEval) {
                retval = BoolEval.TRUE;
            }
            else if (eval instanceof RefEval) {
                Eval xlatedEval = xlateRefEval((RefEval) eval);
                if (xlatedEval instanceof StringEval) {
                    retval = BoolEval.TRUE;
                }
            }
        }
View Full Code Here

* @author Amol S. Deshmukh < amolweb at ya hoo dot com >
*
*/
public class Isref implements Function {
    public Eval evaluate(Eval[] operands, int srcCellRow, short srcCellCol) {
        Eval retval = BoolEval.FALSE;
       
        switch (operands.length) {
        default:
            retval = ErrorEval.VALUE_INVALID;
            break;
        case 1:
            Eval eval = operands[0];
            if (eval instanceof RefEval || eval instanceof AreaEval) {
                retval = BoolEval.TRUE;
            }
        }
       
View Full Code Here

    int maxN = args.length;
   
    if(maxN < 1) {
      return ErrorEval.VALUE_INVALID;
    }
    Eval firstArg = args[0];
    try {
      if(firstArg instanceof NumericValueEval) {
        return evaluateSingleProduct(args);
      }
      if(firstArg instanceof RefEval) {
        return evaluateSingleProduct(args);
      }
      if(firstArg instanceof AreaEval) {
        AreaEval ae = (AreaEval) firstArg;
        if(ae.isRow() && ae.isColumn()) {
          return evaluateSingleProduct(args);
        }
        return evaluateAreaSumProduct(args);
      }
    } catch (EvalEx e) {
      return e.getError();
    }
    throw new RuntimeException("Invalid arg type for SUMPRODUCT: ("
        + firstArg.getClass().getName() + ")");
  }
View Full Code Here

    return new NumberEval(term);
  }

  private double getScalarValue(Eval arg) throws EvalEx {
   
    Eval eval;
    if (arg instanceof RefEval) {
      RefEval re = (RefEval) arg;
      eval = re.getInnerValueEval();
    } else {
      eval = arg;
    }
   
    if (eval == null) {
      throw new RuntimeException("parameter may not be null");
    }
    if (eval instanceof AreaEval) {
      AreaEval ae = (AreaEval) eval;
      // an area ref can work as a scalar value if it is 1x1
      if(!ae.isColumn() || !ae.isRow()) {
        throw new EvalEx(ErrorEval.VALUE_INVALID);
      }
      eval = ae.getValues()[0];
    }

    if (!(eval instanceof ValueEval)) {
      throw new RuntimeException("Unexpected value eval class ("
          + eval.getClass().getName() + ")");
    }
   
    return getProductTerm((ValueEval) eval, true);
  }
View Full Code Here

*
*/
public class Islogical extends LogicalFunction {

    public Eval evaluate(Eval[] operands, int srcCellRow, short srcCellCol) {
        Eval retval = BoolEval.FALSE;
       
        switch (operands.length) {
        default:
            retval = ErrorEval.VALUE_INVALID;
            break;
        case 1:
            Eval eval = operands[0];
            if (eval instanceof BoolEval) {
                retval = BoolEval.TRUE;
            }
            else if (eval instanceof RefEval) {
                Eval xlatedEval = xlateRefEval((RefEval) eval);
                if (xlatedEval instanceof BoolEval) {
                    retval = BoolEval.TRUE;
                }
            }
        }
View Full Code Here

        return ErrorEval.VALUE_INVALID;
      default:
        // too many arguments
        return ErrorEval.VALUE_INVALID;
    }
    Eval firstArg = args[0];
   
    int result;
        if (firstArg instanceof AreaEval) {
            AreaEval ae = (AreaEval) firstArg;
            result = ae.getLastColumn() - ae.getFirstColumn() + 1;
View Full Code Here

   *Substitutes text in a text string with new text, some number of times.
   *
   * @see org.apache.poi.hssf.record.formula.eval.Eval
   */
    public Eval evaluate(Eval[] operands, int srcCellRow, short srcCellCol) {   
      Eval retval = null;
        String oldStr = null;
        String searchStr = null;
        String newStr = null;
        int numToReplace = REPLACE_ALL;
       
View Full Code Here

TOP

Related Classes of org.apache.poi.hssf.record.formula.eval.Eval

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.