c# 获取excel所有工作表

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();

你可能感兴趣的:(c# 获取excel所有工作表)