28,376
社区成员




<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%Server.Scripttimeout=99999999%>
<%page_grade=3%>
<!--#include file="conn1.asp"-->
<%
set rs3=server.CreateObject("adodb.recordset")
sql="select cj_nianji AS 年级,cj_xueyuan AS 学院,cj_banji AS 班级, cj_tyxm AS 项目,cj_fenban AS 上课时间,cj_laoshi AS 教师,cj_xuehao AS 学号,cj_xm AS 姓名,cj_sex AS 性别,cj_1 AS 身高(厘米),cj_2 AS 体重(公斤),cj_4 AS 肺活量(毫升),cj_5 AS 50米(秒),cj_6 AS 立定跳远(米),cj_7 AS 坐位体前屈(厘米),cj_8 AS 引体向上(男)仰卧起坐(女)(次),cj_9 AS 800米(女)1000米(男)(分秒),cj_bz AS 备注,cj_fs AS 成绩 from [cj] where cj_nianji='"&request("nj")&"' order by cid asc"
rs3.open sql,conn,3,2
if rs3.EOF and rs3.BOF then
response.write("<script>alert('无数据导出!!');window.close();</script>")
response.end
else
dim strLine
Set fs = server.CreateObject("scripting.filesystemobject")
'--生成的EXCEL文件存放地址
if request("nj")="11" then
nianji_text="大一"
end if
if request("nj")="12" then
nianji_text="大二"
end if
if request("nj")="13" then
nianji_text="大三"
end if
if request("nj")="14" then
nianji_text="大四"
end if
fileName="down_excel\"&nianji_text&"-"&date()&".xls"
filePath = Server.MapPath(fileName)
'--如果原来的EXCEL文件存在的话删除它
if fs.FileExists(filePath) then
fs.DeleteFile(filePath)
end if
'--创建EXCEL文件
set xlsFile = fs.CreateTextFile(filePath,true)
strLine=""
For each x in rs3.fields
strLine= strLine & x.name & chr(9)
Next
'--将表的列名先写入EXCEL
xlsFile.writeline strLine
Do while Not rs3.EOF
strLine=""
for each x in rs3.Fields
strLine= strLine & x.value & chr(9)
next
'--将表的数据写入EXCEL
xlsFile.writeline strLine
rs3.MoveNext
loop
response.write"<font color=#FF0000>【成功导出!】【<a href=""javascript:history.back();"">点击返回</a>】</font><br>"
fileurl=left(Request.ServerVariables("Http_Referer") ,len(Request.ServerVariables("Http_Referer"))-21)& replace(fileName,"\","/")
%> <br>
<a href="<%= fileurl %>" target="_blank">点击下载</a>
<% end if
rs3.Close
set rs3=nothing
'Response.ContentType="application/x-msdownload"
%>