Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

how read excel data in c#

string con =
  @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:	emp	est.xls;" + 
  @"Extended Properties='Excel 8.0;HDR=Yes;'";    
using(OleDbConnection connection = new OleDbConnection(con))
{
    connection.Open();
    OleDbCommand command = new OleDbCommand("select * from [Sheet1$]", connection); 
    using(OleDbDataReader dr = command.ExecuteReader())
    {
         while(dr.Read())
         {
             var row1Col0 = dr[0];
             Console.WriteLine(row1Col0);
         }
    }
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #read #excel #data
ADD COMMENT
Topic
Name
9+2 =