C# 获得EXCEL工作表名

发布时间:2009年11月13日      浏览次数:1095 次
string strPath="EXCEL的路径";
OleDbConnection ExcelConnection = new OleDbConnection(@"Provider=Microsoft.Jet.Oledb.4.0;Data Source=" + strPath + ";Extended Properties='Excel 8.0;HDR=Yes;IMEX=1;'");
OleDbCommand ExcelCommand = new OleDbCommand();
ExcelCommand.Connection = ExcelConnection;
OleDbDataAdapter ExcelAdapter = new OleDbDataAdapter(ExcelCommand);
ExcelConnection.Open();
DataTable ExcelSheets = ExcelConnection.GetOleDbSchemaTable(System.Data.OleDb.OleDbSchemaGuid.Tables, new object[] { null, null, null, "TABLE" });
ExcelConnection.Close();
return ExcelSheets;
免责声明:本站相关技术文章信息部分来自网络,目的主要是传播更多信息,如果您认为本站的某些信息侵犯了您的版权,请与我们联系,我们会即时妥善的处理,谢谢合作!