Exemplo n.º 1
0
        protected override List <Cell> GetCells(int rowIndex, int maxColEnd)
        {
            List <Cell> result = new List <Cell>();

            Aspose.Cells.Row  row       = worksheet.Cells.Rows[rowIndex];
            Aspose.Cells.Cell firstCell = row.FirstCell;
            Aspose.Cells.Cell lastCell  = row.LastCell;
            if (lastCell == null)
            {
                return(result);
            }

            for (int i = 0; i <= lastCell.Column; i++)
            {
                if (i >= maxColEnd)
                {
                    break;
                }
                Aspose.Cells.Cell cell = row.GetCellOrNull(i);
                result.Add(new AsposeExcelCell(cell, worksheet));
                if (cell != null && cell.IsMerged && cell.GetMergedRange().ColumnCount > 1)
                {
                    i += cell.GetMergedRange().ColumnCount - 1;
                }
            }
            return(result);
        }
        public override List <Cell> GetCells(int rowIndex, int maxColEnd = IAdapter.MaxColumnsCount)
        {
            List <Cell> result = new List <Cell>();

            Aspose.Cells.Row  row       = worksheet.Cells.Rows[rowIndex];
            Aspose.Cells.Cell firstCell = row.FirstCell;
            Aspose.Cells.Cell lastCell  = row.LastCell;
            if (lastCell == null)
            {
                return(result);
            }

            for (int i = 0; i <= lastCell.Column; i++)
            {
                if (i >= maxColEnd)
                {
                    break;
                }
                Aspose.Cells.Cell cell = row.GetCellOrNull(i);
                result.Add(new AsposeExcelCell(cell, worksheet));
                if (cell != null && cell.IsMerged && cell.GetMergedRange().ColumnCount > 1)
                {
                    i += cell.GetMergedRange().ColumnCount - 1;
                }
            }

            /*
             * IEnumerator enumerator = worksheet.Cells.Rows[rowIndex].GetEnumerator();
             * int range_end = -1;
             * while (enumerator.MoveNext())
             * {
             *  Aspose.Cells.Cell cell = (Aspose.Cells.Cell)enumerator.Current;
             *  if (cell.Column < range_end)
             *  {
             *      index++;
             *      continue;
             *  }
             *
             *  result.Add(new AsposeExcelCell(cell));
             *
             *  if (cell.IsMerged)
             *  {
             *      int first = cell.GetMergedRange().FirstColumn;
             *      int count = cell.GetMergedRange().ColumnCount;
             *      range_end = first + count;
             *  }
             *  index++;
             * }
             */
            return(result);
        }