• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# ValueEval类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中ValueEval的典型用法代码示例。如果您正苦于以下问题:C# ValueEval类的具体用法?C# ValueEval怎么用?C# ValueEval使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ValueEval类属于命名空间,在下文中一共展示了ValueEval类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Evaluate

        /**
         * returns the OperationEval concrete impl instance corresponding
         * to the supplied operationPtg
         */
        public static ValueEval Evaluate(OperationPtg ptg, ValueEval[] args,
                OperationEvaluationContext ec)
        {
            if(ptg == null) {
            throw new ArgumentException("ptg must not be null");
            }
            Function result = _instancesByPtgClass[ptg] as Function;

            if (result != null) {
            return  result.Evaluate(args, ec.RowIndex, (short) ec.ColumnIndex);
            }

            if (ptg is AbstractFunctionPtg) {
            AbstractFunctionPtg fptg = (AbstractFunctionPtg)ptg;
            int functionIndex = fptg.GetFunctionIndex();
            switch (functionIndex) {
                case NPOI.HSSF.Record.Formula.Function.FunctionMetadataRegistry.FUNCTION_INDEX_INDIRECT:
                    return Indirect.instance.Evaluate(args, ec);
                case NPOI.HSSF.Record.Formula.Function.FunctionMetadataRegistry.FUNCTION_INDEX_EXTERNAL:
                    return UserDefinedFunction.instance.Evaluate(args, ec);
            }

            return FunctionEval.GetBasicFunction(functionIndex).Evaluate(args, ec.RowIndex, ec.ColumnIndex);
            }
            throw new Exception("Unexpected operation ptg class (" + ptg.GetType().Name + ")");
        }
开发者ID:babywzazy,项目名称:Server,代码行数:30,代码来源:OperationEvaluatorFactory.cs


示例2: ConfirmPercentile

 private void ConfirmPercentile(ValueEval percentile, ValueEval[] args, double expected)
 {
     ValueEval result = invokePercentile(args, percentile);
     Assert.AreEqual(typeof(NumberEval), result.GetType());
     double delta = 0.00000001;
     Assert.AreEqual(expected, ((NumberEval)result).NumberValue, delta);
 }
开发者ID:asd1355215911,项目名称:npoi,代码行数:7,代码来源:TestPercentile.cs


示例3: EvaluateFunc

        public override ValueEval EvaluateFunc(ValueEval[] args, int srcCellRow, int srcCellCol)
        {
            if (args.Length != 3)
            {
                return ErrorEval.VALUE_INVALID;
            }

            String text = EvaluateStringArg(args[0], srcCellRow, srcCellCol);
            int startCharNum = EvaluateIntArg(args[1], srcCellRow, srcCellCol);
            int numChars = EvaluateIntArg(args[2], srcCellRow, srcCellCol);
            int startIx = startCharNum - 1; // convert to zero-based

            // Note - for start_num arg, blank/zero causes error(#VALUE!),
            // but for num_chars causes empty string to be returned.
            if (startIx < 0)
            {
                return ErrorEval.VALUE_INVALID;
            }
            if (numChars < 0)
            {
                return ErrorEval.VALUE_INVALID;
            }
            int len = text.Length;
            if (numChars < 0 || startIx > len)
            {
                return new StringEval("");
            }
            int endIx = Math.Min(startIx + numChars, len);
            String result = text.Substring(startIx, endIx-startIx);
            return new StringEval(result);
        }
开发者ID:missxiaohuang,项目名称:Weekly,代码行数:31,代码来源:Mid.cs


