コード例 #1
0
ファイル: Importer.cs プロジェクト: zencodeguy/ExcelImporter
        public ImportResult ReadAll()
        {
            var result = new ImportResult();

            using (this.s = File.Open(this.pathAndFileName, FileMode.Open, FileAccess.Read))
            {
                this.r = CreateDataReader(s, this.importDefinition.FileType);

                this.fieldCount = this.r.FieldCount;

                if (this.importDefinition.HeaderRow)
                {
                    this.r.Read();
                }

                ImportedRow row = this.ReadRow();
                do
                {
                    result.Rows.Add(row);
                    row = this.ReadRow();
                } while (row != null);
            }

            return(result);
        }
コード例 #2
0
ファイル: Importer.cs プロジェクト: zencodeguy/ExcelImporter
        public ImportedRow ReadRow()
        {
            var r = new ImportedRow();

            if (this.r.Read())
            {
                this.currentRow++;
                var o = new string[this.fieldCount];
                for (var i = 0; i < this.fieldCount; i++)
                {
                    if (!this.r.IsDBNull(i))
                    {
                        o[i] = this.r.GetValue(i).ToString();
                    }
                }

                return(new ImportedRow(this.currentRow, o, this.importDefinition));
            }
            else
            {
                return(null);
            }
        }