当前位置: 首页>>代码示例>>C#>>正文


C# AreaEval类代码示例

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


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

示例1: Evaluate

        public ValueEval Evaluate(ValueEval[] args, OperationEvaluationContext ec)
        {
            if (args.Length < 3 || args.Length % 2 == 0)
            {
                return ErrorEval.VALUE_INVALID;
            }

            try
            {
                AreaEval sumRange = ConvertRangeArg(args[0]);

                // collect pairs of ranges and criteria
                AreaEval[] ae = new AreaEval[(args.Length - 1) / 2];
                I_MatchPredicate[] mp = new I_MatchPredicate[ae.Length];
                for (int i = 1, k = 0; i < args.Length; i += 2, k++)
                {
                    ae[k] = ConvertRangeArg(args[i]);
                    mp[k] = Countif.CreateCriteriaPredicate(args[i + 1], ec.RowIndex, ec.ColumnIndex);
                }

                ValidateCriteriaRanges(ae, sumRange);

                double result = SumMatchingCells(ae, mp, sumRange);
                return new NumberEval(result);
            }
            catch (EvaluationException e)
            {
                return e.GetErrorEval();
            }
        }
开发者ID:hanwangkun,项目名称:npoi,代码行数:30,代码来源:Sumifs.cs

示例2: ResolveRange

        /**
         * @return simple rectangular {@link AreaEval} which represents the intersection of areas
         * <c>aeA</c> and <c>aeB</c>. If the two areas do not intersect, the result is <code>null</code>.
         */
        private static AreaEval ResolveRange(AreaEval aeA, AreaEval aeB)
        {

            int aeAfr = aeA.FirstRow;
            int aeAfc = aeA.FirstColumn;
            int aeBlc = aeB.LastColumn;
            if (aeAfc > aeBlc)
            {
                return null;
            }
            int aeBfc = aeB.FirstColumn;
            if (aeBfc > aeA.LastColumn)
            {
                return null;
            }
            int aeBlr = aeB.LastRow;
            if (aeAfr > aeBlr)
            {
                return null;
            }
            int aeBfr = aeB.FirstRow;
            int aeAlr = aeA.LastRow;
            if (aeBfr > aeAlr)
            {
                return null;
            }


            int top = Math.Max(aeAfr, aeBfr);
            int bottom = Math.Min(aeAlr, aeBlr);
            int left = Math.Max(aeAfc, aeBfc);
            int right = Math.Min(aeA.LastColumn, aeBlc);

            return aeA.Offset(top - aeAfr, bottom - aeAfr, left - aeAfc, right - aeAfc);
        }
开发者ID:missxiaohuang,项目名称:Weekly,代码行数:39,代码来源:IntersectionEval.cs

示例3: CreateResultColumnVector

 /**
  * Returns one column from an <tt>AreaEval</tt>
  *
  * @(#VALUE!) if colIndex Is negative, (#REF!) if colIndex Is too high
  */
 private ValueVector CreateResultColumnVector(AreaEval tableArray, int rowIndex)
 {
     if (rowIndex >= tableArray.Height)
     {
         throw EvaluationException.InvalidRef();
     }
     return LookupUtils.CreateRowVector(tableArray, rowIndex);
 }
开发者ID:babywzazy,项目名称:Server,代码行数:13,代码来源:Hlookup.cs

示例4: CreateVector

 private static ValueVector CreateVector(AreaEval ae)
 {
     ValueVector result = LookupUtils.CreateVector(ae);
     if (result != null)
     {
         return result;
     }
     // extra complexity required to emulate the way LOOKUP can handles these abnormal cases.
     throw new InvalidOperationException("non-vector lookup or result areas not supported yet");
 }
开发者ID:babywzazy,项目名称:Server,代码行数:10,代码来源:Lookup.cs

示例5: Eval

        private static ValueEval Eval(int srcRowIndex, int srcColumnIndex, ValueEval arg1, AreaEval aeRange,
                AreaEval aeSum)
        {

            // TODO - junit to prove last arg must be srcColumnIndex and not srcRowIndex
            I_MatchPredicate mp = Countif.CreateCriteriaPredicate(arg1, srcRowIndex, srcColumnIndex);
            double result = SumMatchingCells(aeRange, mp, aeSum);
            return new NumberEval(result);

        }
开发者ID:Johnnyfly,项目名称:source20131023,代码行数:10,代码来源:Sumif.cs

