最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
ASP.NET导出数据到Excel并输出
时间:2010-08-27 编辑:简简单单 来源:一聚教程网
asp教程.net导出数据到excel并输出
public void import(){
if (this.ddl_task.selectedvalue == "-1")
{
function.script.alert("请选择主题!");
return;
}
string savepath = server.mappath("sql\");
if(fileup1.hasfile)
{
excelengine excelengine = new excelengine();
iapplication application = excelengine.excel;
savepath += fileup1.filename;
fileup1.saveas(savepath);
iworkbook workbook = excelengine.excel.workbooks.open(savepath);
iworksheet sheet1 = workbook.worksheets[0];
for (int i = 0; i < sheet1.rows.length-1; i++)
{if (!ifexistinblacklist(sheet1.range["e" + convert.tostring((i + 2))].value2.tostring(), sheet1.range["f" + convert.tostring((i + 2))].value2.tostring() ))
{
using (oracleconnection connection = new oracleconnection(configurationmanager.connectionstrings["dvteconnectionstring"].tostring()))
{
string sql = " insert into dc_visituser(customerid,cust_name,cust_addr,addrcode,mobilephone,homephone,taskid)";
sql += " values('" + sheet1.range["a" + convert.tostring((i + 2))].value2 + "'";
sql += ",'" + sheet1.range["b" + convert.tostring((i + 2))].value2 + "'";
sql += ",'" + sheet1.range["c" + convert.tostring((i + 2))].value2 + "'";
sql += ",'" + sheet1.range["d" + convert.tostring((i + 2))].value2 + "'";
sql += ",'" + sheet1.range["e" + convert.tostring((i + 2))].value2 + "'";
sql += ",'" + sheet1.range["f" + convert.tostring((i + 2))].value2 + "'";
sql += "," + this.ddl_task.selectedvalue;
sql += ")";
oraclecommand command = new oraclecommand(sql, connection);
connection.open();
command.executenonquery();}
}
}excelengine.thrownotsavedondestroy = false;
excelengine.dispose();
this.bindgridview();
}
}
相关文章
- asp.net中导出excel数据的方法汇总 02-13
- asp.net将数据导出为Excel报表 12-20
- asp.net导出数据到excel方法 10-28
- C#复制数组的两种方式及效率比较解读 10-24
- ASP.NET Identity用法解析 10-24
- ASP.NET MVC使用Identity增删改查用户介绍 10-24