excel导入数据库  select * from [sheet1$]读入dataset 然后循环插入excel第一行为该excel文档的标题 ,重第二行开始才是内容,怎样才能只重第二行读起写入dataset?

解决方案 »

  1.   

    for (int i = 2; i <= 30; i++) //第一行为标题,不读取
            {
                for (int j = 1; j <= 20; j++)//列
                {
                    Range r = (Range)mySheet.Cells[i, j];
                }
           }
      

  2.   

    where *** <> ***标题肯定有和数据不一样的地方,用where过滤一下。
      

  3.   

    select * from [sheet1$] where id not in (select top 1 from [sheet1$] order by id)order by id
      

  4.   

    string ConnString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\MyExcel.xls;Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=1\";""HDR=Yes;" 表示第一行是标题行, 不是数据。"HDR=No;" 则表示从第一行开始就是数据。 
      

  5.   

    http://www.connectionstrings.com/?carrier=excel
      

  6.   

    select * from [sheet1$]
    这条语句默认就是把第一行当作列名,第二行开始才是内容
      

  7.   

    the string needs to be escaped using your language specific escape syntax.
    c#, c++   \"
    VB6, VBScript   ""
    xml (web.config etc)   &quot;
    or maybe use a single quota '.  
    "HDR=Yes;" indicates that the first row contains columnnames, not data. "HDR=No;" indicates the opposite.  
    "IMEX=1;" tells the driver to always read "intermixed" (numbers, dates, strings etc) data columns as text. Note that this option might affect excel sheet write access negative.  
    楼上的强。
      

  8.   

     string strConn = "Provider=Microsoft.Jet.Oledb.4.0;Data Source=" + fileurl + ";Extended Properties='Excel 8.0;HDR=Yes;IMEX=1;'"; 把连接字符串改后 select * from [sheet1$]获得 datatable for (int i = 0; i < tab.Rows.Count; i++)
      {
    tab.Rows[i]["name"].ToString();}错误:name不属于datatable ?????
      

  9.   

    for (int i = 0; i < tab.Rows.Count; i++) 

      tab.Rows[i][0].ToString(); 
    }
      

  10.   

    读到dataset 后 再把datatable  第一行 给删除
    没必要  只从第2行读 这样效果一样
      

  11.   


    默认就从第二行读的如果想把Excel表里的第一行的数据也写入加个 HDR=No
    string mystring = "Provider = Microsoft.Jet.OLEDB.4.0 ; Data Source = '" + fPath + "';Extended Properties='Excel 8.0;HDR=No;IMEX=1'";