示例4: Calculate

        private bool Calculate(ValueEval[] args)
        {
            bool result = InitialResultValue;
            bool atleastOneNonBlank = false;
            bool? tempVe;
            /*
             * Note: no short-circuit bool loop exit because any ErrorEvals will override the result
             */
            for (int i = 0, iSize = args.Length; i < iSize; i++)
            {
                ValueEval arg = args[i];
                if (arg is AreaEval)
                {
                    AreaEval ae = (AreaEval)arg;
                    int height = ae.Height;
                    int width = ae.Width;
                    for (int rrIx = 0; rrIx < height; rrIx++)
                    {
                        for (int rcIx = 0; rcIx < width; rcIx++)
                        {
                            ValueEval ve = ae.GetRelativeValue(rrIx, rcIx);
                            tempVe = OperandResolver.CoerceValueToBoolean(ve, true);
                            if (tempVe != null)
                            {
                                result = PartialEvaluate(result, Convert.ToBoolean(tempVe));
                                atleastOneNonBlank = true;
                            }
                        }
                    }
                    continue;
                }

                if (arg is RefEval)
                {
                    ValueEval ve = ((RefEval)arg).InnerValueEval;
                    tempVe = OperandResolver.CoerceValueToBoolean(ve, true);
                }
                else if (arg is ValueEval)
                {
                    ValueEval ve = (ValueEval)arg;
                    tempVe = OperandResolver.CoerceValueToBoolean(ve, false);
                }
                else
                {
                    throw new InvalidOperationException("Unexpected eval (" + arg.GetType().Name + ")");
                }

                if (tempVe != null)
                {
                    result = PartialEvaluate(result, Convert.ToBoolean(tempVe));
                    atleastOneNonBlank = true;
                }
            }

            if (!atleastOneNonBlank)
            {
                throw new EvaluationException(ErrorEval.VALUE_INVALID);
            }
            return result;
        }
开发者ID:babywzazy,项目名称:Server,代码行数:60,代码来源:BooleanFunction.cs


示例5: Evaluate

 public override ValueEval Evaluate(int srcRowIndex, int srcColumnIndex, ValueEval arg0, ValueEval arg1)
 {
     double result;
     try
     {
         double d0 = SingleOperandEvaluate(arg0, srcRowIndex, srcColumnIndex);
         double d1 = SingleOperandEvaluate(arg1, srcRowIndex, srcColumnIndex);
         result = Evaluate(d0, d1);
         if (result == 0.0)
         { // this '==' matches +0.0 and -0.0
             // Excel Converts -0.0 to +0.0 for '*', '/', '%', '+' and '^'
             if (!(this is SubtractEval))
             {
                 return NumberEval.ZERO;
             }
         }
         if (Double.IsNaN(result) || Double.IsInfinity(result))
         {
             return ErrorEval.NUM_ERROR;
         }
     }
     catch (EvaluationException e)
     {
         return e.GetErrorEval();
     }
     return new NumberEval(result);
 }
开发者ID:missxiaohuang,项目名称:Weekly,代码行数:27,代码来源:TwoOperandNumericOperation.cs


示例6: Evaluate

        public ValueEval Evaluate(ValueEval[] args, OperationEvaluationContext ec)
        {
            int nIncomingArgs = args.Length;
            if (nIncomingArgs < 1)
            {
                throw new Exception("function name argument missing");
            }

            ValueEval nameArg = args[0];
            String functionName = string.Empty ;
            if (nameArg is NameEval)
            {
                functionName = ((NameEval)nameArg).FunctionName;
            }
            else if (nameArg is NameXEval)
            {
                functionName = ec.GetWorkbook().ResolveNameXText(((NameXEval)nameArg).Ptg);
            }
            else
            {
                throw new Exception("First argument should be a NameEval, but got ("
                        + nameArg.GetType().Name + ")");
            }
            FreeRefFunction targetFunc = ec.FindUserDefinedFunction(functionName);
            if (targetFunc == null)
            {
                throw new NotImplementedException(functionName);
            }
            int nOutGoingArgs = nIncomingArgs - 1;
            ValueEval[] outGoingArgs = new ValueEval[nOutGoingArgs];
            Array.Copy(args, 1, outGoingArgs, 0, nOutGoingArgs);
            return targetFunc.Evaluate(outGoingArgs, ec);
        }
