国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數(shù)據(jù)庫 > Access > 正文

asp代碼實現(xiàn)access數(shù)據(jù)-導(dǎo)出到excel文件

2019-11-02 14:28:08
字體:
供稿:網(wǎng)友

   asp代碼實現(xiàn)access數(shù)據(jù)導(dǎo)出到excel文件:

  一,下面是導(dǎo)出XLS格式

<% 
dim referer 
referer = Request.ServerVariables("HTTP_REFERER") 
Dim CName,action 
action=request.Form("action") 
CName="../../Excel/" 
dim daytime 
’daytime=year(now())&"-"&month(now())&"-"&day(now())&"-"&hour(now())&"-"&Minute(now()) 
daytime=year(now())&"年"&month(now())&"月"&day(now())&"日"&hour(now())&"時" 
Set rs = Server.CreateObject("ADODB.Recordset") 
’--從數(shù)據(jù)庫中把你想放到EXCEL中的數(shù)據(jù)查出來 
sql="select * from gbook order by id desc" 
rs.Open sql,conn 
if rs.EOF and rs.BOF then 
   response.write "<script>alert(’操作出錯,下面是產(chǎn)生錯誤的可能原因:nn庫里暫時沒有數(shù)據(jù),所以不能導(dǎo)出EXCEL文件!’);location.href = ’"&referer&"’;</script>" 
  response.end 
else 
dim filename,fs,myfile,x 
Set fs = server.CreateObject("scripting.filesystemobject") 
’--假設(shè)你想讓生成的EXCEL文件做如下的存放 
filename = Server.MapPath(""&CName&""&daytime&".xls") 
’--如果原來的EXCEL文件存在的話刪除它 
if fs.FileExists(filename) then 
fs.DeleteFile(filename) 
end if 
’--創(chuàng)建EXCEL文件 
set myfile = fs.CreateTextFile(filename,true) 
dim strLine,responsestr 
strLine="" 
For each x in rs.fields 
strLine= strLine & x.name & chr(9) 
Next 
’--將表的列名先寫入EXCEL 
myfile.writeline strLine 
Do while Not rs.EOF 
strLine="" 
for each x in rs.Fields 
strLine= strLine & x.value & chr(9) 
next 
’--將表的數(shù)據(jù)寫入EXCEL 
myfile.writeline strLine 
rs.MoveNext 
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 那坡县| 嘉祥县| 通渭县| 贵港市| 龙门县| 门源| 深泽县| 宁安市| 疏附县| 海城市| 镇沅| 库尔勒市| 肇庆市| 连山| 基隆市| 什邡市| 礼泉县| 亚东县| 东平县| 阜阳市| 盐亭县| 商城县| 南召县| 鄂托克前旗| 定西市| 托克托县| 集安市| 东乡族自治县| 安远县| 蓬莱市| 图木舒克市| 阿克陶县| 伊春市| 木兰县| 石阡县| 贞丰县| 界首市| 翁源县| 肇源县| 冷水江市| 山东省|