Пример #1
0
 private async Task ReadAll()
 {
     do
     {
         int      rowNr    = 0;
         TypeInfo typeInfo = new TypeInfo(typeof(TOutput));
         while (ExcelDataReader.Read())
         {
             if (ExcelDataReader.VisibleState != "visible")
             {
                 continue;
             }
             if (HasSheetName && ExcelDataReader.Name != SheetName)
             {
                 continue;
             }
             rowNr++;
             if (HasRange && rowNr > Range.EndRowIfSet)
             {
                 break;
             }
             if (HasRange && rowNr < Range.StartRow)
             {
                 continue;
             }
             TOutput row = ParseDataRow(typeInfo);
             await Buffer.SendAsync(row);
         }
     } while (ExcelDataReader.NextResult());
 }
Пример #2
0
        protected override void ReadAll()
        {
            do
            {
                int rowNr = 0;

                while (ExcelDataReader.Read())
                {
                    if (ExcelDataReader.VisibleState != "visible")
                    {
                        continue;
                    }
                    if (HasSheetName && ExcelDataReader.Name != SheetName)
                    {
                        continue;
                    }
                    rowNr++;
                    if (HasRange && rowNr > Range.EndRowIfSet)
                    {
                        break;
                    }
                    if (HasRange && rowNr < Range.StartRow)
                    {
                        continue;
                    }
                    try
                    {
                        if (!HasNoHeader && !IsHeaderRead)
                        {
                            ParseHeader();
                        }
                        else
                        {
                            TOutput row = ParseDataRow();
                            if (row == null && IgnoreBlankRows)
                            {
                                continue;
                            }
                            else if (row == null && !IgnoreBlankRows)
                            {
                                break;
                            }
                            else if (row != null)
                            {
                                Buffer.SendAsync(row).Wait();
                                LogProgress();
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        if (!ErrorHandler.HasErrorBuffer)
                        {
                            throw e;
                        }
                        ErrorHandler.Send(e, $"File: {Uri} -- Sheet: {SheetName ?? ""} -- Row: {rowNr}");
                    }
                }
            } while (ExcelDataReader.NextResult());
        }