Read Excel to DataTable
Description: Read Excel to DataTable
Link: http://www.codekeep.net/snippets/9c43beed-1312-4ac2-b19c-c60e56c93c65.aspx
using System.Data.OleDb
.
.
.
string fileLocation = @"c:\temp\testfile.xls";
OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + fileLocation +";Extended Properties=\"Excel 8.0;HDR=YES\"");
OleDbDataAdapter da = new OleDbDataAdapter();
dt = new DataTable();
da.SelectCommand = new OleDbCommand("SELECT * FROM [Sheet1$]", conn);
da.Fill(dt); // We could be filling a DataSet too
.
.
.
conn.Dispose();
da.Dispose();
dt.Dispose();






