米雪飘飞吧 关注:558贴子:2,724
  • 2回复贴,共1

「米de程序狗」Visual C#读取Excel表格中的数据

只看楼主收藏回复

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();
}


1楼2015-11-14 15:30回复
    这个是获取DataSet中行列的值;
    ds.Tables[0].Rows[0][0].ToString()


    2楼2015-11-14 15:31
    回复
      新年快乐


      IP属地:浙江来自Android客户端3楼2016-02-17 07:55
      回复