Esempio n. 1
0
        public ValueEval Evaluate(ValueEval[] args, int srcCellRow, int srcCellCol)
        {
            int nArgs = args.Length;

            if (nArgs < 1)
            {
                // too few arguments
                return(ErrorEval.VALUE_INVALID);
            }

            if (nArgs > 30)
            {
                // too many arguments
                return(ErrorEval.VALUE_INVALID);
            }

            int temp = 0;

            // Note - observed behavior of Excel:
            // Error values like #VALUE!, #REF!, #DIV/0!, #NAME? etc don't cause this COUNTA to return an error
            // in fact, they seem to Get Counted

            for (int i = 0; i < nArgs; i++)
            {
                temp += CountUtils.CountArg(args[i], _predicate);
            }
            return(new NumberEval(temp));
        }
Esempio n. 2
0
 /**
  * @return the number of evaluated cells in the range that match the specified criteria
  */
 private double CountMatchingCellsInArea(ValueEval rangeArg, IMatchPredicate criteriaPredicate)
 {
     if (rangeArg is RefEval)
     {
         return(CountUtils.CountMatchingCellsInRef((RefEval)rangeArg, criteriaPredicate));
     }
     else if (rangeArg is ThreeDEval)
     {
         return(CountUtils.CountMatchingCellsInArea((ThreeDEval)rangeArg, criteriaPredicate));
     }
     else
     {
         throw new ArgumentException("Bad range arg type (" + rangeArg.GetType().Name + ")");
     }
 }
Esempio n. 3
0
 public static int CountArg(ValueEval eval, IMatchPredicate criteriaPredicate)
 {
     if (eval == null)
     {
         throw new ArgumentException("eval must not be null");
     }
     if (eval is TwoDEval)
     {
         return(CountUtils.CountMatchingCellsInArea((TwoDEval)eval, criteriaPredicate));
     }
     if (eval is RefEval)
     {
         return(CountUtils.CountMatchingCell((RefEval)eval, criteriaPredicate));
     }
     return(criteriaPredicate.Matches(eval) ? 1 : 0);
 }
Esempio n. 4
0
        public override ValueEval Evaluate(int srcRowIndex, int srcColumnIndex, ValueEval arg0)
        {
            double result;

            if (arg0 is RefEval)
            {
                result = CountUtils.CountMatchingCell((RefEval)arg0, predicate);
            }
            else if (arg0 is TwoDEval)
            {
                result = CountUtils.CountMatchingCellsInArea((TwoDEval)arg0, predicate);
            }
            else
            {
                throw new ArgumentException("Bad range arg type (" + arg0.GetType().Name + ")");
            }
            return(new NumberEval(result));
        }
Esempio n. 5
0
 public static int CountArg(ValueEval eval, IMatchPredicate criteriaPredicate)
 {
     if (eval == null)
     {
         throw new ArgumentException("eval must not be null");
     }
     if (eval is ThreeDEval)
     {
         return(CountUtils.CountMatchingCellsInArea((ThreeDEval)eval, criteriaPredicate));
     }
     if (eval is TwoDEval)
     {
         throw new ArgumentException("Count requires 3D Evals, 2D ones aren't supported");
     }
     if (eval is RefEval)
     {
         return(CountUtils.CountMatchingCellsInRef((RefEval)eval, criteriaPredicate));
     }
     return(criteriaPredicate.Matches(eval) ? 1 : 0);
 }
Esempio n. 6
0
        public ValueEval Evaluate(ValueEval[] args, int srcCellRow, int srcCellCol)
        {
            int nArgs = args.Length;

            if (nArgs < 1)
            {
                // too few arguments
                return(ErrorEval.VALUE_INVALID);
            }

            if (nArgs > 30)
            {
                // too many arguments
                return(ErrorEval.VALUE_INVALID);
            }

            int temp = 0;

            for (int i = 0; i < nArgs; i++)
            {
                temp += CountUtils.CountArg(args[i], _predicate);
            }
            return(new NumberEval(temp));
        }