⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 outputword_index.asp

📁 办公软件之间的数据交换,可以把WORD文件和EXCEL文件中的数据添加到WEB服务器,也可以从WEB服务器中下载数据到本地电脑.
💻 ASP
字号:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<style type="text/css">
<!--
.style1 {font-size: 18px}
-->
</style>
</head>

<%

    set newconn=server.createobject("adodb.connection")
	set rs=server.createobject("adodb.recordset")
	DBPath = Server.MapPath("#ctm wish.mdb")
	newconn.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & DBPath
	'sqlcmd="select * from wish Order By id Desc"
	'rs.Open sqlcmd,newconn,1,2
	
	'  获取要显示的字段
   bid=request.Form("chid")  '序号
   chpro=request.Form("chpro")'项目名称
   chsf=request.Form("chsf") '  省份
   tname=request.Form("chname")'姓名
   chsex=request.Form("chsex") '性别
   chsch=request.Form("chsch") '毕业学校名称
  
   '获取条件
    txtid=request.Form("txtid")
	mname=request.Form("txtname")
	txtsex=request.Form("txtsex")
	txtsch=request.Form("txtsch")
     

	
	sqlcmd=sqlcmd+"select "
	
	
	dim lflag
	lflag=0
	if bid=1 then 
	lflag=1
	   sqlcmd=sqlcmd+" "+"序号"
	   else
	   sqlcmd=sqlcmd
   end if
   
   
	if tname=1  and bid=1  then
        	 lflag=1
	        sqlcmd=sqlcmd+","
			 sqlcmd=sqlcmd+"姓名"
	else if tname=1  then
	        lflag=1
	        sqlcmd=sqlcmd+"姓名"
	   
		 end if
	end if
	
	
	if chpro=1  and lflag=1  then
	         sqlcmd=sqlcmd+","
			 sqlcmd=sqlcmd+"项目名称"
	else if chpro=1   then
            lflag=1
	        sqlcmd=sqlcmd+"项目名称"
	      end if
	end if
   
   if chsf=1  and lflag=1  then
	         sqlcmd=sqlcmd+","
			 sqlcmd=sqlcmd+"省份"
	else if chsf=1   then
            lflag=1
	        sqlcmd=sqlcmd+"省份"
	      end if
	end if
  
   
   if chsex=1  and lflag=1  then
	         sqlcmd=sqlcmd+","
			 sqlcmd=sqlcmd+ "性别"
	else if chsex=1   then
            lflag=1
	        sqlcmd=sqlcmd+ "性别"
	      end if
	end if
	
	if chsch=1  and lflag=1  then
	         sqlcmd=sqlcmd+","
			 sqlcmd=sqlcmd+ "毕业学校名称"
	else if chsch=1   then
            lflag=1
	        sqlcmd=sqlcmd+ "毕业学校名称"
	      end if
	end if
	
	
	sqlcmd=sqlcmd+" "+"from student_info "
	dim flag_look     '标识为查寻,在多条件下,如果前面已经有一个条件,则为1
     flag_look=0
	 
	if  txtid<>""  then
	     flag_look=1
	     sqlcmd=sqlcmd+"where 序号="&txtid
		 else
		 flag_look=0
	end if

       if flag_look=1 and mname<>""  then
       sqlcmd=sqlcmd+"and 姓名='"&mname&"'"
	   else if mname<>""then
	            sqlcmd=sqlcmd+"where 姓名='"&mname&"'"
			    flag_look=1
			end if
	end if
	
	if flag_look=1 and txtsex<>""  then
       sqlcmd=sqlcmd+"and 性别='"&txtsex&"'"
	   else if txtsex<>""then
	            sqlcmd=sqlcmd+"where 性别='"&txtsex&"'"
			    flag_look=1
			end if
	end if
	
	if flag_look=1 and txtsch<>""  then
       sqlcmd=sqlcmd+"and 毕业学校名称='"&txtsch&"'"
	else if txtsch<>""then
	            sqlcmd=sqlcmd+"where 毕业学校名称='"&txtsch&"'"
			    flag_look=1
		 end if
	end if
	
	response.Write sqlcmd
	
	
	rs.Open sqlcmd,newconn,1,2

	
   Dim fso, MyFile
   
   Set fso = CreateObject("Scripting.FileSystemObject")
   Set MyFile = fso.openTextFile(server.MapPath("testfile.doc"), 2,false)
  
   do while not rs.eof 
       for i=0 to rs.Fields.Count-1
	    
		 MyFile.Write(rs(i))
		  MyFile.Write  "	"
	 next
	  MyFile.Write  chr(10)+chr(13)
	rs.movenext      
 loop
   
%>

<body>
<span class="style1"><a href="testfile.doc">下载word文件
</a></span>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -