📄 exportcontenttable.asp
字号:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="CheckLogin.asp"-->
<!--#include file="StudentConn.asp" -->
<%
Dim nFileName
nFileName=Year(now) & Month(now) & Day(now)
Response.Buffer = true
Response.AddHeader "Content-Disposition","attachment;filename=" & nFileName & ".csv;"
Response.CharSet = "bg2312"
Response.ContentType = "application/octet-stream"
strSheetName = Request("SheetName")
strSubjects = strSheetName & "." & Replace(Request("chkbox"),", ",", " & strSheetName & ".")
strStudentNum= Request("StudentNum")
strClass=Request("Class")
strGrade=Request("Grade")
strSQL = "Select " & strSheetName & ".StudentNum as 编号,StudentInfo.Remark as 帐号,StudentInfo.ClassName as 科室, StudentInfo.Name as 姓名, " & strSubjects & " From " & strSheetName
strSQL = strSQL & " LEFT JOIN StudentInfo ON " & strSheetName & ".StudentNum = StudentInfo.StudentNum"
if (strStudentNum <> "") then
strSQL = strSQL & " Where " & strSheetName & ".StudentNum Like '%" & strStudentNum & "%'"
else
if strClass="All" and strGrade="All" then
strStudentNum=""
strSQL = strSQL & " Where " & strSheetName & ".StudentNum Like '%" & strStudentNum & "%'"
else
if strClass="All" and strGrade<>"All" then
strSQL = strSQL & " Where StudentInfo.GradeID='" & strGrade & "'"
else
if strClass<>"All" and strGrade="All" then
strSQL = strSQL & " Where StudentInfo.ClassID='" & strClass & "'"
else
strSQL = strSQL & " Where StudentInfo.ClassID='" & strClass & "' and StudentInfo.GradeID='" & strGrade & "'"
end if
end if
end if
end if
strSQL = strSQL & " ORDER BY " & strSheetName & ".StudentNum"
Dim objConn
SET objConn = Server.CreateObject("ADODB.Connection")
objConn.ConnectionString=MM_StudentConn_STRING
objConn.Open
Dim RST
Dim I
Set RST = objConn.Execute(strSQL)
If RST.EOF Then
Response.Write("没有可导出数据!")
Response.End
End If
while not rst.eof
if i>=16 then
For i =0 TO RST.Fields.Count-16
strFields=strFields + RST.Fields(i).Name & ","
Next
For i =0 TO RST.Fields.Count-16
if i=0 then
strField=strField + "'" + (RST(i) & ",")
else
if i=1 then
strField=strField + "'" + (RST(i) & ",")
else
strField=strField + (RST(i) & ",")
end if
end if
Next
str=strFields + vbcrlf + strField + vbcrlf
Response.Write(str)
strFields=""
strField=""
For i =RST.Fields.Count-15 TO RST.Fields.Count-1
strFields=strFields + RST.Fields(i).Name & ","
Next
For i =RST.Fields.Count-15 TO RST.Fields.Count-1
strField=strField + (RST(i) & ",")
Next
str=strFields + vbcrlf + strField + vbcrlf + vbcrlf
Response.Write(str)
strFields=""
strField=""
else
For i =0 TO RST.Fields.Count-1
strFields=strFields + RST.Fields(i).Name & ","
Next
For i =0 TO RST.Fields.Count-1
if i=0 then
strField=strField+ chr(39) + (RST(i) & ",")
else
if i=1 then
strField=strField + "'" + (RST(i) & ",")
else
strField=strField + (RST(i) & ",")
end if
end if
Next
str=strFields + vbcrlf + strField + vbcrlf
str=cstr(str)
Response.Write(str)
strFields=""
strField=""
end if
rst.movenext
Wend
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -