예제 #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));
        }
예제 #2
0
 public static int CountArg(ValueEval eval, I_MatchPredicate criteriaPredicate)
 {
     if (eval == null)
     {
         throw new ArgumentException("eval must not be null");
     }
     if (eval is AreaEval)
     {
         return(CountUtils.CountMatchingCellsInArea((AreaEval)eval, criteriaPredicate));
     }
     if (eval is RefEval)
     {
         return(CountUtils.CountMatchingCell((RefEval)eval, criteriaPredicate));
     }
     return(criteriaPredicate.Matches(eval) ? 1 : 0);
 }
예제 #3
0
파일: Countif.cs 프로젝트: thinhmascot/NPOI
        /**
         * @return the number of Evaluated cells in the range that match the specified criteria
         */
        private ValueEval CountMatchingCellsInArea(ValueEval rangeArg, I_MatchPredicate criteriaPredicate)
        {
            int result;

            if (rangeArg is RefEval)
            {
                result = CountUtils.CountMatchingCell((RefEval)rangeArg, criteriaPredicate);
            }
            else if (rangeArg is AreaEval)
            {
                result = CountUtils.CountMatchingCellsInArea((AreaEval)rangeArg, criteriaPredicate);
            }
            else
            {
                throw new ArgumentException("Bad range arg type (" + rangeArg.GetType().Name + ")");
            }
            return(new NumberEval(result));
        }
예제 #4
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));
        }