示例6: ValidateCriteriaRanges

 /**
  * Verify that each <code>criteriaRanges</code> argument contains the same number of rows and columns
  * as the <code>sumRange</code> argument
  *
  * @throws EvaluationException if
  */
 private void ValidateCriteriaRanges(AreaEval[] criteriaRanges, AreaEval sumRange)
 {
     foreach (AreaEval r in criteriaRanges)
     {
         if (r.Height != sumRange.Height ||
            r.Width != sumRange.Width)
         {
             throw EvaluationException.InvalidValue();
         }
     }
 }
开发者ID:hanwangkun,项目名称:npoi,代码行数:17,代码来源:Sumifs.cs

示例7: ColumnVector

 public ColumnVector(AreaEval tableArray, int columnIndex)
 {
     _columnIndex = columnIndex;
     int _columnAbsoluteIndex = tableArray.FirstColumn + columnIndex;
     if (!tableArray.ContainsColumn((short)_columnAbsoluteIndex))
     {
         int lastColIx = tableArray.LastColumn - tableArray.FirstColumn;
         throw new ArgumentException("Specified column index (" + columnIndex
                 + ") is outside the allowed range (0.." + lastColIx + ")");
     }
     _tableArray = tableArray;
     _size = _tableArray.Height;
 }
开发者ID:missxiaohuang,项目名称:Weekly,代码行数:13,代码来源:LookupUtils.cs

示例8: RowVector

 public RowVector(AreaEval tableArray, int rowIndex)
 {
     _rowIndex = rowIndex;
     int _rowAbsoluteIndex = tableArray.FirstRow + rowIndex;
     if (!tableArray.ContainsRow(_rowAbsoluteIndex))
     {
         int lastRowIx = tableArray.LastRow - tableArray.FirstRow;
         throw new ArgumentException("Specified row index (" + rowIndex
                 + ") is outside the allowed range (0.." + lastRowIx + ")");
     }
     _tableArray = tableArray;
     _size = tableArray.Width;
 }
开发者ID:missxiaohuang,项目名称:Weekly,代码行数:13,代码来源:LookupUtils.cs

示例9: SumMatchingCells

        private static double SumMatchingCells(AreaEval aeRange, I_MatchPredicate mp, AreaEval aeSum)
        {
            int height = aeRange.Height;
            int width = aeRange.Width;

            double result = 0.0;

            for (int r = 0; r < height; r++)
            {
                for (int c = 0; c < width; c++)
                {
                    result += Accumulate(aeRange, mp, aeSum, r, c);
                }
            }
            return result;
        }
开发者ID:Johnnyfly,项目名称:source20131023,代码行数:16,代码来源:Sumif.cs

示例10: ChooseSingleElementFromArea

        /**
         * Implements (some perhaps not well known) Excel functionality to select a single cell from an
         * area depending on the coordinates of the calling cell.  Here is an example demonstrating
         * both selection from a single row area and a single column area in the same formula.
         *
         *    <table border="1" cellpAdding="1" cellspacing="1" summary="sample spReadsheet">
         *      <tr><th>&nbsp;</th><th>&nbsp;A&nbsp;</th><th>&nbsp;B&nbsp;</th><th>&nbsp;C&nbsp;</th><th>&nbsp;D&nbsp;</th></tr>
         *      <tr><th>1</th><td>15</td><td>20</td><td>25</td><td>&nbsp;</td></tr>
         *      <tr><th>2</th><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>200</td></tr>
         *      <tr><th>3</th><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>300</td></tr>
         *      <tr><th>3</th><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>400</td></tr>
         *    </table>
         *
         * If the formula "=1000+A1:B1+D2:D3" is put into the 9 cells from A2 to C4, the spReadsheet
         * will look like this:
         *
         *    <table border="1" cellpAdding="1" cellspacing="1" summary="sample spReadsheet">
         *      <tr><th>&nbsp;</th><th>&nbsp;A&nbsp;</th><th>&nbsp;B&nbsp;</th><th>&nbsp;C&nbsp;</th><th>&nbsp;D&nbsp;</th></tr>
         *      <tr><th>1</th><td>15</td><td>20</td><td>25</td><td>&nbsp;</td></tr>
         *      <tr><th>2</th><td>1215</td><td>1220</td><td>#VALUE!</td><td>200</td></tr>
         *      <tr><th>3</th><td>1315</td><td>1320</td><td>#VALUE!</td><td>300</td></tr>
         *      <tr><th>4</th><td>#VALUE!</td><td>#VALUE!</td><td>#VALUE!</td><td>400</td></tr>
         *    </table>
         *
         * Note that the row area (A1:B1) does not include column C and the column area (D2:D3) does
         * not include row 4, so the values in C1(=25) and D4(=400) are not accessible to the formula
         * as written, but in the 4 cells A2:B3, the row and column selection works ok.<p/>
         *
         * The same concept is extended to references across sheets, such that even multi-row,
         * multi-column areas can be useful.<p/>
         *
         * Of course with carefully (or carelessly) chosen parameters, cyclic references can occur and
         * hence this method <b>can</b> throw a 'circular reference' EvaluationException.  Note that
         * this method does not attempt to detect cycles.  Every cell in the specified Area <tt>ae</tt>
         * has already been Evaluated prior to this method call.  Any cell (or cell<b>s</b>) part of
         * <tt>ae</tt> that would incur a cyclic reference error if selected by this method, will
         * already have the value <t>ErrorEval.CIRCULAR_REF_ERROR</tt> upon entry to this method.  It
         * is assumed logic exists elsewhere to produce this behaviour.
         *
         * @return whatever the selected cell's Evaluated value Is.  Never <c>null</c>. Never
         *  <tt>ErrorEval</tt>.
         * @if there is a problem with indexing into the area, or if the
         *  Evaluated cell has an error.
         */
        public static ValueEval ChooseSingleElementFromArea(AreaEval ae,
                int srcCellRow, int srcCellCol)
        {
            ValueEval result = ChooseSingleElementFromAreaInternal(ae, srcCellRow, srcCellCol);
            if (result == null)
            {
                // This seems to be required because AreaEval.Values array may contain nulls.
                // perhaps that should not be allowed.
                result = BlankEval.instance;
            }
            if (result is ErrorEval)
            {
                throw new EvaluationException((ErrorEval)result);

            }
            return result;
        }
