Exemplo n.º 1
0
        /// <summary>
        /// 查找原点
        /// </summary>
        /// <param name="book"></param>
        private void FindOrigin(ISheet sheet)
        {
            var Finder = new OriginCellFinder(sheet, this.OriginNames);

            Finder.Find();
            Origin = Finder.ResultCell;

            if (null != Finder)
            {
                return;
            }

            #region   old code......

            Origin = new OriginCell();


            for (int i = 0; i <= sheet.LastRowNum; i++)
            {
                IRow row = sheet.GetRow(i);
                if (null == row)
                {
                    continue;
                }

                if (0 == row.Cells.Count)
                {
                    continue;
                }

                if (row.Cells.Count == row.LastCellNum)
                {
                    Console.WriteLine("equre !");
                }

                for (int j = 0; j < row.LastCellNum; j++)
                {
                    //ICell cell = row.Cells[j];
                    ICell  cell       = row.GetCell(j);
                    string CellString = GetCellString(cell);
                    x.Say(String.Format("准备处理数据【{0}】行【{1}】列", i, j));
                    if (null == CellString)
                    {
                        x.Say("没有数据。");
                    }
                    else
                    {
                        x.Say("找到数据:" + CellString);
                    }
                    if ("品名" == CellString)
                    {
                        Origin = new OriginCell(j, i);
                        return;
                    }
                }
            }
            #endregion
        }
Exemplo n.º 2
0
        public OriginCell FindInSheet(ISheet sheet)
        {
            var ResultOrigin = new OriginCell();

            for (int i = 0; i <= sheet.LastRowNum; i++)
            {
                IRow row = sheet.GetRow(i);
                if (null == row)
                {
                    continue;
                }

                if (0 == row.Cells.Count)
                {
                    continue;
                }
                //row.Cells.Count 实际使用的数量
                //row.LastCellNum 最后一个cell的数字
                //if (row.Cells.Count == row.LastCellNum)
                //{
                //    //Console.WriteLine("equre !");
                //}
                for (int j = 0; j < row.LastCellNum; j++)
                {
                    x.Say(String.Format("准备处理数据【{0}】行【{1}】列", i, j));
                    ICell cell = row.GetCell(j);
                    if (IsOriginCell(cell))
                    {
                        ResultOrigin = new OriginCell(j, i);
                        return(ResultOrigin);
                    }
                    //if ("品名" == cellString)
                    //{
                    //    ResultOrigin = new OriginCell(j, i);
                    //    return;
                    //}
                }
            }
            return(ResultOrigin);
        }
Exemplo n.º 3
0
 public OriginCellFinder()
 {
     ResultCell  = new OriginCell();
     OriginNames = new List <string>();
     ResultList  = new List <OriginCell>();
 }