asp导出excel文件|asp可以导出到excel文件那么怎么将数据导出到指定的表中

asp导出excel文件|asp可以导出到excel文件那么怎么将数据导出到指定的表中的第1张示图

Ⅰ Asp如何生成excel文件

可以生成,最简单的是生成CSV<%dim conn,strconn strconn="driver={Microsoft Access driver (*.mdb)};dbq="&server.mappath("dataBase/mydatabase.mdb") '这里改为你的数据库地址set conn=server.CreateObject("adodb.connection") conn.Open strconn dim s,sql,filename,fs,myfile,x Set fs = server.CreateObject("scripting.filesystemobject") 成不同文件名的EXCEL文件,只需要更改excel.xls文件名filename = Server.MapPath("excel.xls")'–如果原来的EXCEL文件存在的话删除它 if fs.FileExists(filename) then fs.DeleteFile(filename) end if '–创建EXCEL文件 set myfile = fs.CreateTextFile(filename,true)strSql = "select * from tabList"Set rstData = DataToRsStatic(conn,strSql)if not rstData.EOF and not rstData.BOF then dim trLine,responsestr strLine = "序 号" & chr(9) & "姓 名" & chr(9) & "电 话" & chr(9) & "Q Q" & chr(9) & "邮 箱" & chr(9) & "地 址" & chr(9) & "生 日" & chr(9) & "备 注" '–将表的列名先写入EXCEL myfile.writeline strLine Do while Not rstData.EOF strLine="" strLine = rstData("fid") & chr(9) & rstData("fName")& chr(9) & rstData("fTel") & chr(9) & rstData("fQQ") & chr(9) & rstData("fEmail")& chr(9)&rstData("fAddress")& chr(9) &rstData("birthday")& chr(9) & rstData("fNote") & chr(9)& IfSendStr '括号改为你的数据库字段 myfile.writeline strLine rstData.MoveNext loop end if Response.Charset="utf-8"Response.Write "<br><br>生成EXCEL文件成功,点击<a href=""excel.xls"" target=""_blank"">下载</a>!"rstData.Close set rstData = nothingConn.CloseSet Conn = nothingFunction DataToRsStatic(Conn,strSql) Dim RsStatic Set DataToRsStatic = Nothing If Conn Is Nothing Then Exit Function End If Set RsStatic = CreateObject("ADODB.RecordSet") RsStatic.CursorLocation = 3 RsStatic.Open strSql,Conn,3,3 If Err.Number <> 0 Then Exit Function End If Set DataToRsStatic = RsStaticEnd Function%>

Ⅱ asp 导出excel表格

给你段代码:<%strconn = "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("数据库.mdb") set conn = server.createobject("adodb.connection") conn.open strconn %><HTML><HEAD><meta content="text/html; charset=gb2312" http-equiv="Content-Type"><TITLE>生成EXCEL文件</TITLE></HEAD><body><a href="?act=make">在线生成EXCEL</a> <a href="record.xls" target="_blank">下载</a><hr size=1 align=left width=300px><%if Request("act") = "" thenResponse.Write "生成EXCEL文件"elsedim rs,sql,filename,fs,myfile,xSet fs = server.CreateObject("scripting.filesystemobject")filename = Server.MapPath("record.xls")if fs.FileExists(filename) thenfs.DeleteFile(filename)end ifset myfile = fs.CreateTextFile(filename,true)Set rs = Server.CreateObject("ADODB.Recordset")sql = "select * from record worder by id desc"rs.Open sql,conn,1,1if rs.EOF and rs.BOF thenelsedim strLine,responsestrstrLine=""For each x in rs.fieldsstrLine = strLine & x.name & chr(9)Nextmyfile.writeline strLineDo while Not rs.EOFstrLine=""for each x in rs.FieldsstrLine = strLine & x.value & chr(9)nextmyfile.writeline strLiners.MoveNextloopend ifrs.Closeset rs = nothingEnd If%>

Ⅲ ASP怎么样生成EXCEL文件,谢谢