开发者ID:babywzazy,项目名称:Server,代码行数:61,代码来源:OperandResolver.cs

示例11: AreasAllSameSize

 private static bool AreasAllSameSize(AreaEval[] args, int height, int width)
 {
     for (int i = 0; i < args.Length; i++)
     {
         AreaEval areaEval = args[i];
         // check that height and width match
         if (areaEval.Height != height)
         {
             return false;
         }
         if (areaEval.Width != width)
         {
             return false;
         }
     }
     return true;
 }
开发者ID:babywzazy,项目名称:Server,代码行数:17,代码来源:Sumproduct.cs

示例12: CountMatchingCellsInArea

        /**
         * @return the number of evaluated cells in the range that match the specified criteria
         */
        public static int CountMatchingCellsInArea(AreaEval areaEval, I_MatchPredicate criteriaPredicate)
        {
            int result = 0;

            int height = areaEval.Height;
            int width = areaEval.Width;
            for (int rrIx = 0; rrIx < height; rrIx++)
            {
                for (int rcIx = 0; rcIx < width; rcIx++)
                {
                    ValueEval ve = areaEval.GetRelativeValue(rrIx, rcIx);
                    if (criteriaPredicate.Matches(ve))
                    {
                        result++;
                    }
                }
            }
            return result;
        }
开发者ID:babywzazy,项目名称:Server,代码行数:22,代码来源:CountUtils.cs

示例13: eval

        private static ValueEval eval(int srcRowIndex, int srcColumnIndex, double arg0, AreaEval aeRange, bool descending_order)
        {

            int rank = 1;
            int height = aeRange.Height;
            int width = aeRange.Width;
            for (int r = 0; r < height; r++)
            {
                for (int c = 0; c < width; c++)
                {

                    Double value = GetValue(aeRange, r, c);
                    if (Double.IsNaN(value)) continue;
                    if (descending_order && value > arg0 || !descending_order && value < arg0)
                    {
                        rank++;
                    }
                }
            }
            return new NumberEval(rank);
        }
开发者ID:ctddjyds,项目名称:npoi,代码行数:21,代码来源:Rank.cs

示例14: BaseRef

 public BaseRef(AreaEval ae)
 {
     _refEval = null;
     _areaEval = ae;
     _firstRowIndex = ae.FirstRow;
     _firstColumnIndex = ae.FirstColumn;
     _height = ae.LastRow - ae.FirstRow + 1;
     _width = ae.LastColumn - ae.FirstColumn + 1;
 }
开发者ID:ChiangHanLung,项目名称:PIC_VDS,代码行数:9,代码来源:Offset.cs

示例15: AreaValueArray

 public AreaValueArray(AreaEval ae)
     : base(ae.Width * ae.Height)
 {
     _ae = ae;
     _width = ae.Width;
 }
开发者ID:babywzazy,项目名称:Server,代码行数:6,代码来源:XYNumericFunction.cs


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