开发者ID:JnS-Software-LLC,项目名称:npoi,代码行数:33,代码来源:UserDefinedFunction.cs


示例7: Evaluate

 public ValueEval Evaluate(ValueEval[] args, int srcCellRow, int srcCellCol)
 {
     ValueEval arg3 = null;
     switch (args.Length)
     {
         case 4:
             arg3 = args[3]; // important: assumed array element Is never null
             break;
         case 3:
             break;
         default:
             // wrong number of arguments
             return ErrorEval.VALUE_INVALID;
     }
     try
     {
         // Evaluation order:
         // arg0 lookup_value, arg1 table_array, arg3 range_lookup, Find lookup value, arg2 row_index, fetch result
         ValueEval lookupValue = OperandResolver.GetSingleValue(args[0], srcCellRow, srcCellCol);
         AreaEval tableArray = LookupUtils.ResolveTableArrayArg(args[1]);
         bool IsRangeLookup = LookupUtils.ResolveRangeLookupArg(arg3, srcCellRow, srcCellCol);
         int colIndex = LookupUtils.LookupIndexOfValue(lookupValue, LookupUtils.CreateRowVector(tableArray, 0), IsRangeLookup);
         int rowIndex = LookupUtils.ResolveRowOrColIndexArg(args[2], srcCellRow, srcCellCol);
         ValueVector resultCol = CreateResultColumnVector(tableArray, rowIndex);
         return resultCol.GetItem(colIndex);
     }
     catch (EvaluationException e)
     {
         return e.GetErrorEval();
     }
 }
开发者ID:babywzazy,项目名称:Server,代码行数:31,代码来源:Hlookup.cs


示例8: TestCountBlank

        public void TestCountBlank()
        {

            AreaEval range;
            ValueEval[] values;

            values = new ValueEval[] {
				new NumberEval(0),
				new StringEval(""),	// note - does not match blank
				BoolEval.TRUE,
				BoolEval.FALSE,
				ErrorEval.DIV_ZERO,
				BlankEval.instance,
		};
            range = EvalFactory.CreateAreaEval("A1:B3", values);
            ConfirmCountBlank(1, range);

            values = new ValueEval[] {
				new NumberEval(0),
				new StringEval(""),	// note - does not match blank
				BlankEval.instance,
				BoolEval.FALSE,
				BoolEval.TRUE,
				BlankEval.instance,
		};
            range = EvalFactory.CreateAreaEval("A1:B3", values);
            ConfirmCountBlank(2, range);
        }
开发者ID:xiepeixing,项目名称:npoi,代码行数:28,代码来源:TestCountFuncs.cs


示例9: Evaluate

        public override ValueEval Evaluate(int srcRowIndex, int srcColumnIndex, ValueEval arg0)
        {
            ValueEval arg = arg0;
            if (arg is RefEval)
            {
                // always use the first sheet
                RefEval re = (RefEval)arg;
                arg = re.GetInnerValueEval(re.FirstSheetIndex);
            }
            else if (arg is AreaEval)
            {
                // when the arg is an area, choose the top left cell
                arg = ((AreaEval)arg).GetRelativeValue(0, 0);
            }

            if (arg is StringEval)
            {
                // Text values are returned unmodified
                return arg;
            }

            if (arg is ErrorEval)
            {
                // Error values also returned unmodified
                return arg;
            }
            // for all other argument types the result is empty string
            return StringEval.EMPTY_INSTANCE;
        }
开发者ID:Reinakumiko,项目名称:npoi,代码行数:29,代码来源:T.cs


