コード例 #1
0
        public string[] GetRow(int c)
        {
            if (c >= rowCount)
            {
                return(null);
            }
            if (data[c, 0] == null)
            {
                while (c != currentRow)
                {
                    if (++currentRow >= rowCount)
                    {
                        currentRow = 0;
                        enumerator = enumerable.GetEnumerator();
#if DEBUG
                        if (enumerator.Current[0].ToString() != table.Rows[0].ToString())
                        {
                            throw new Exception("cant go to begin");
                        }
#endif
                    }
                    else
                    {
                        enumerator.MoveNext();
                    }
                    if (data[currentRow, 0] == null)
                    {
                        SetDataByDataRow(currentRow, enumerator.Current);
                    }
                }
            }
            return(GetDataStringArr(c));
        }
コード例 #2
0
 public EDRExcelWrapper(string str)
 {
     filename = str;
     // before open file because also opens file
     CalcTableSize();
     if (!File.Exists(str))
     {
         throw new FileNotFoundException(str);
     }
     try
     {
         stream     = File.Open(filename, FileMode.Open, FileAccess.Read);
         reader     = ExcelReaderFactory.CreateReader(stream);
         dataset    = reader.AsDataSet();
         table      = dataset.Tables[0];
         enumerable = table.AsEnumerable();
         enumerator = enumerable.GetEnumerator();
         enumerator.MoveNext();
     }
     finally
     {
         stream.Close();
         stream = null;
         reader = null;
     }
     currentRow = 0;
     data       = new string[rowCount, colCount];
 }