asp.net循环读取excel工作表(sheet)名称

asp.net循环读取excel工作表(sheet)名称
      OleDbConnection objConn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + path + ";Extended Properties=\"Excel 8.0;imex=1;hdr=no\";");
objConn.Open();
System.Data.DataTable dt = null;
dt = objConn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
String[] excelSheets = new String[dt.Rows.Count];
int i = 0;
foreach (DataRow row in dt.Rows)
{
Response.Write(row["TABLE_NAME"].ToString());
i++;
}
if (objConn != null)
{
objConn.Close();
objConn.Dispose();
}
if (dt != null)
{
dt.Dispose();
}

注:path为实际路径

posted on 2012-01-05 17:45  tianyaxiang  阅读(2346)  评论(0编辑  收藏  举报

导航