最新下载
热门教程
- 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的名字
相关文章
- 荒原曙光银鬃怎么捕捉 10-14
- 崩坏因缘精灵阿斯维加斯强度如何 10-14
- 火环尼芙海姆位置在哪里 10-14
- 迷雾大陆机械师流派构筑指南-迷雾大陆机械师流派构筑参考 10-14
- 羊蹄山之魂是什么类型的游戏 羊蹄山之魂游戏类型介绍 10-14
- 洛伊的移动要塞翁古拉强度说明 10-14