比如:   
          excel文件内容如下:   
              001     张三         男         19   
            002     李四         女         20   
    
      
写入数据到一个表person中:   
    
      字段名:    ID   编号         姓名       性别     年龄   (ID为自增量)
                  1    001        张三         男       19   
                2   002        李四         女        20   
  

解决方案 »

  1.   

    http://blog.csdn.net/jiatong1981/archive/2008/02/26/2122768.aspx
      

  2.   

    对于一些excel的链接字串参数HDR=YES   ExcelSheet表的首行为字段名称 
    IMEX=1   将所有数据以文本形式读取  
      

  3.   

    参看http://topic.csdn.net/u/20080228/09/c60ef31d-4a59-47cf-a746-8b20a26e2ee6.html
      

  4.   

    到codeproject上查查吧,那里比较全的不过有个问题就是 进程上你的excel.exe是很难删除的!
      

  5.   

    OleDbConnection myConnection = new OleDbConnection();  myConnection.ConnectionString  ="Provider=Microsoft.Jet.Oledb.4.0;Data Source=" + FilePathAndName + ";Extended Properties='Excel 8.0;HDR=Yes;IMEX=1;'";    
    myConnection.Open();    
    OleDbCommand myCommand = myConnection.CreateCommand(); string strExecelSql(select * from sheet1);//第一行每列字符串可以作为表头进行查询,sheet名不要改。
    myCommand.CommandText = strExecelSql;
    OleDbDataAdapter myAdapter = new OleDbDataAdapter();     
    myAdapter.SelectCommand = myCommand;     
    DataSet mySet = new DataSet(); ...从dataset中读,插入数据库。