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

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


*/
public class Or extends BooleanFunction {

    public Eval evaluate(Eval[] operands, int srcRow, short srcCol) {
        ValueEval retval = null;
        boolean b = false;
        boolean atleastOneNonBlank = false;
       
        /*
         * Note: do not abort the loop if b is true, since we could be
         * dealing with errorevals later.
         */
        outer:
        for (int i=0, iSize=operands.length; i<iSize; i++) {
            if (operands[i] instanceof AreaEval) {
                AreaEval ae = (AreaEval) operands[i];
                ValueEval[] values = ae.getValues();
                for (int j=0, jSize=values.length; j<jSize; j++) {
                    ValueEval tempVe = singleOperandEvaluate(values[j], srcRow, srcCol, true);
                    if (tempVe instanceof BoolEval) {
                        b = b || ((BoolEval) tempVe).getBooleanValue();
                        atleastOneNonBlank = true;
                    }
                    else if (tempVe instanceof ErrorEval) {
                        retval = tempVe;
                        break outer;
                    }
                }
            }
            else {
                ValueEval tempVe = singleOperandEvaluate(operands[i], srcRow, srcCol, false);
                if (tempVe instanceof BoolEval) {
                    b = b || ((BoolEval) tempVe).getBooleanValue();
                    atleastOneNonBlank = true;
                }
                else if (tempVe instanceof ErrorEval) {
View Full Code Here


*
*/
public class IsError implements Function {

    public Eval evaluate(Eval[] operands, int srcCellRow, short srcCellCol) {
        ValueEval retval = null;
        boolean b = false;
       
        switch (operands.length) {
        default:
            retval = ErrorEval.VALUE_INVALID;
            break;
        case 1:
            if (operands[0] instanceof ErrorEval) {
                b = true;
            }
            else if (operands[0] instanceof AreaEval) {
                AreaEval ae = (AreaEval) operands[0];
                if (ae.contains(srcCellRow, srcCellCol)) { // circular ref!
                    retval = ErrorEval.CIRCULAR_REF_ERROR;
                }
                else if (ae.isRow()) {
                    if (ae.containsColumn(srcCellCol)) {
                        ValueEval ve = ae.getValueAt(ae.getFirstRow(), srcCellCol);
                        if (ve instanceof RefEval)
                            b = ((RefEval) ve).getInnerValueEval() instanceof ErrorEval;
                        else
                            b = (ve instanceof ErrorEval);
                    }
                    else {
                        b = true;
                    }
                }
                else if (ae.isColumn()) {
                    if (ae.containsRow(srcCellRow)) {
                        ValueEval ve = ae.getValueAt(srcCellRow, ae.getFirstColumn());
                        if (ve instanceof RefEval)
                            b = ((RefEval) ve).getInnerValueEval() instanceof ErrorEval;
                        else
                            b = (ve instanceof ErrorEval);
                    }
View Full Code Here

        if (eval instanceof NumberEval) {
            retval = true;
        }
        else if (eval instanceof RefEval) {
            RefEval re = (RefEval) eval;
            ValueEval ve = re.getInnerValueEval();
            retval = (ve instanceof NumberEval);
        }
       
        return retval;
    }
View Full Code Here

            NumberEval ne = (NumberEval) eval;
            retval = ne.getNumberValue();
        }
        else if (eval instanceof RefEval) {
            RefEval re = (RefEval) eval;
            ValueEval ve = re.getInnerValueEval();
                retval = (ve instanceof NumberEval)
                    ? ((NumberEval) ve).getNumberValue()
                    : Double.NaN;
        }
        else if (eval instanceof ErrorEval) {
View Full Code Here

*/
public class Exp extends NumericFunction {

    public Eval evaluate(Eval[] operands, int srcRow, short srcCol) {
        double d = 0;
        ValueEval retval = null;

        switch (operands.length) {
        default:
            retval = ErrorEval.VALUE_INVALID;
            break;
        case 1:
            ValueEval ve = singleOperandEvaluate(operands[0], srcRow, srcCol);
            if (ve instanceof NumericValueEval) {
                NumericValueEval ne = (NumericValueEval) ve;
                d = ne.getNumberValue();
            }
            else if (ve instanceof BlankEval) {
View Full Code Here

public class Fv extends FinanceFunction {

    public Eval evaluate(Eval[] operands, int srcRow, short srcCol) {
        double rate = 0, nper = 0, pmt = 0, pv = 0, d = 0;
        boolean type = false;
        ValueEval retval = null;
        ValueEval ve = null;
       
        switch (operands.length) {
        default:
            retval = ErrorEval.VALUE_INVALID;
            break;
View Full Code Here

public class Pv extends FinanceFunction {

    public Eval evaluate(Eval[] operands, int srcRow, short srcCol) {
        double rate = 0, fv = 0, nper = 0, pmt = 0, d = 0;
        boolean type = false;
        ValueEval retval = null;
        ValueEval ve = null;
       
        switch (operands.length) {
        default:
            retval = ErrorEval.VALUE_INVALID;
            break;
View Full Code Here

*/
public class Abs extends NumericFunction {
   
    public Eval evaluate(Eval[] operands, int srcRow, short srcCol) {
        double d = 0;
        ValueEval retval = null;
       
        switch (operands.length) {
        default:
            retval = ErrorEval.VALUE_INVALID;
            break;
        case 1:
            ValueEval ve = singleOperandEvaluate(operands[0], srcRow, srcCol);
            if (ve instanceof NumericValueEval) {
                NumericValueEval ne = (NumericValueEval) ve;
                d = ne.getNumberValue();
            }
            else if (ve instanceof BlankEval) {
View Full Code Here

    }

   
   
    public Eval evaluate(Eval[] operands, int srcCellRow, short srcCellCol) {
        ValueEval retval = null;
        double[] values = getNumberArray(operands, srcCellRow, srcCellCol);
        if (values == null) {
            retval = ErrorEval.VALUE_INVALID;
        }
        else {
View Full Code Here

*/
public class Atanh extends NumericFunction {

    public Eval evaluate(Eval[] operands, int srcRow, short srcCol) {
        double d = 0;
        ValueEval retval = null;

        switch (operands.length) {
        default:
            retval = ErrorEval.VALUE_INVALID;
            break;
        case 1:
            ValueEval ve = singleOperandEvaluate(operands[0], srcRow, srcCol);
            if (ve instanceof NumericValueEval) {
                NumericValueEval ne = (NumericValueEval) ve;
                d = ne.getNumberValue();
            }
            else if (ve instanceof BlankEval) {
View Full Code Here

TOP

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

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.