如何在.net中判断excel的sheet是否存在

来源: http://www.notetoday.cn/opennote/View?noteId=50

oledbconn1.ConnectionString = "provider=Microsoft.Jet.OLEDB.4.0;data source="+openFileDialog1.FileName+";Extended Properties=Excel 8.0;Persist Security Info=False";

oledbconn1.Open(); 

DataTable dt = oledbconn1.GetOleDbSchemaTable(OleDbSchemaGuid.Tables,new objec] {null, null, null, "TABLE"}); 

If(dt !=null && dt.Rows >0)
{
  DataRow[] dr = dt.Select("TABLE_NAME = '"+sheet名+"'");
if(dr == null || dr.Lenght = 0)
{
不包含
}
}

原文地址:https://www.cnblogs.com/eric812/p/2744099.html