示例10: EvaluateFunc

        /**
         *Substitutes text in a text string with new text, some number of times.
         *
         * @see org.apache.poi.hssf.record.formula.eval.Eval
         */
        public override ValueEval EvaluateFunc(ValueEval[] args, int srcCellRow, int srcCellCol)
        {
            if (args.Length < 3 || args.Length > 4)
            {
                return ErrorEval.VALUE_INVALID;
            }

            String oldStr = EvaluateStringArg(args[0], srcCellRow, srcCellCol);
            String searchStr = EvaluateStringArg(args[1], srcCellRow, srcCellCol);
            String newStr = EvaluateStringArg(args[2], srcCellRow, srcCellCol);

            String result;

            switch (args.Length)
            {
                case 4:
                    int instanceNumber = EvaluateIntArg(args[3], srcCellRow, srcCellCol);
                    if (instanceNumber < 1)
                    {
                        return ErrorEval.VALUE_INVALID;
                    }
                    result = ReplaceOneOccurrence(oldStr, searchStr, newStr, instanceNumber);
                    break;
                case 3:
                    result = ReplaceAllOccurrences(oldStr, searchStr, newStr);
                    break;
                default:
                    throw new InvalidOperationException("Cannot happen");

            }

            return new StringEval(result);
        }
开发者ID:babywzazy,项目名称:Server,代码行数:38,代码来源:Substitute.cs


示例11: TestCriteriaArgRange

        public void TestCriteriaArgRange()
        {
            ValueEval[] arg0values = new ValueEval[] { _50, _60, _50, _50, _50, _30, };
            ValueEval[] arg1values = new ValueEval[] { _30, _40, _50, _60, };

            AreaEval arg0;
            AreaEval arg1;
            ValueEval ve;

            arg0 = EvalFactory.CreateAreaEval("A3:B5", arg0values);
            arg1 = EvalFactory.CreateAreaEval("A2:D2", arg1values); // single row range

            ve = invokeSumif(0, 2, arg0, arg1);  // invoking from cell C1
            if (ve is NumberEval)
            {
                NumberEval ne = (NumberEval)ve;
                if (ne.NumberValue == 30.0)
                {
                    throw new AssertionException("identified error in SUMIF - criteria arg not Evaluated properly");
                }
            }

            ConfirmDouble(200, ve);

            arg0 = EvalFactory.CreateAreaEval("C1:D3", arg0values);
            arg1 = EvalFactory.CreateAreaEval("B1:B4", arg1values); // single column range

            ve = invokeSumif(3, 0, arg0, arg1); // invoking from cell A4

            ConfirmDouble(60, ve);
        }
开发者ID:hanwangkun,项目名称:npoi,代码行数:31,代码来源:TestSumif.cs


示例12: Evaluate

        public ValueEval Evaluate(ValueEval[] args, OperationEvaluationContext ec)
        {
            double result;

            if (args.Length != 2)
            {
                return ErrorEval.VALUE_INVALID;
            }

            try
            {
                double startDateAsNumber = GetValue(args[0]);
                NumberEval offsetInYearsValue = (NumberEval)args[1];
                int offsetInMonthAsNumber = (int)offsetInYearsValue.NumberValue;
                // resolve the arguments
                DateTime startDate = DateUtil.GetJavaDate(startDateAsNumber);

                DateTime resultDate = startDate.AddMonths(offsetInMonthAsNumber);
                result = DateUtil.GetExcelDate(resultDate);
                    
                NumericFunction.CheckValue(result);
                return new NumberEval(result);
            }
            catch (EvaluationException e)
            {
                return e.GetErrorEval();
            }
        }
开发者ID:korneyev,项目名称:npoi,代码行数:28,代码来源:EDate.cs


示例13: Evaluate

        public ValueEval Evaluate(ValueEval[] args, int srcRowIndex, int srcColumnIndex)
        {
            int nInnerArgs = args.Length - 1; // -1: first arg is used to select from a basic aggregate function
            if (nInnerArgs < 1)
            {
                return ErrorEval.VALUE_INVALID;
            }

            Function innerFunc;
            try
            {
                ValueEval ve = OperandResolver.GetSingleValue(args[0], srcRowIndex, srcColumnIndex);
                int functionCode = OperandResolver.CoerceValueToInt(ve);
                innerFunc = FindFunction(functionCode);
            }
            catch (EvaluationException e)
            {
                return e.GetErrorEval();
            }

            ValueEval[] innerArgs = new ValueEval[nInnerArgs];
            Array.Copy(args, 1, innerArgs, 0, nInnerArgs);

            return innerFunc.Evaluate(innerArgs, srcRowIndex, srcColumnIndex);
        }
