可以用string.Format("SELECT * FROM [{0}${1}]", sheetName, sheetRange); 的SQL来限定读取的table可以看下我之前写的一个oledb读excel的类,写了很久了,很多我自己都不记得了
http://user.qzone.qq.com/3183601/blog/1

解决方案 »

  1.   

    读取excel            string opnFileName = "D:\\dddd.xls";
                if (File.Exists(opnFileName) == false)
                {
                    return;
                }
                string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
                    + opnFileName + ";Extended Properties=\"Excel 8.0;HDR=YES;IMEX=1\"";
                OleDbConnection conn = new OleDbConnection(strConn);
                string strExcel = "";
                OleDbDataAdapter myCommand = null;
                DataSet ds = new DataSet();
                strExcel = "select * from [sheet1$]";
                try
                {
                    conn.Open();
                    myCommand = new OleDbDataAdapter(strExcel, strConn);
                    myCommand.Fill(ds, "dtSource");            }
                catch (Exception ex)
                {
                    MessageBox.Show("导入出错:" + ex, "错误信息");
                }
                finally
                {
                    conn.Close();
                    conn.Dispose();
                }
      

  2.   

    有没有不用OLEDB读取excel的方法,因为.net compact Framework不支持OLEDB。