string strFileName = FileUpload1.FileName;
string imgpath = Server.MapPath("~/inputFile/");
FileUpload1.SaveAs(imgpath + strFileName);
try
{
string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + imgpath + "\\" + strFileName + ";" + "Extended Properties=Excel 8.0;";
OleDbConnection conn = new OleDbConnection(strConn);
OleDbDataAdapter oda = new OleDbDataAdapter("select * from [Sheet1$]", strConn);oda.Fill(ds);
oda.Update(ds);
GridView1.DataSource = ds.Tables[0].DefaultView;
GridView1.DataBind();
}
catch (Exception ex)
{
Response.Write(ex.ToString());
}
dataset读取excel中的数据到打dataset中
最新推荐文章于 2023-12-04 15:21:30 发布