Posts

Showing posts with the label excel

Read from excel and insert into data table in c#

using System.Data.OleDb; using System.IO;   private DataTable ReadExcelToTable ( string path ) {         //Connection String         string extenstion = Path.GetExtension(path);         string connstring = "" ;         if (extenstion == "xls" || extenstion == "XLS" )         {             connstring = "Provider=Microsoft.JET.OLEDB.4.0;Data Source=" + path + ";Extended Properties='Excel 8.0;HDR=NO;IMEX=1';" ;         }         else         {             connstring = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + ";Extended Properties='Excel 8.0;HDR=NO;IMEX=1';" ;         }         //connstring = "Provider=Microsoft.JET.OLEDB.4.0;Data Source=" + path + ";Extended Properties='Excel 8.0;HDR=NO...