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))
{
conn.Open();
var table = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
var sheets = table.Rows.Cast().Select(x => x["TABLE_NAME"]).ToList();
grid.DataSource = sheets;
grid.DataBind();
}
Немає коментарів:
Дописати коментар