不能直接生成,可以生成CSV,使用EXCEL打开<%dim conn,strconn strconn="driver={Microsoft Access driver (*.mdb)};dbq="&server.mappath("dataBase/mydatabase.mdb") '这里改为你的数据库地址set conn=server.CreateObject("adodb.connection") conn.Open strconn dim s,sql,filename,fs,myfile,x Set fs = server.CreateObject("scripting.filesystemobject") 成不同文件名的EXCEL文件,只需要更改excel.xls文件名filename = Server.MapPath("excel.xls")'–如果原来的EXCEL文件存在的话删除它 if fs.FileExists(filename) then fs.DeleteFile(filename) end if '–创建EXCEL文件 set myfile = fs.CreateTextFile(filename,true)strSql = "select * from tabList"Set rstData = DataToRsStatic(conn,strSql)if not rstData.EOF and not rstData.BOF then dim trLine,responsestr strLine = "序 号" & chr(9) & "姓 名" & chr(9) & "电 话" & chr(9) & "Q Q" & chr(9) & "邮 箱" & chr(9) & "地 址" & chr(9) & "生 日" & chr(9) & "备 注" '–将表的列名先写入EXCEL myfile.writeline strLine Do while Not rstData.EOF strLine="" strLine = rstData("fid") & chr(9) & rstData("fName")& chr(9) & rstData("fTel") & chr(9) & rstData("fQQ") & chr(9) & rstData("fEmail")& chr(9)&rstData("fAddress")& chr(9) &rstData("birthday")& chr(9) & rstData("fNote") & chr(9)& IfSendStr '括号改为你的数据库字段 myfile.writeline strLine rstData.MoveNext loop end if Response.Charset="utf-8"Response.Write "<br><br>生成EXCEL文件成功,点击<a href=""excel.xls"" target=""_blank"">下载</a>!"rstData.Close set rstData = nothingConn.CloseSet Conn = nothingFunction DataToRsStatic(Conn,strSql) Dim RsStatic Set DataToRsStatic = Nothing If Conn Is Nothing Then Exit Function End If Set RsStatic = CreateObject("ADODB.RecordSet") RsStatic.CursorLocation = 3 RsStatic.Open strSql,Conn,3,3 If Err.Number <> 0 Then Exit Function End If Set DataToRsStatic = RsStaticEnd Function%>

Ⅳ ASP页面中怎么导出Excel文档

<%rs.open "select * from [table]",conn,1,1if not rs.eof thenset fso=server.createObject("scripting.fileSystemObject")filename=Server.MapPath("online.xls") if fso.FileExists(filename) then fso.DeleteFile(filename) end if set myfile = fso.CreateTextFile(filename,true)dim strLine,responsestrFor each x in rs.fields strLine= strLine & x.name & chr(9) Next myfile.writeline strLine Do while Not rs.EOFfor each x in rs.Fields strLine= strLine & x.value & chr(9) next myfile.writeline strLiners.MoveNext loopmyfile.writeline ()end ifrs.closeresponse.redirect "online.xls"%>

Ⅳ asp导出excel

在查询内容页前面加上以下语句就可以了: <%Response.ContentType = "application/msword"Response.AddHeader "Content-Disposition", "attachment;filename=data.xls"%>

Ⅵ asp代码实现access数据导出到excel文件

