Posted By

krisdb on 03/22/10


Tagged

c-sharp


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

digiteyes


Excel to DataTable


 / Published in: C#
 

  1. var connectionString = string.Format("Provider=Microsoft.Jet.OLEDB.4.0; data source={0}; Extended Properties=Excel 8.0;", file);
  2.  
  3. var adapter = new OleDbDataAdapter("SELECT * FROM [Table1$]", connectionString);
  4. var ds = new DataSet();
  5.  
  6. adapter.Fill(ds, "Name");
  7.  
  8. DataTable dt = ds.Tables["Name"];

Report this snippet  

You need to login to post a comment.