ASP將數(shù)據(jù)庫(kù)中的數(shù)據(jù)導(dǎo)出到EXCEL表中_ASP教程
推薦:ASP把電話號(hào)碼生成圖片的代碼作用:將頁(yè)面中的電話號(hào)碼生成圖片格式。 % Call Com_CreatValidCode(Request.QueryString(tel)) Public Sub Com_CreatValidCode(pTel) '----------禁止緩存 Response.Expires = 0 Response.AddHeader Pragma,no-cache Response.AddHeader cache-ctro
ASP實(shí)例代碼,直接將數(shù)據(jù)庫(kù)中的數(shù)據(jù)導(dǎo)出到EXCEL電子表中。
<!--#include file="../conn.asp"-->
<%
dim s,sql,filename,fs,myfile,x
Set fs = server.CreateObject("scripting.filesystemobject")
'--假設(shè)你想讓生成的EXCEL文件做如下的存放
filename = Server.MapPath("users.xls")
'--如果原來的EXCEL文件存在的話刪除它
if fs.FileExists(filename) then
fs.DeleteFile(filename)
end if
'--創(chuàng)建EXCEL文件
set myfile = fs.CreateTextFile(filename,true)
'Set rs = Server.CreateObject("ADODB.Recordset")
'--從數(shù)據(jù)庫(kù)中把你想放到EXCEL中的數(shù)據(jù)查出來
'sql = "select * from Tb_Execl order by id desc"
'rs.Open sql,conn
StartTime = Request("StartTime")
EndTime = Request("EndTime")
StartEndTime = "AddTime between #"& StartTime &" 00:00:00# and #"& EndTime &" 23:59:59#"
strSql = "select * from myeky_myusr "
Set rstData =conn.execute(strSql)
if not rstData.EOF and not rstData.BOF then
dim trLine,responsestr
strLine=""
For each x in rstData.fields
strLine = strLine & x.name & chr(9)
Next
'--將表的列名先寫入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文件成功,點(diǎn)擊<a href=""users.xls"" target=""_blank"">下載</a>!"
rstData.Close
set rstData = nothing
Conn.Close
Set Conn = nothing
%>
分享:Asp中代碼與頁(yè)面的分離為了避免ASP程序和HTML代碼混寫造成維護(hù)困難的情況,本文介紹了一種方法,利用模板來分離程序和頁(yè)面,使程序設(shè)計(jì)更加輕松。 在使用ASP制作一個(gè)站點(diǎn)的時(shí)候,常常會(huì)出現(xiàn)一個(gè)ASP文件中,程序代碼和HTML代碼混合的情況。這樣子做有許多缺點(diǎn): 1.且不說編程時(shí)就要
- asp FSO 讀寫文件本文件實(shí)現(xiàn)代碼
- asp中isNull、isEmpty和空字符串的區(qū)別
- asp獲取用戶真實(shí)IP地址的方法
- asp連接sqlserver數(shù)據(jù)庫(kù)實(shí)現(xiàn)代碼
- asp中正則表達(dá)式過濾html代碼函數(shù)
- asp中g(shù)et post提交表單區(qū)別
- 網(wǎng)頁(yè)模板:ASP內(nèi)建對(duì)象Request
- xmlhttp的open方法使用詳解
- ASP的常用的自定義函數(shù)大全
- asp中用for循環(huán)的一個(gè)小技巧
- eWebEditor v3.8 列目錄
- ASP無組件分頁(yè)實(shí)現(xiàn)思路及代碼
ASP教程Rss訂閱編程教程搜索
ASP教程推薦
- 怎樣限制只能中文輸入的方法。
- ASP開發(fā)中有用的函數(shù)(function)集合(2)
- IIS服務(wù)器與web.config配置優(yōu)化指南
- ASP實(shí)現(xiàn)SQL語(yǔ)句日期格式的加減運(yùn)算
- 小議ASP動(dòng)態(tài)網(wǎng)頁(yè)編程的19個(gè)基本技巧
- ASP生成靜態(tài)htm頁(yè)面基本代碼
- 詳解ASP的Session對(duì)象
- ASP組件AspJpeg(加水印)生成縮略圖等使用方法
- asp有效防止網(wǎng)站留言板出現(xiàn)垃圾留言/評(píng)論實(shí)現(xiàn)思路
- 關(guān)于Adodb.Stream 的使用說明
- 相關(guān)鏈接:
復(fù)制本頁(yè)鏈接| 搜索ASP將數(shù)據(jù)庫(kù)中的數(shù)據(jù)導(dǎo)出到EXCEL表中
- 教程說明:
ASP教程-ASP將數(shù)據(jù)庫(kù)中的數(shù)據(jù)導(dǎo)出到EXCEL表中
。