开发者ID:missxiaohuang,项目名称:Weekly,代码行数:25,代码来源:Subtotal.cs


示例14: Evaluate

        public ValueEval Evaluate(ValueEval[] args, OperationEvaluationContext ec)
        {
            DateTime date;
            double numberOfMonths, result;

            if (args.Length != 2)
            {
                return ErrorEval.VALUE_INVALID;
            }

            try
            {
                // resolve the arguments
                date = DateUtil.GetJavaDate(OperandResolver.CoerceValueToDouble(OperandResolver.GetSingleValue(args[0], ec.RowIndex, ec.ColumnIndex)));
                numberOfMonths = OperandResolver.CoerceValueToDouble(OperandResolver.GetSingleValue(args[1], ec.RowIndex, ec.ColumnIndex));

                // calculate the result date (Excel rounds the second argument always to zero; but we have be careful about negative numbers)
                DateTime resultDate = date.AddMonths((int)Math.Floor(Math.Abs(numberOfMonths)) * Math.Sign(numberOfMonths));
                result = DateUtil.GetExcelDate(resultDate);
                    
                NumericFunction.CheckValue(result);
                return new NumberEval(result);
            }
            catch (EvaluationException e)
            {
                return e.GetErrorEval();
            }
        }
开发者ID:89sos98,项目名称:npoi,代码行数:28,代码来源:EDate.cs


示例15: EvaluateFunc

        /**
         * Replaces part of a text string based on the number of Chars 
         * you specify, with another text string.
         * 
         * @see org.apache.poi.hssf.record.formula.eval.Eval
         */
        public override ValueEval EvaluateFunc(ValueEval[] args, int srcCellRow, int srcCellCol)
        {
            if (args.Length != 4)
            {
                return ErrorEval.VALUE_INVALID;
            }

            String oldStr = EvaluateStringArg(args[0], srcCellRow, srcCellCol);
            int startNum = EvaluateIntArg(args[1], srcCellRow, srcCellCol);
            int numChars = EvaluateIntArg(args[2], srcCellRow, srcCellCol);
            String newStr = EvaluateStringArg(args[3], srcCellRow, srcCellCol);

            if (startNum < 1 || numChars < 0)
            {
                return ErrorEval.VALUE_INVALID;
            }
            StringBuilder strBuff = new StringBuilder(oldStr);
            // remove any characters that should be replaced
            if (startNum <= oldStr.Length && numChars != 0)
            {
                strBuff.Remove(startNum - 1, startNum - 1 + numChars);
            }
            // now insert (or append) newStr
            if (startNum > strBuff.Length)
            {
                strBuff.Append(newStr);
            }
            else
            {
                strBuff.Insert(startNum - 1, newStr);
            }
            return new StringEval(strBuff.ToString());
        }
开发者ID:Johnnyfly,项目名称:source20131023,代码行数:39,代码来源:Replace.cs


示例16: Evaluate

 public override ValueEval Evaluate(int srcRowIndex, int srcColumnIndex, ValueEval arg0, ValueEval arg1,
         ValueEval arg2)
 {
     bool b;
     try
     {
         b = EvaluateFirstArg(arg0, srcRowIndex, srcColumnIndex);
     }
     catch (EvaluationException e)
     {
         return e.GetErrorEval();
     }
     if (b)
     {
         if (arg1 == MissingArgEval.instance)
         {
             return BlankEval.instance;
         }
         return arg1;
     }
     if (arg2 == MissingArgEval.instance)
     {
         return BlankEval.instance;
     }
     return arg2;
 }
