c# 獲取excel所有工作表

weixin_33894992發表於2016-06-28

var filePath="f:\xx.xlsx"

string connStr = "Provider=Microsoft.Ace.OleDb.12.0;" + "data source=" + filePath + ";Extended Properties='Excel 12.0; HDR=Yes; IMEX=1'";

OleDbConnection myConn = new OleDbConnection(connStr);

myConn.Open();

DataTable table = myConn.GetOleDbSchemaTable(System.Data.OleDb.OleDbSchemaGuid.Tables, null); 

var tableName = table.Rows[0]["Table_Name"].ToString();

相關文章