最新下载
热门教程
- 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的名字
相关文章
- TPLink TLWR847N 51~53 无线路由器IP带宽控制功能分配带宽 09-03
- MuleRun怎样生成招聘筛选标准 09-03
- Premiere如何制作胶片式滑动特效 09-03
- 如何关闭360安全卫士的文档保护 09-03
- TPLink TLWR847N 51~53 无线路由器控制小孩上网方法 09-03
- 初探Delphi中的插件编程实用指南 09-03