62,272
社区成员
发帖
与我相关
我的任务
分享
public static string getFirsttableName(string excelFilepath)
{
string tableName = null;
if (File.Exists(excelFilepath))
{
using (OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet." +
"OLEDB.4.0;Extended Properties=\"Excel 8.0\";Data Source=" + excelFilepath))
{
conn.Open();
DataTable dt = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
tableName = dt.Rows[0][2].ToString().Trim();
}
}
return tableName;
}