asp代码实现access数据导出到excel文件:一,下面是导出XLS格式%dimrefererreferer=Request.ServerVariables(HTTP_REFERER)DimCName,actionaction=request.Form(action)CName=../../Excel/dimdaytimedaytime=year(now())-month(now())-day(now())-hour(now())-Minute(now())daytime=year(now())年month(now())月day(now())日hour(now())时Setrs=Server.CreateObject(ADODB.Recordset)–从数据库中把你想放到EXCEL中的数据查出来sql=select*fromgbookorderbyiddescrs.Opensql,connifrs.EOFandrs.BOFthenresponse.writescriptalert(操作出错,下面是产生错误的可能原因:nn库里暂时没有数据,所以不能导出EXCEL文件!);location.href=referer;/scriptresponse.endelsedimfilename,fs,myfile,xSetfs=server.CreateObject(scripting.filesystemobject)–假设你想让生成的EXCEL文件做如下的存放filename=Server.MapPath(CNamedaytime.xls)–如果原来的EXCEL文件存在的话删除它iffs.FileExists(filename)thenfs.DeleteFile(filename)endif–创建EXCEL文件setmyfile=fs.CreateTextFile(filename,true)dimstrLine,responsestrstrLine=Foreachxinrs.fieldsstrLine=strLinex.namechr(9)Next–将表的列名先写入EXCELmyfile.writelinestrLineDowhileNotrs.EOFstrLine=foreachxinrs.FieldsstrLine=strLinex.valuechr(9)next–将表的数据写入EXCELmyfile.writelinestrLiners.MoveNextlooprs.Closesetrs=nothingconn.closesetconn=nothingsetmyfile=nothingSetfs=NothingResponse.WriteBRBRcenterb导出成功,请选择继续操作/b/centerResponse.Writebrresponse.Writetablewidth=90%cellspacing=1cellpadding=3align=centerResponse.Writetralign=centertdresponse.write(fontcolor=green/fontahref=CNameENames.xls下载/a)nbsp;nbsp;fontcolor=green/fontahref=referer返回/aResponse.Write/td/tr/tableendif%二,下面是导出CSV格式%dimrefererreferer=Request.ServerVariables(HTTP_REFERER)DimCName,actionaction=request.Form(action)CName=../../Excel/dimdaytimedaytime=year(now())-month(now())-day(now())-hour(now())-Minute(now())daytime=year(now())年month(now())月day(now())日hour(now())时Setrs=Server.CreateObject(ADODB.Recordset)–从数据库中把你想放到EXCEL中的数据查出来sql=select*fromgbookorderbyiddescrs.Opensql,connifrs.EOFandrs.BOFthenresponse.writescriptalert(操作出错,下面是产生错误的可能原因:nn库里暂时没有数据,所以不能导出EXCEL文件!);location.href=referer;/scriptresponse.endelseDimFs,ExcDimExcelstring,ExcelHead,Excelstr,Excelstr2DimScou_FileNamen,Scou_FieldListDimDest_FileName,Dest_FieldListDest_FileName=CNamedaytime.csvExcelstring=ExcelHead=识别号,主题类型,公司名称,姓名,性别,职位,城市省份,城市,公司地址,邮编,邮件,电话,传真,手机,公司网址,详细内容,IP地址,留言时间SetRs=Server.CreateObject(ADODB.Recordset)Sql=Select*FromgbookRs.OpenSql,Conn,1,3DoWhileNotRs.EofExcelstr=Rs(ID),Rs(zhutiname),Rs(gsname),Rs(gsname),Rs(sex),Rs(wei),Rs(Province),Rs(City),Rs(di),Rs(youbian),Rs(email),Rs(tel),Rs(fax),Rs(tel2),Rs(homeurl),Rs(body),Rs(ip),Rs(addtime)Excelstr2=Excelstr2Chr(13)ExcelstrRs.MovenextLoopExcelstring=ExcelHeadExcelstr2Rs.Close

Ⅶ 关于ASP生成导出excel文件的问题

直接用FSO导出为Excel。我把我写的一个范例给你参考下Set fs = server.CreateObject("scripting.filesystemobject") '–假设你想让生成的EXCEL文件做如下的存放 filename = Server.MapPath("Order_Data.xls") '–如果原来的EXCEL文件存在的话删除它 if fs.FileExists(filename) then fs.DeleteFile(filename) end if '–创建EXCEL文件 set myfile = fs.CreateTextFile(filename,true) strSql = "select 型号,未到货数量,单价,总价,订货日期,订单编号,交货期 from Bn_Excel "Set rstData =conn.execute(strSql)if not rstData.EOF and not rstData.BOF then dim trLine,responsestr strLine = "型号" & chr(9) & "数量" & chr(9) & "单价" & chr(9) & "总价" & chr(9) & "订货日期" & chr(9) & "订单编号" & chr(9) & "交货期" & chr(9)'–将表的列名先写入EXCEL myfile.writeline strLine Do while Not rstData.EOF strLine="" for each x in rstData.Fields strLine = strLine & x.value & chr(9) next myfile.writeline strLine rstData.MoveNext loop end if Response.Write "生成订单EXCEL文件成功,点击<a href=""Order_Data.xls"" target=""_blank"">订单下载</a>!"rstData.Close set rstData = nothing

Ⅷ 如何将ASP页面中的表格导出到Excel文件中

建议你直接从数据库里导出到EXCEL还简单些。

Ⅸ asp可以导出到excel文件,那么怎么将数据导出到指定的表中

只能先导出,然后复制到其他表

Ⅹ asp导出excel文件大家有什么简便点的操作方法

给页面前加这两句代码,按正常查询生成表格即可<%Response.ContentType = "application/excel"Response.AddHeader "Content-Disposition", "attachment;filename=""在线申请汇总表.xls""" %>

未经允许不得转载:山九号 » asp导出excel文件|asp可以导出到excel文件那么怎么将数据导出到指定的表中

赞 (0)