当前位置: 首页 > 图文教程 > 网络编程 > ASP.NET > asp.net下获取Excel所有的工作表名称

ASP.NET
细细品味ASP.NET(一)
细细品味ASP.NET(二)
细细品味ASP.NET(三)
细细品味ASP.NET(四)
细细品味ASP.NET(五)
用asp.net和xml做的新闻更新系统(1)
用asp.net和xml做的新闻更新系统(2)
用asp.net和xml做的新闻更新系统(3)
十天学会ASP.net(1)
十天学会ASP.net(2)
十天学会ASP.net(3)
十天学会ASP.net(4)
十天学会ASP.net(5)
十天学会ASP.net(6)
十天学会ASP.net(7)
十天学会ASP.net(8)
十天学会ASP.net(9)
十天学会ASP.net(10)
ASP.NET创建XML Web服务全接触(1)
ASP.NET创建XML Web服务全接触(2)

ASP.NET 中的 asp.net下获取Excel所有的工作表名称


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-13   浏览: 126 ::
收藏到网摘: n/a

.net 获取Excel所有工作表名称:
OleDbConnection oleConn = new OleDbConnection();
oleConn.ConnectionString = "Provider=Microsoft.Jet.Oledb.4.0;data source=D:\\Data.xls;Extended Properties=Excel 8.0;";
oleConn.Open();
DataTable dtOle = oleConn.GetSchema("Tables");
DataTableReader dtReader = new DataTableReader(dtOle);
while (dtReader.Read())
{
MessageBox.Show(dtReader["Table_Name"]);
}
dtReader = null;
dtOle = null;
oleConn.Close();
这是临时想到的一种方法,如有更方便的方法,也请留言告诉我一下。