开发者ID:89sos98,项目名称:npoi,代码行数:26,代码来源:If.cs


示例17: Evaluate

 public override ValueEval Evaluate(int srcCellRow, int srcCellCol, ValueEval arg0)
 {
     double d;
     try
     {
         ValueEval ve = OperandResolver.GetSingleValue(arg0, srcCellRow, srcCellCol);
         if (ve is BlankEval)
         {
             return NumberEval.ZERO;
         }
         if (ve is StringEval)
         {
             // Note - asymmetric with UnaryMinus
             // -"hello" Evaluates to #VALUE!
             // but +"hello" Evaluates to "hello"
             return ve;
         }
         d = OperandResolver.CoerceValueToDouble(ve);
     }
     catch (EvaluationException e)
     {
         return e.GetErrorEval();
     }
     return new NumberEval(+d);
 }
开发者ID:Johnnyfly,项目名称:source20131023,代码行数:25,代码来源:UnaryPlusEval.cs


示例18: Evaluate

        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);
        }
开发者ID:Reinakumiko,项目名称:npoi,代码行数:27,代码来源:Counta.cs


示例19: AreValuesEqual

 private static bool AreValuesEqual(ValueEval a, ValueEval b)
 {
     if (a == null)
     {
         return false;
     }
     Type cls = a.GetType();
     if (cls != b.GetType())
     {
         // value type is changing
         return false;
     }
     if (a == BlankEval.instance)
     {
         return b == a;
     }
     if (cls == typeof(NumberEval))
     {
         return ((NumberEval)a).NumberValue == ((NumberEval)b).NumberValue;
     }
     if (cls == typeof(StringEval))
     {
         return ((StringEval)a).StringValue.Equals(((StringEval)b).StringValue);
     }
     if (cls == typeof(BoolEval))
     {
         return ((BoolEval)a).BooleanValue == ((BoolEval)b).BooleanValue;
     }
     if (cls == typeof(ErrorEval))
     {
         return ((ErrorEval)a).ErrorCode == ((ErrorEval)b).ErrorCode;
     }
     throw new InvalidOperationException("Unexpected value class (" + cls.Name + ")");
 }
开发者ID:uwitec,项目名称:web-mvc-logistics,代码行数:34,代码来源:CellCacheEntry.cs


示例20: EvaluateDatesArg

        /**
         * Evaluate a generic {@link ValueEval} argument to an array of double values that represents dates in POI.
         * 
         * @param arg {@link ValueEval} an argument.
         * @param srcCellRow number cell row.
         * @param srcCellCol number cell column.
         * @return an array of doubles representing dates in POI.
         * @throws EvaluationException exception upon argument evaluation.
         */
        public double[] EvaluateDatesArg(ValueEval arg, int srcCellRow, int srcCellCol)
        {
            if (arg == null)
            {
                return new double[0];
            }

            if (arg is StringEval)
            {
                return new double[] { EvaluateDateArg(arg, srcCellRow, srcCellCol) };
            }
            else if (arg is AreaEvalBase)
            {
                List<Double> valuesList = new List<Double>();
                AreaEvalBase area = (AreaEvalBase)arg;
                for (int i = area.FirstRow; i <= area.LastRow; i++)
                {
                    for (int j = area.FirstColumn; j <= area.LastColumn; j++)
                    {
                        valuesList.Add(EvaluateDateArg(area.GetValue(i, j), i, j));
                    }
                }
                double[] values = new double[valuesList.Count];
                for (int i = 0; i < valuesList.Count; i++)
                {
                    values[i] = valuesList[(i)];
                }
                return values;
            }
            return new double[] { OperandResolver.CoerceValueToDouble(arg) };
        }
开发者ID:89sos98,项目名称:npoi,代码行数:40,代码来源:ArgumentsEvaluator.cs



注:本文中的ValueEval类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ValueItem类代码示例发布时间:2022-05-24
下一篇:
C# ValueChangedEventArgs类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap