var file = Server.MapPath("file.xls");
var cs = string.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties=Excel 8.0;", file);
using(var conn = new OleDbConnection(cs))
{
using(var cmd = new OleDbCommand("SELECT * FROM [Sheet1$]", conn))
{
using(var adapter = new OleDbDataAdapter(cmd))
{
var table = new DataTable();
adapter.Fill(table);
grid.DataSource = table;
grid.DataBind();
}
}
}
Немає коментарів:
Дописати коментар