示例#1
0
        public DataSet ReadExcel(FileInfo _file)
        {
            DataSet dataSet = null;

            using (var stream = File.Open(_file.FullName, FileMode.Open, FileAccess.Read))
            {
                using (var excelReader = ExcelReaderFactory.CreateReader(stream))
                {
                    string name = _file.Name.Split('.')[0];
                    dataSet = excelReader.AsDataSet();
                    if (!ExcelData.ContainsKey(name))
                    {
                        ExcelData.Add(name, dataSet);
                    }
                    excelReader.Close();
                }

                stream.Close();
            }

            return(dataSet);
        }