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为实际路径

你可能感兴趣的:(asp.net)