试试:
Dim sConnectionString As String = "Driver={Microsoft Visual FoxPro Driver};SourceType=DBF;SourceDB=e:\;Exclusive=No" 
 
Dim objConn As New OleDbConnection(sConnectionString)
objConn.Open()
 
Dim objCmdSelect As New OleDbCommand("SELECT * FROM gck.dbf", objConn)
Dim objAdapter1 As New OleDbDataAdapter()
objAdapter1.SelectCommand = objCmdSelect
Dim objDataset1 As New DataSet()
objAdapter1.Fill(objDataset1, "gck")
objConn.Close()

解决方案 »

  1.   

    可以应用Microsoft Excel 9.0 class library然后和你在VB里一样操作Excel就行了。注意命名空间是Excel.Excel.Application excelApp= new Excel.Application();___________________________________
    too simple,sometimes naive :()
    ___________________________________
      

  2.   

    打错,是“引用”
    ___________________________________
    too simple,sometimes naive :()
    ___________________________________
      

  3.   

    nerk:
      很感谢你的回复,我用你的方法进行了尝试,还是不行
      碰到的问题是在
      Excel.Application excelApp= new Excel.Application();
      之后,没有办法实现
      excelApp.Workbooks.Open("e:\\gck.dbf");
      说是
      “重载“Open”方法未获取“1”参数”
      我看过workbooks.open的方法,需要很多的参数,但除了第一个是必须外,其它是可选的。但同样是workbooks.open的方法,在vb.net中就可以很好解决
    Dim xlApp As Excel.Application
    mFileName = "e:\gck.dbf"   
    Set xlApp = CreateObject("Excel.Application")
    xlApp.Workbooks.Open mFileName
    就可以了,不知道为什么?  另外
      using Excel;
      会造成
     ““Application”是不明确的引用”错误
      在vb.net中不用using Excel;也可以成功。
      

  4.   

    lixigang:
     感谢你提供的方法,但很都时候是在excel中提取零散的单元数据,而且excel文件(不是用excel可以打开的dbf文件)并没有数据库关系,不能用SQL语句
      

  5.   

    菜单: -> 项目 -> 添加引用
          -> COM -> Microsoft Excel 10.0 Object Library (双击) -> 确定C# code:
     Excel.ApplicationClass xx = new Excel.ApplicationClass();
      

  6.   

    其他参数用: System.Reflection.Missing.Value
    Excel.ApplicationClass xx = new Excel.ApplicationClass();
    xx.Visible = true;
    xx.Workbooks.Open (@"e:\test.xls",System.Reflection.Missing.Value,System.Reflection.Missing.Value,System.Reflection.Missing.Value,System.Reflection.Missing.Value,System.Reflection.Missing.Value,System.Reflection.Missing.Value,System.Reflection.Missing.Value,System.Reflection.Missing.Value,System.Reflection.Missing.Value,System.Reflection.Missing.Value,System.Reflection.Missing.Value,System.Reflection.Missing.Value,System.Reflection.Missing.Value,System.Reflection.Missing.Value);
      

  7.   

    同意小干部的,不过最好用9。0的,10.0的不太好用,我只好用的9.0。然后用range对象,就可以读取或者写入单元格数据了,
      

  8.   

    各位兄弟:读取EXCEL数据是有的麻烦,经过研究,已搞掂,C#的代码如下,至于写数据则较简单:
    Excel.ApplicationClass excel=new Excel .ApplicationClass ();
    excel.Workbooks .Add(path);//打开麻烦,增加一个较好处理
    Excel.Worksheet worksheet=(Excel.Worksheetexcel.Worksheets.get_Item (1);
    for(int i=1;i<=row;i++)
    {
    Excel.Range r=worksheet.get_Range ("A"+i.ToString (),"A"+i.ToString ());
    r.Select ();
    labcellname.Text =excel.ActiveCell.Text .ToString ().Trim ();
    Application.DoEvents ();
    labnum.Text =i.ToString ();
    Application.DoEvents ();
    }
    excel.Quit ();
      

  9.   

    各位:
        我还是不能成功啊!!
        在
        Excel.Application excelApp= new Excel.Application();
        之后,不能
        Excel.Workbooks excelworkbook=new excelApp.Workbooks();
        excelworkbook不能被引用    我这样写是类比了vb的写法,是不是这样就不行,一定要用
        lhxiangbird(freeboy)和zyongcai所说的range对象    但我用zyongcai提供的方法
        Excel.Worksheet worksheet=Excel.Worksheetexcel.Worksheets.get_Item (1);
        出错
     类型或命名空间名称“Worksheetexcel”在类或命名空间“Excel”中不存在(是否缺少程序集引用?)
    why???
      

  10.   

    Excel.Worksheet worksheet=(Excel.Worksheet)excel.Worksheets.get_Item (1);