我现在从Excel中读取数据时,由于数据不规则导致读入的数据出现问题,具体情况如下。
     在程序中用Ole方法读取Excel。比如
第一行(字段名,字符型): A  B  C
第二行(类型,字符型):   T1 T2 T3
其他行(数据,数值型):   1  2  3结果,第二行无法获取

解决方案 »

  1.   

    public DataSet EmportExcel(string fileName, string sheetName)
            {
                DataSet dataSet = new DataSet();            string strConnExcels = "Provider=Microsoft.Jet.Oledb.4.0;Data Source=" + fileName + ";Extended Properties='ExceL 8.0;IMEX=1;HDR=no';";
                OleDbConnection connExcels = new OleDbConnection(strConnExcels);
                connExcels.Open();            string strExcel = "SELECT * FROM [" + sheetName + "$]";            try
                { 
                    OleDbDataAdapter oleDbDataAdapter = new OleDbDataAdapter(strExcel, connExcels);
                    oleDbDataAdapter.Fill(dataSet);                connExcels.Close();
                    connExcels.Dispose();
                }
                catch (OleDbException ex)
                {
                    throw ex;
                }            return dataSet;
            }
    参考……
      

  2.   

    第二行应该是用typeof()的方法的吧
      

  3.   

    试过了,提示“没有可安装的IMEX” 什么玩艺,不知道什么意思,是不是我的安装的问题呀。