看这里
http://dev.csdn.net/Develop/article/15/15544.shtm

解决方案 »

  1.   

    OleDbConnection myConnection = new OleDbConnection(); 
    myConnection.ConnectionString =" Provider=Microsoft.Jet.OLEDB.4.0;"  
               +"Data Source=Excel数据文件;Extended Properties=Excel 8.0;"; 
    myConnection.Open(); 
    OleDbCommand myCommand = myConnection.CreateCommand(); 
    myCommand.CommandText = "select * from [sheet1$]"; 
    OleDbDataAdapter myAdapter = new OleDbDataAdapter(); 
    myAdapter.SelectCommand = myCommand; 
    DataSet mySet = new DataSet(); 
    myAdapter.Fill(mySet);
      

  2.   

    //我在网上找的;
    public string [] GetSheetNameList( string excelFilePath , string[] colList )
    {
        Excel.Application myExcel=new Excel.Application ( ) ;
        try{
            object oMissing = System.Reflection.Missing.Value ;        myExcel.Application.Workbooks.Open excelFilePath,oMissing,oMissing,oMissing,oMissing,oMissing,oMissing,oMissing,oMissing,oMissing,oMissing,oMissing,oMissing ) ; Excel.Workbook myBook = myExcel.Workbooks[1] ;
    int sheetNum = myBook.Worksheets.Count ;
    string [] col = null ;
    ArrayList totalName = new ArrayList();
    for( int i = 1 ; i <= sheetNum ; i ++ ){
           col = this.GetColumnsNameList( excelFilePath , i ) ;
       if( col==null || col.Length == 0 || col.Length != colList.Length )
    continue ;
       for( int j = 0 ; j < col.Length ; j ++ )
      {
    if( col[j].Trim() != colList[j].Trim() )
    continue ;
    }
    Excel.Worksheet xlsheet = (Excel.Worksheet)myBook.Worksheets[i] ;
    totalName.Add( xlsheet.Name ) ;
    }
    //===========2003.11.28=============
    string [] sheetName = new String[ totalName.Count ] ;

    for( int i = 0 ; i < totalName.Count  ; i ++  )
    {
    sheetName[i] = totalName[i].ToString().Trim();
    }
    myExcel.Application.Workbooks.Close( ) ;

                    Marshal.ReleaseComObject( myExcel ) ;
    return sheetName;
    }
    catch{
    Marshal.ReleaseComObject( myExcel ) ;
    return null ;
    }
    }