コード例 #1
0
            public override object Evaluate(object[] arguments, ICalcContext context)
            {
                int           count         = 0;
                CalcReference calcReference = arguments[0] as CalcReference;

                foreach (IRange srcRange in calcReference.GetRanges())
                {
                    object[,] values = srcRange.Value as object[, ];
                    for (int row = 0; row < srcRange.Rows.Count; row++)
                    {
                        for (int col = 0; col < srcRange.Columns.Count; col++)
                        {
                            if (values[row, col] is double)
                            {
                                double num = (double)values[row, col];
                                if (num > 70)
                                {
                                    count++;
                                }
                            }
                        }
                    }
                }
                return(count);
            }
コード例 #2
0
 private static IEnumerable <object> Enumerate(CalcReference reference)
 {
     foreach (var range in reference.GetRanges())
     {
         int rowCount = range.Rows.Count;
         int colCount = range.Columns.Count;
         for (int i = 0; i < rowCount; i++)
         {
             for (int j = 0; j < colCount; j++)
             {
                 if (range.Cells[i, j].DisplayFormat.Interior.Color == System.Drawing.Color.Red)
                 {
                     yield return(range.Cells[i, j].Value);
                 }
             }
         }
     }
 }