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


C# ICell类代码示例

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


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

示例1: CreateCell

 Cell CreateCell(ICell cell)
 {
     string value = null;
     switch (cell.CellType)
     {
         case CellType.STRING:
             value = cell.StringCellValue;
             break;
         case CellType.NUMERIC:
             value = cell.NumericCellValue.ToString();
             break;
         case CellType.FORMULA:
             switch (cell.CachedFormulaResultType)
             {
                 case CellType.STRING:
                     value = cell.StringCellValue;
                     break;
                 case CellType.NUMERIC:
                     //excel trigger is probably out-of-date
                     value = (cell.CellFormula == "TODAY()" ? DateTime.Today.ToOADate() : cell.NumericCellValue).ToString();
                     break;
             }
             break;
     }
     return new Cell(cell.RowIndex, cell.ColumnIndex, value);
 }
开发者ID:kellyselden,项目名称:Libraries,代码行数:26,代码来源:ExcelService.cs

示例2: SetCellValue

        private static void SetCellValue(HSSFWorkbook workbook, ICell workCell, Type type, dynamic row, Cell cell)
        {
            var value = type.GetProperty(cell.Field).GetValue(row);
            if (value == null)
            {
                return;
            }

            if (value is DateTime)
            {
                workCell.SetCellValue((DateTime)value);
            }
            else if (value is int)
            {
                workCell.SetCellValue((int)value);
            }
            else if (value is double)
            {
                workCell.SetCellValue((double)value);
            }
            else
            {
                workCell.SetCellValue(value.ToString());
            }

            if (!string.IsNullOrWhiteSpace(cell.Format))
            {
                var cellStyle = workbook.CreateCellStyle();
                var format = workbook.CreateDataFormat();
                cellStyle.DataFormat = format.GetFormat(cell.Format);
                workCell.CellStyle = cellStyle;
            }
        }
开发者ID:ErikXu,项目名称:CommonLibrary,代码行数:33,代码来源:ExcelUtil.cs

示例3: Equals

 /// <summary>
 ///     Compare cell objects
 /// </summary>
 /// <param name="other"> </param>
 /// <returns> </returns>
 public bool Equals(ICell other)
 {
     if (other == null) return false;
     if (other.Alive != Alive) return false;
     if (!other.Position.Equals(Position)) return false;
     return true;
 }
开发者ID:agamya,项目名称:GameOfLife,代码行数:12,代码来源:Cell.cs

示例4: GetCellValue

 /// <summary>
 /// 根据Excel列类型获取列的值
 /// </summary>
 /// <param name="cell">Excel列</param>
 /// <returns></returns>
 private static string GetCellValue(ICell cell)
 {
     if (cell == null)
         return string.Empty;
     switch (cell.CellType)
     {
         case CellType.BLANK:
             return string.Empty;
         case CellType.BOOLEAN:
             return cell.BooleanCellValue.ToString();
         case CellType.ERROR:
             return cell.ErrorCellValue.ToString();
         case CellType.NUMERIC:
         case CellType.Unknown:
         default:
             return cell.ToString();//This is a trick to get the correct value of the cell. NumericCellValue will return a numeric value no matter the cell value is a date or a number
         case CellType.STRING:
             return cell.StringCellValue;
         case CellType.FORMULA:
             try
             {
                 HSSFFormulaEvaluator e = new HSSFFormulaEvaluator(cell.Sheet.Workbook);
                 e.EvaluateInCell(cell);
                 return cell.ToString();
             }
             catch
             {
                 return cell.NumericCellValue.ToString();
             } 
     }
 }
开发者ID:cityjoy,项目名称:Portal.MVC,代码行数:36,代码来源:ExcelRender.cs

示例5: SetMemberValue

        private void SetMemberValue(string member, ICell cell, TextWriter log)
        {
            var info = GetType().GetProperty(member);
            if (info == null)
            {
                log.WriteLine("Property {0} is not defined in {1}", member, GetType().Name);
                return;
            }

            if(info.PropertyType != typeof(string))
                throw new NotImplementedException("This function was only designed to work for string properties.");

            string value = null;
            switch (cell.CellType)
            {
                case CellType.Numeric:
                    value = cell.NumericCellValue.ToString(CultureInfo.InvariantCulture);
                    break;
                case CellType.String:
                    value = cell.StringCellValue;
                    break;
                case CellType.Boolean:
                    value = cell.BooleanCellValue.ToString();
                    break;
                default:
                    log.WriteLine("There is no suitable value for {0} in cell {1}{2}, sheet {3}",
                        info.Name, CellReference.ConvertNumToColString(cell.ColumnIndex), cell.RowIndex + 1,
                        cell.Sheet.SheetName);
                    break;
            }
            info.SetValue(this, value);
        }
