コード例 #1
0
        /// <summary>
        /// 获得当前显示出来的、并且有Border信息、Text信息的Cell。被其他SpanCell挡住的Cell不被获得。
        /// </summary>
        /// <param name="startRow">起始行。</param>
        /// <param name="endRow">结束行。</param>
        /// <returns>当前显示出来的、并且有Border信息、Text信息的Cell。</returns>
        private List <CellInfo> GetVisibleCellInfo(int startRow, int endRow)
        {
            //所有当前显示出来的Cell。
            List <FarPoint.Win.Spread.Cell> visibleCellList = new List <FarPoint.Win.Spread.Cell>();
            List <CellInfo> cellInfoList = new List <CellInfo>();
            //循环。
            int columnCount = sheetMain.ColumnCount;

            for (int rowIndex = startRow; rowIndex <= endRow; rowIndex++)
            {
                for (int columnIndex = 0; columnIndex < columnCount; columnIndex++)
                {
                    FarPoint.Win.Spread.Cell cell = sheetMain.Cells[rowIndex, columnIndex];
                    FilterCell(visibleCellList, cell);
                }
            }
            //对显示出来的Cell进行二次过滤,将无需保存信息的Cell排除。
            foreach (FarPoint.Win.Spread.Cell cell in visibleCellList)
            {
                if (cell.RowSpan == 1 && cell.ColumnSpan == 1)
                {
                    //如果Cell没有字符且没有Border,则不记录。
                    if (cell.Value == null && cell.Border == null)
                    {
                        continue;
                    }
                    if (cell.Value != null && cell.Value.ToString() == string.Empty && cell.Border == null)
                    {
                        continue;
                    }
                }
                CellInfo cellInfo = new CellInfo();
                cellInfo.SetCellInfo(cell);
                cellInfoList.Add(cellInfo);
            }
            return(cellInfoList);
        }