1.ASP+access 导åºExcel
2.asp代码实现access数据导出到excel文件
ASP+access 导åºExcel
ç»ä½ 个å°ä¾å
<!--#include file="conn.asp"-->
<%
Server.ScriptTimeOut=
response.ContentType ="application/vnd.ms-excel"
response.addheader "Content-Disposition",导l导"attachment;filename=订åä¿¡æ¯.xls"
%>
<meta ame")%> </td>
<td align="left" style="vnd.ms-excel.numberformat:@">èç³»çµè¯ï¼</td>
<td colspan="2" align="left" style="vnd.ms-excel.numberformat:@"><%=rs("recphone")%> </td>
</tr>
<tr align="center">
<td align="left" style="vnd.ms-excel.numberformat:@">çµåé®ä»¶ï¼</td>
<td align="left" bgcolor="#FFFFFF" style="vnd.ms-excel.numberformat:@"><%=rs("recemail")%> </td>
<td align="left" style="vnd.ms-excel.numberformat:@">详ç»å°åï¼</td>
<td colspan="2" align="left" style="vnd.ms-excel.numberformat:@"><%=rs("recaddress")%></td>
</tr>
<tr align="center">
<td align="left" style="vnd.ms-excel.numberformat:@">é®ç¼ï¼</td>
<td align="left" bgcolor="#FFFFFF" style="vnd.ms-excel.numberformat:@"><%=rs("reczip")%> </td>
<td align="left" style="vnd.ms-excel.numberformat:@">é éæ¹å¼ï¼</td>
<td colspan="2" align="left" style="vnd.ms-excel.numberformat:@"><%=rs("peisong")%></td>
</tr>
<tr align="center">
<td align="left" style="vnd.ms-excel.numberformat:@">ææºï¼</td>
<td align="left" bgcolor="#FFFFFF" style="vnd.ms-excel.numberformat:@"><%=rs("shouji")%> </td>
<td align="left" style="vnd.ms-excel.numberformat:@">ä»æ¬¾æ¹å¼ï¼</td>
<td colspan="2" align="left" style="vnd.ms-excel.numberformat:@"><%=rs("fukuan")%></td>
</tr>
<tr align="center">
<td align="left" style="vnd.ms-excel.numberformat:@">å ¶ä»è¯´æï¼</td>
<td colspan="4" align="left" bgcolor="#FFFFFF" style="vnd.ms-excel.numberformat:@"><%=rs("recmemo")%></td>
</tr>
</table>
<br />
<%
rs.movenext
loop
rs.close
set rs=nothing
%>
asp代码实现access数据导出到excel文件
asp代码实现access数据导出到excel文件:
一,下面是入a入网站互赞源码导出XLS格式
%
dimreferer
referer=Request.ServerVariables(HTTP_REFERER)
DimCName,action
action=request.Form(action)
CName=../../Excel/
dimdaytime
daytime=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*fromgbookorderbyiddesc
rs.Opensql,conn
ifrs.EOFandrs.BOFthen
response.writescriptalert(操作出错,下面是源码发单app源码产生错误的可能原因:nn库里暂时没有数据,所以不能导出EXCEL文件!);location.href=referer;/script
response.end
else
dimfilename,将据库c gdi 源码fs,myfile,x
Setfs=server.CreateObject(scripting.filesystemobject)
--假设你想让生成的EXCEL文件做如下的存放
filename=Server.MapPath(CNamedaytime.xls)
--如果原来的EXCEL文件存在的话删除它
iffs.FileExists(filename)then
fs.DeleteFile(filename)
endif
--创建EXCEL文件
setmyfile=fs.CreateTextFile(filename,true)
dimstrLine,responsestr
strLine=
Foreachxinrs.fields
strLine=strLinex.namechr(9)
Next
--将表的列名先写入EXCEL
myfile.writelinestrLine
DowhileNotrs.EOF
strLine=
foreachxinrs.Fields
strLine=strLinex.valuechr(9)
next
--将表的数据写入EXCEL
myfile.writelinestrLine
rs.MoveNext
loop
rs.Close
setrs=nothing
conn.close
setconn=nothing
setmyfile=nothing
Setfs=Nothing
Response.WriteBRBRcenterb导出成功,请选择继续操作/b/center
Response.Writebr
response.Writetablewidth=%cellspacing=1cellpadding=3align=center
Response.Writetralign=centertd
response.write(fontcolor=green/fontahref=CNameENames.xls下载/a)nbsp;nbsp;fontcolor=green/fontahref=referer返回/a
Response.Write/td/tr/table
endif
%
二,下面是导l导奇迹全套源码导出CSV格式
%
dimreferer
referer=Request.ServerVariables(HTTP_REFERER)
DimCName,action
action=request.Form(action)
CName=../../Excel/
dimdaytime
daytime=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*fromgbookorderbyiddesc
rs.Opensql,conn
ifrs.EOFandrs.BOFthen
response.writescriptalert(操作出错,下面是入a入dubbo源码 服务产生错误的可能原因:nn库里暂时没有数据,所以不能导出EXCEL文件!);location.href=referer;/script
response.end
else
DimFs,源码Exc
DimExcelstring,ExcelHead,Excelstr,Excelstr2
DimScou_FileNamen,Scou_FieldList
DimDest_FileName,Dest_FieldList
Dest_FileName=CNamedaytime.csv
Excelstring=
ExcelHead=识别号,主题类型,公司名称,姓名,性别,职位,城市省份,城市,公司地址,邮编,邮件,电话,传真,手机,公司网址,详细内容,IP地址,留言时间
SetRs=Server.CreateObject(ADODB.Recordset)
Sql=Select*Fromgbook
Rs.OpenSql,Conn,1,3
DoWhileNotRs.Eof
Excelstr=Rs(ID),Rs(zhutiname),Rs(gsname),Rs(gsname),Rs(sex),Rs(zhiwei),Rs(Province),Rs(City),Rs(dizhi),Rs(youbian),Rs(email),Rs(tel),Rs(fax),Rs(tel2),Rs(homeurl),Rs(body),Rs(ip),Rs(addtime)
Excelstr2=Excelstr2Chr()Excelstr
Rs.Movenext
Loop
Excelstring=ExcelHeadExcelstr2
Rs.Close