好湿?好紧?好多水好爽自慰,久久久噜久噜久久综合,成人做爰A片免费看黄冈,机机对机机30分钟无遮挡

主頁 > 知識庫 > asp.net讀取excel中的數(shù)據(jù)并綁定在gridview

asp.net讀取excel中的數(shù)據(jù)并綁定在gridview

熱門標(biāo)簽:電銷機(jī)器人 數(shù)據(jù) 地圖標(biāo)注多少錢一張 ai電銷機(jī)器人對貸款有幫助嗎 宿遷智能外呼系統(tǒng)排名 廣州銷售外呼系統(tǒng)定制 怎樣給陜西地圖標(biāo)注顏色 400電話辦理信任翰諾科技 云狐人工智能電話機(jī)器人 福州人工智能電銷機(jī)器人加盟
前臺label,DropDownList,gridview控件

aspx.cs核心代碼:
復(fù)制代碼 代碼如下:

using System.Data.OleDb;//需要引入命名
public void Excel_Click(object sender, EventArgs e)
{
if (this.AttachmentFile.Value == "" this.Label1.Text == "" DropDownList2.SelectedValue == "")
{
Response.Write("script>window.alert('請選擇要導(dǎo)入的文件')/script>");
}
if (this.AttachmentFile.Value != "" this.DropDownList2.SelectedValue == "")
{
HttpFileCollection files = HttpContext.Current.Request.Files;
HttpPostedFile postedFile = files[0];
fileName = System.IO.Path.GetFileName(postedFile.FileName);
if (fileName != "")
{
postedFile.SaveAs("\\\\localhost\\文件夾\\" + fileName);
}
string strConn;
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + "\\\\localhost\\文件夾\\" + fileName + ";Extended Properties=Excel 8.0;";//this.AttachmentFile.Value.ToString()
OleDbConnection conn = new OleDbConnection(strConn);
conn.Open();
DataTable sheetNames = conn.GetOleDbSchemaTable(System.Data.OleDb.OleDbSchemaGuid.Tables, new object[] { null, null, null, "TABLE" });
foreach (DataRow dr in sheetNames.Rows)
{
DropDownList2.Items.Add(dr[2].ToString());
}
this.Label1.Text = "\\\\localhost\\文件夾\\" + fileName;//this.AttachmentFile.Value.ToString();
conn.Close();
}
if (this.Label1.Text.ToString() != "" this.DropDownList2.SelectedValue != "")// this.DropDownList1.SelectedValue.ToString() != "全部"
{

//綁定到gridview
GridView1.DataSource = createDataSource(DropDownList2.SelectedValue.ToString(), this.Label1.Text.ToString());//, this.DropDownList1.SelectedValue.ToString()
GridView1.DataBind();


}


}
//以Excel為數(shù)據(jù)源獲取數(shù)據(jù)集
private DataSet createDataSource(string select, string lable)

{
string strCon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + lable + ";Extended Properties=Excel 8.0;";
string strsql = "select 登記號碼,姓名,日期,簽到時(shí)間,簽退時(shí)間,部門 from [" + select + "] order by 部門,日期,姓名";//excel表格的字段
OleDbConnection conn = new OleDbConnection(strCon);
OleDbDataAdapter da = new OleDbDataAdapter(strsql, conn);
try
{
conn.Open();
DataSet ds = new DataSet();
da.Fill(ds);
conn.Close();
return ds;
}
catch (Exception e)
{
Response.Write("script>window.alert('沒有數(shù)據(jù),或者" + e.Message + "')/script>");
return null;
}
}

以上是插入07以前版本excel

如果07版本以后只需要做小小修改
復(fù)制代碼 代碼如下:

string strCon = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + lable + ";Extended Properties=Excel 12.0;";
您可能感興趣的文章:
  • asp.net gridview代碼綁定
  • asp.net ListView 數(shù)據(jù)綁定
  • asp.net中將數(shù)據(jù)庫綁定到DataList控件的實(shí)現(xiàn)方法與實(shí)例代碼
  • asp.net中綁定TextBox回車事件的解決方法
  • asp.net中ListBox 綁定多個(gè)選項(xiàng)為選中及刪除實(shí)現(xiàn)方法
  • ASP.NET中ListView(列表視圖)的使用前臺綁定附源碼
  • asp.net數(shù)據(jù)綁定DataBind使用方法
  • Asp.net中的數(shù)據(jù)綁定Eval和Bind應(yīng)用示例
  • ASP.NET MVC數(shù)組模型綁定詳解

標(biāo)簽:焦作 大興安嶺 綿陽 曲靖 延安 新疆 黃南 宜春

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《asp.net讀取excel中的數(shù)據(jù)并綁定在gridview》,本文關(guān)鍵詞  asp.net,讀取,excel,中的,數(shù)據(jù),;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《asp.net讀取excel中的數(shù)據(jù)并綁定在gridview》相關(guān)的同類信息!
  • 本頁收集關(guān)于asp.net讀取excel中的數(shù)據(jù)并綁定在gridview的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    主站蜘蛛池模板: 亚洲做受???高潮深喉| spyzwc撒尿| 女尊nph嗯好大轻点疼| 久久国产精品嫩草影院的推荐理由| 李采谭被躁120分钟视频播放| 91天堂一区二区| 久久久精品欧美AV无码看动漫 | 香港150部性三级| 三级黄色片免费观看| 黄色xxxx| hh99me福利毛片在线看| 一起草cad免费看| 欧美97色伦欧美一区二区日韩 | 91最新地域网名| 局长揉着秘书的双乳H文电影| 男男大尺度做哭受污文| 受虐狂性兴奋调教| 天天天天做夜夜夜夜| 500短篇乱婬小说| 婷婷久久五月色综合小说| 欧美美女激情| 欧美zozo人与禽交| 男人日母鸡| 免费黄色软件| 夏尔是不是被轮了| jyzzjyzz国产免费观看| 精品久久久久天堂漫画无码AV| 巜商务旅行戴帽子HD中字| 午夜激爽毛片在线看| 岳的好紧好浪| 国产精品久久久久久久久久直| 雄y体育教练高h肌肉猛男| 轻点啊啊| 国产操视频| 手机看片1024欧美一级| 国产一级淫片a免费播放口| 久久精品人妻| 同桌上课摸的我出水| 露水的夜| 伊人色在线| 美脚の诱脚舐め脚|