예제 #1
0
        internal static IEnumerable <ExcelRow> Read(ISheet sheet)
        {
            var actualRowIndex = 0;
            int maxColumn      = GetMaxColumn(sheet);
            int maxRow         = GetMaxRow(sheet);

            for (int rowIndex = 0; rowIndex <= maxRow; rowIndex++)
            {
                var row   = sheet.GetRow(rowIndex);
                var cells = new List <ExcelCell>();
                if (row == null || row.Cells.Count == 0)
                {
                    yield return(new ExcelRow(actualRowIndex++, cells));

                    continue;
                }
                int firstColumn         = row.FirstCellNum;
                int currentRowMaxColumn = Math.Min(row.LastCellNum - 1, maxColumn);
                for (int columnIndex = 0; columnIndex <= currentRowMaxColumn; columnIndex++)
                {
                    var cell        = row.GetCell(columnIndex);
                    var stringValue = ExcelUtility.GetCellStringValue(cell);
                    cells.Add(new ExcelCell(stringValue, columnIndex, rowIndex));
                }

                yield return(new ExcelRow(actualRowIndex++, cells));
            }
        }
예제 #2
0
        internal static IEnumerable <ExcelRow> Read(ISheet sheet)
        {
            var actualRowIndex  = 0;
            var filtrationIndex = 0;

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

                var cells = new List <ExcelCell>();


                for (int columnIndex = 0; columnIndex < row.LastCellNum; columnIndex++)
                {
                    var cell        = row.GetCell(columnIndex);
                    var stringValue = ExcelUtility.GetCellStringValue(cell);

                    if (stringValue == "")
                    {
                        filtrationIndex++;
                    }
                    else
                    {
                        filtrationIndex = 0;
                    }
                    if (filtrationIndex < 100)
                    {
                        cells.Add(new ExcelCell(stringValue, columnIndex, rowIndex));
                    }
                    else
                    {
                        filtrationIndex = 0;
                        break;
                    }
                }
                filtrationIndex = 0;
                yield return(new ExcelRow(actualRowIndex++, cells));
            }
        }
예제 #3
0
        internal static IEnumerable <ExcelRow> Read(ISheet sheet)
        {
            var actualRowIndex = 0;
            var maxColCount    = 0;

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

                var cells = new List <ExcelCell>();
                int contiuneBlankCount = 0;
                int columnIndex        = 0;
                for (; columnIndex < row.LastCellNum; columnIndex++)
                {
                    var cell        = row.GetCell(columnIndex);
                    var stringValue = ExcelUtility.GetCellStringValue(cell);
                    cells.Add(new ExcelCell(stringValue, columnIndex, rowIndex));
                    if (stringValue == "")
                    {
                        contiuneBlankCount++;
                    }
                    else
                    {
                        contiuneBlankCount = 0;
                    }
                    if (contiuneBlankCount > ExcelHelperCom.ContinueColBlankUpperLimit && columnIndex > maxColCount)
                    {
                        break;
                    }
                }
                if (columnIndex > maxColCount)
                {
                    maxColCount = columnIndex;
                }

                yield return(new ExcelRow(actualRowIndex++, cells));
            }
        }
예제 #4
0
        internal static IEnumerable <ExcelRow> Read(ISheet sheet)
        {
            var actualRowIndex = 0;

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

                var cells = row.Cells.Select(cell =>
                {
                    var stringValue = ExcelUtility.GetCellStringValue(cell);
                    return(new ExcelCell(stringValue, cell.ColumnIndex, cell.RowIndex, cell));
                });

                yield return(new ExcelRow(actualRowIndex++, cells));
            }
        }
예제 #5
0
 public override string GetCellValue(int row, int col)
 {
     return(ExcelUtility.GetCellStringValue(rawSheet.GetRow(row).GetCell(col)));
 }