开发者ID:McLeanBH,项目名称:XbimExchange,代码行数:32,代码来源:Metadata.cs

示例6: RuInterferenceVictim

 public RuInterferenceVictim(ICell cell)
 {
     CellId = cell.CellId;
     SectorId = cell.SectorId;
     MeasuredTimes = 0;
     InterferenceTimes = 0;
 }
开发者ID:ouyh18,项目名称:LteTools,代码行数:7,代码来源:RuInterferenceVictim.cs

示例7: ProcessTest

 public IEnumerable<ICell> ProcessTest(
     [PexAssumeUnderTest]global::PathfindingAlgorithms.Algorithms.Astar.Astar target,
     ICell[,] cells,
     Coordinates from,
     Coordinates to
     )
 {
     PexAssume.IsNotNull(cells);
     PexAssume.IsTrue(cells.GetLength(0)* cells.GetLength(1) > 0);
     PexAssume.IsTrue(from.Inside(new Coordinates(cells.GetLength(0) - 1, cells.GetLength(1) - 1)));
     PexAssume.IsTrue(to.Inside(new Coordinates(cells.GetLength(0) - 1, cells.GetLength(1) - 1)));
     PexAssume.IsTrue(cells.GetLowerBound(0) == 0);
     PexAssume.IsTrue(cells.GetLowerBound(1) == 0);
     bool f = true;
     for (int x = cells.GetLowerBound(0); x <= cells.GetUpperBound(0); x++)
     {
         for (int y = cells.GetLowerBound(1); y <= cells.GetUpperBound(1); y++)
         {
             PexAssume.IsNotNull(cells[x, y]);
             PexAssume.IsNotNull(cells[x, y].Coordinates);
             f &= cells[x, y].Coordinates.Equals(new Coordinates(x, y));
         }
     }
     PexAssume.IsTrue(f);
     IEnumerable<ICell> result = target.Process(cells, from, to);
     return result;
     // TODO: добавление проверочных утверждений в метод AstarTest.ProcessTest(Astar, ICell[,], Coordinates, Coordinates)
 }
开发者ID:iu7-12-dbg,项目名称:t08-lab01,代码行数:28,代码来源:AstarTest.cs

示例8: SwapLookup

        private void SwapLookup(ICell cell)
        {
#pragma warning disable 0420
            //Ok to ignore CS0420 "a reference to a volatile field will not be treated as volatile" for interlocked calls http://msdn.microsoft.com/en-us/library/4bw5ewxy(VS.80).aspx
            Interlocked.Exchange(ref _lookup_DoNotCallMeDirectly, cell);
#pragma warning restore 0420
        }
开发者ID:njannink,项目名称:sonarlint-vs,代码行数:7,代码来源:RepointableActorRef.cs

示例9: Evaluate

        public virtual bool Evaluate(ICell cell, ICellContext context)
        {
            bool evaluated = false;
            Parallel.ForEach<IRule>(Rules, r => { evaluated |= r.Evaluate(cell, context); });

            return evaluated;
        }
开发者ID:cthibault,项目名称:Life,代码行数:7,代码来源:RulesManager.cs

示例10: CalculateInterfernece

        protected override double CalculateInterfernece(ICell[] position)
        {
            double totalInterference = 0;
            foreach (ICellRelation cellRelation in InterferenceMatrix)
            {
                ICell cell = position[cellRelation.CellIndex[0]];
                ICell interferingCell = position[cellRelation.CellIndex[1]];
                double interference = 0;
                for (int i = 0; i < interferingCell.Frequencies.Length; i++)
                {
                    for (int j = 0; j < cell.Frequencies.Length; j++)
                    {
                        int frequencyA = channels[interferingCell.Frequencies[i].Value];
                        int frequencyB = channels[cell.Frequencies[j].Value];
                        double trxInf = 0;
                        if (SameFrequency(frequencyA, frequencyB))
                        {
                            trxInf = ZeroIfOusideInterferneceThreshold(cellRelation.DA[0]);
                            interference += trxInf;
                        }
                        else if (base.FrequenciesDifferByOne(frequencyA, frequencyB))
                        {
                            trxInf = ZeroIfOusideInterferneceThreshold(cellRelation.DA[1]);
                            interference += trxInf;
                        }
                        cell.FrequencyHandler.SetSingleTrxInterference(j, trxInf);
                    }
                    //cell.Interference += interference;
                }
                cell.Interference += interference;
                totalInterference += interference;

            }
            return totalInterference;
        }
开发者ID:Burmudar,项目名称:PSOMastersDissertation,代码行数:35,代码来源:FAPIndexCostFunction.cs

