OleDbConnection ExcelConnection = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+(new Comm.DoWeb()).GetFilePath(filePath.TempFilePath + filename)+";Extended Properties=Excel 8.0;");
OleDbCommand ExcelCommand = new OleDbCommand();
ExcelCommand.Connection = ExcelConnection;
OleDbDataAdapter ExcelAdapter = new OleDbDataAdapter(ExcelCommand);
ExcelConnection.Open();
//读取Excel表名
DataTable ExcelSheets = ExcelConnection.GetOleDbSchemaTable(System.Data.OleDb.OleDbSchemaGuid.Tables,new object[] {null, null, null, "TABLE"});
for(int i=0;i<ExcelSheets.Rows.Count;i++)
{
string tableName = "["+ExcelSheets.Rows[i]["TABLE_NAME"].ToString()+"]";
DataTable myTable=new DataTable();
ExcelCommand.CommandText = @"SELECT * FROM "+SpreadSheetName;
ExcelAdapter.Fill(myTable);
ExcelConnection.Close();
}