日期:2014-05-17 浏览次数:21009 次
#region 导入Excel数据相关函数
/// <summary>
/// 根据文件名获得Excel的工作薄名称
/// </summary>
/// <param name="excelFileName"></param>
/// <returns></returns>
public static IList<string> GetExcelTablesName(string excelFileName)
{
using (OleDbConnection olbDbConn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source = " + excelFileName + ";Extended Properties = \"Excel 8.0;HDR=YES;IMEX=1;\""))
{
try
{
olbDbConn.Open();
DataTable ExcelTableNames = olbDbConn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[] { null, null, null, "TABLE" });
IList<string> tableList = new List<string>();