示例11: Move

        public Direction Move(ICell cell)
        {
            /*
            Add current cell as visited
            Get possible directions
            Get all neighbouring cells that haven't been visited
            If found
                randomly choose one
                push it onto stack
                add to visited
                set as current position
                return cell
            If not that means dead end
                pop next cell from stack
                if no more cells that means we're at the start again and maze is not solvable
                else
                add to visited (should already be there but HashSet means it doesn't matter if it is added again)
                set as current position
                return cell
            */

            var random = new Random(DateTime.Now.Millisecond);
            visited.Add(cell);
            stack.Push(cell);
            var possibleDirections = GetPossibleDirections(cell);
            if (possibleDirections.Any()) return possibleDirections[random.Next(possibleDirections.Count)];

            if (stack.Count <= 0) return Direction.None; // We're back at the start and the maze is not solvable

            // Backtrack
            var previousCell = stack.Pop();
            visited.Add(previousCell);
            return GetDirection(cell, previousCell);
        }
开发者ID:LeedsSharp,项目名称:MazeSharp,代码行数:34,代码来源:DepthFirstSearch.cs

示例12: Mutate

        /// <summary>
        /// Perform a single point crossover.
        /// </summary>
        public static void Mutate(ICell cell)
        {
            if (cell == null) throw new ArgumentNullException("cell");

            // Iterate the tags and the resources within the tags
            for (int i = 0; i < cell.ActiveTagsInModel; i++)
            {
                // Potentially modify existing tag resources
                Tag activeTag = cell.GetTagByIndex(i);
                for (int j = 0; j < activeTag.Data.Count; j++)
                {
                    if (ShouldMutateThisPoint())
                    {
                        activeTag.Data[j] = Resource.Random(true);
                    }
                }

                // Potentially add a resource
                if (activeTag.Data.Count < Tag.MaxSize && ShouldMutateThisPoint())
                {
                    int insertionIndex = RandomProvider.Next(0, activeTag.Data.Count);
                    activeTag.Data.Insert(insertionIndex, Resource.Random(true));
                }

                // Potentially remove a resource
                if (activeTag.Data.Count > 2 && ShouldMutateThisPoint())
                {
                    activeTag.Data.RemoveRandom();
                }
            }
        }
开发者ID:andrewanderson,项目名称:Web-Critters,代码行数:34,代码来源:PointMutation.cs

示例13: Cell

        public Cell(ICell cell, Grid parent, Point p)
        {
            _cell = cell;
            var values = new List<int>();

            if (IsDefined)
            {
                var value = (int) (cell.Value);
                Result = value.ToString(CultureInfo.InvariantCulture);
                ResultColor = _cellColors[value - 1];
            }
            else
            {
                foreach (var value in _allNumericValues)
                {
                    if (cell.MayHaveValue(value))
                    {
                        values.Add((int) value);
                    }
                }

                Values =
                    Enumerable.Range(1, Width)
                              .ToList()
                              .Select(
                                  value =>
                                  Tuple.Create(value, new RelayCommand(() => parent.ValueChoosen(value, p)),
                                               values.Contains(value), _cellColors[value - 1]));
                Result = "?";
            }
        }
开发者ID:WinstonSmith77,项目名称:Sudoku,代码行数:31,代码来源:Cell.cs

示例14: Player

 /// <summary>
 /// Constructor with 2 parameters
 /// </summary>
 /// <param name="name">String that represents the name of the player</param>
 /// <param name="cell">Object of type ICell that represents the current position of the player</param>
 public Player(string name, ICell cell)
 {
     this.MovesCount = 0;
     this.Name = name;
     this.CurentCell = cell;
     this.StartPosition = cell.Position;
 }
开发者ID:HQC-Team-Labyrinth-2,项目名称:Labyrinth-2,代码行数:12,代码来源:Player.cs

示例15: SetCellValue

        /// <summary>
        /// Sets a cell value
        /// </summary>
        /// <param name="cell">The cell</param>
        /// <param name="value">The value to be assigned to the cell</param>
        public static void SetCellValue(ICell cell, object value)
        {
            if (value == null)
                cell.SetCellValue(null as string);

            else if (value is string ||
                     value is String)
                cell.SetCellValue(value as string);

            else if (value is bool ||
                     value is Boolean)
                cell.SetCellValue((bool) value);

            else if (value is DateTime) {
                //It works
                var wb = cell.Sheet.Workbook;
                var cellStyle = wb.CreateCellStyle();
                cellStyle.DataFormat = cell.Sheet.Workbook.GetCreationHelper().CreateDataFormat().GetFormat("dd/mm/yyyy" );
                cell.CellStyle = cellStyle;                
                cell.SetCellValue((DateTime) value);
            }

            else
                cell.SetCellValue(Convert.ToDouble(value));
        }
开发者ID:mgmccarthy,项目名称:FileHelpers,代码行数:30,代码来源:NPOIUtils.cs


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