最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
asp.net C# 读取Excel数据代码
时间:2022-06-25 05:06:33 编辑:袖梨 来源:一聚教程网
asp教程.net c# 读取excel数据代码
public dataset exceltods(string path)
{
string con = "provider=microsoft.jet.oledb.4.0;data source="+"e:collegemisupexcel" + fileupload1.filename+";extended properties='excel 8.0;imex=1'";
oledbconnection olecon = new oledbconnection(con);
oledbdataadapter oleda = new oledbdataadapter("select * from [sheet1$]", con);//sheet1是sheet的名字
string strexcel = "";
oledbdataadapter mycommand = null;
dataset ds = null;
//从excel的一个工作表中导入数据到数据库教程中
strexcel = "select 门牌号,用户名,用户人口数目,用户住房面积,用户取暖面积,用户电话,用户工作单位,用户数据类型 from [sheet1$]";
try
{
mycommand = new oledbdataadapter(strexcel, strconn);
ds = new dataset();
mycommand.fill(ds, "table1");
}
catch(exception e)
{
conn.close();
mycommand.dispose();
}
return ds;
}
//sheet1是sheet的名字
相关文章
- mcjs网页版即点即玩-mcjs极速秒玩入口 10-23
- 超星学习通网页版登录-超星学习通官网入口 10-23
- poki免费游戏大全-poki免费游戏在线畅玩入口 10-23
- mc.js官方在线入口 10-23
- 海角haijiao社区2025全新网址一键直达-海角社区最新官方入口地址 10-23
- 王者荣耀世界体力上限与恢复方法详解 王者荣耀世界体力机制全面解析 10-20