Wednesday, April 27, 2011

ExcelDataReader to read excel

ExcelDataReader is a Lightweight library used for reading Microsoft Excel files in .NET.

This Dll will avoid lot of overhead which you may face during Excel operation in your .NET project.

First download the dll using the link, ExcelDataReader DLL Download

Then use below code,
FileStream stream = File.Open(filePath, FileMode.Open, FileAccess.Read);
  
 IExcelDataReader excelReader = ExcelReaderFactory.CreateBinaryReader(stream);
  
 IExcelDataReader excelReader = ExcelReaderFactory.CreateOpenXmlReader(stream);
  
 DataSet result = excelReader.AsDataSet();
  
 excelReader.IsFirstRowAsColumnNames = true;
  
 DataSet result = excelReader.AsDataSet();
  
 while (excelReader.Read())
 {
   //excelReader.GetInt32(0);
 }
 excelReader.Close();  

1 comment:

Naviya Nair said...

Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a .Net developer learn from .Net Core Training in Chennai. or learn thru .Net Core Training in Chennai. Nowadays Dot Net has tons of job opportunities on various vertical industry.
or Es6 Training in Chennai. Nowadays JavaScript has tons of job opportunities on various vertical industry.