目的EXCEL=>数据库,用户能马上看到上传内容.设想让用户上传EXCEL,显示到gridview中,可以修改数据,最后导入SQLSERVER.
但Gridview的内容怎样导入到数据库?Gridview的遍厉不知怎么写法.或者先EXCEL导入到数据库,再gridview显示给用户看?

解决方案 »

  1.   

    using System.Data.OleDb;//把xls读到grideView String PhysicalPath="";//物理地址
    string mystring = "Provider = Microsoft.Jet.OLEDB.4.0 ; Data Source = '" + PhysicalPath + "';Extended Properties=Excel 8.0";
                    OleDbConnection cnnxls = new OleDbConnection(mystring);
                    OleDbDataAdapter myDa = new OleDbDataAdapter("select * from [Sheet1$]", cnnxls);
                    DataSet Ds = new DataSet();
                    myDa.Fill(Ds, "Sheet1");
                    this.gvStudent.DataSource = Ds.Tables["Sheet1"];
                    this.gvStudent.DataBind();从gridView写到数据库就比较容易了,自己搞定吧
      

  2.   

    用rovecall方法读Excel, 前提还要注意写Excel要调用用标准的Office-Com组件, 不能用流的方式生成Excel:
    http://blog.csdn.net/ChengKing/category/292667.aspx