string StrCon;
        StrCon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source" + Server.MapPath("ExcelFile/20120714164403943.xls") + ";Extended Properties= 'Excel 8.0;HDR=YES;IMEX=1';";
        OleDbConnection conn = new OleDbConnection(StrCon);
        OleDbDataAdapter myda = new OleDbDataAdapter("select * from[Data$]", StrCon);
        DataSet myds = new DataSet();
        myda.Fill(myds);
        GVRepairReport.DataSource = myds;
        GVRepairReport.DataBind();
老是找不到可安装的ISAM
各位大姐姐大哥哥们帮帮忙

解决方案 »

  1.   

    本帖最后由 net_lover 于 2012-07-14 17:31:23 编辑
      

  2.   

    粘贴个我现在用的给你看下
      string mingchen = filename;
            string filePath = Server.MapPath("~/UploadFile/" + wenjia + "/")+filename;//路径         string strCon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filePath + ";Extended Properties='Excel 8.0;HDR=YES;IMEX=1'";
            OleDbConnection ExcelConn = new OleDbConnection(strCon);
            try
            {
                string strCom = string.Format("SELECT * FROM [Sheet1$]");
                ExcelConn.Open();
                OleDbDataAdapter myCommand = new OleDbDataAdapter(strCom, ExcelConn);
                DataSet ds = new DataSet();
                myCommand.Fill(ds, "[Sheet1$]");
                ExcelConn.Close();
                return ds;
            }
            catch (Exception ex)
            {
                ExcelConn.Close();
                return null;
            }