日期:2014-05-18 浏览次数:21179 次
/// <summary> /// 获取EXCEL的表 表名字列 /// </summary> /// <param name="p_ExcelFile">Excel文件</param> /// <returns>数据表</returns> public static DataTable GetExcelTableName(string p_ExcelFile) { try { if (System.IO.File.Exists(p_ExcelFile)) { OleDbConnection _ExcelConn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties=\"Excel 8.0\";Data Source=" + p_ExcelFile + ";Extended Properties=\"Excel 8.0;HDR=YES;IMEX=1\""); _ExcelConn.Open(); DataTable _Table = _ExcelConn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[] { null, null, null, "Table" }); _ExcelConn.Close(); return _Table; } return null; } catch { return null; } }