发布网友 发布时间:2022-04-21 22:58
共1个回答
热心网友 时间:2022-04-10 09:55
private DataSet CreateDataSource() { string strCon; strCon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("excel.xls") + "; Extended Properties=Excel 8.0;"; OleDbConnection olecon = new OleDbConnection(strCon); OleDbDataAdapter myda = new OleDbDataAdapter("SELECT * FROM [Sheet1$]", strCon); DataSet myds = new DataSet(); myda.Fill(myds); return myds; } protected void Button1_Click(object sender, EventArgs e) { GridView1.DataSource = CreateDataSource(); GridView1.DataBind(); }