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();  

Stop loading page load for few seconds using JavaScript


Add below JavaScript function under head tag of your .aspx page.
 <script type="text/javascript">
  
 function DelayAlert()
  
 {
  
 alert("Page will load after 30 seconds");
  
 }
  
 function DelayPageLoad()
  
 {
  
 setTimeout("DelayAlert()", 30000);
  
 }
  
 </script>
  
You can call above function from body onload like below,

 <body onload="DelayPageLoad">
  
 //page content goes here...
  
 </body>