asp生成excel源代码

2022-07-14 08:10:17   文档大全网     [ 字体: ] [ 阅读: ]

#文档大全网# 导语】以下是®文档大全网的小编为您整理的《asp生成excel源代码》,欢迎阅读!
源代码,生成,excel,asp
<%

dim s,sql,filename,fs,myfile,x

Set fs = server.CreateObject("scripting.filesystemobject") '--假设你想让生成的EXCEL文件做如下的存放

filename = Server.MapPath("班班通使用记录登记表.xls") '--如果原来的EXCEL文件存在的话删除它 if fs.FileExists(filename) then fs.DeleteFile(filename) end if

'--创建EXCEL文件

set myfile = fs.CreateTextFile(filename,true)

Set rs = Server.CreateObject("ADODB.Recordset") '--从数据库中把你想放到EXCEL中的数据查出来 sql = "select teacher_Name,teacher_use_time,teacher_use_class,teacher_use_snumber,teacher_use_jc,teacher_use_ctitle,teacher_use_couse from teacher_use_table order by teacher_use_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 teacher_Name,teacher_use_time,teacher_use_class,teacher_use_snumber,teacher_use_jc,teacher_use_ctitle,teacher_use_couse from teacher_use_table" Set rstData =conn.execute(strSql)

if not rstData.EOF and not rstData.BOF then

dim trLine,responsestr strLine=""

strLine = strLine & "上课教师" & chr(9) strLine = strLine & "上课时间" & chr(9) strLine = strLine & "使用班级" & chr(9) strLine = strLine & "学生人数" & chr(9) strLine = strLine & "使用节次" & chr(9) strLine = strLine & "上课学科" & chr(9) strLine = strLine & "课程名称" & 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文件成功,点击班通使用记录登记表.xls"" target=""_blank"">下载"

rstData.Close set rstData = nothing Conn.Close

Set Conn = nothing %>


本文来源:https://www.wddqxz.cn/cfc1e56a366baf1ffc4ffe4733687e21af45ff0e.html

相关推荐