asp 中数据导出为 word ,excl ,text ,等格式文件
这是从方法直接复制的,
参数 fileType是文件格式
参数filedName是写出后文件的文件名。
参数suffix是写出后文件的文件后缀名。
Response.Clear(); //清空 缓冲区的所有输出数据
Response.Charset = "utf-8";//设置输出输出流字符类型
Response.ContentType = fileType;设置输出流的 file MIME类型
Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(fileName) + suffix);//将HTTP 头添加到输出流,“+”以前是固定的 字符串连接是为了写文件名和文件后缀名
Response.Write("<html><head><Meta http-equiv=\"Content-Type\"content=\"text/html;charset=utf-8\"></head><body>");
Response.Write("<h1>"+article.Title+"</h1><p/>"+article.Context);
Response.Write("</body></html>");
//文件内容
Response.End();
//关闭
当导出的文件为 文本格式时 Response.Write(" ")中就不必写入HTML代码,如果写入了,文本内容会出现 HTML
Response.ContentType ="application/ms-excel";是excel
Response.ContentType ="Content-Disposition";是word
相关文档:
现在主流的网站开发语言无外乎asp、php、asp.net、jsp等。
网页从开始简单的hmtl到复杂的服务语言,走过了10多个年头,各种技术层出不穷,单个的主流技术也在不断翻新的版本,现在分析下各种语言的区别、优势、劣势、开发注意事项!
HTML:当然这是网页最基本的语言,每一个服务器语言都需要它的支持,要学习,这个肯定是开始 ......
<bgsound src="wen.mid" loop="0">
<% dim weh
If Time >=#1:00:00 AM# And Time < #6:00:00 PM# Then
weh = "<bgsound src="1.mid" loop="0">"
Else If Time >#6:00:00 AM# And Time < #9:00:00 PM#
weh = "<bg ......
'使用FSO修改文件特定内容的函数
Function FSOchange(filename,Target,String)
Dim objFSO,objCountFile,FiletempData
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objCountFile = objFSO.OpenTextFile(Server.MapPath(filename),1,True)
FiletempData = objCountFile.ReadAll
objCountFi ......
ASP万用分页程序
这只是个asp小技巧类的东西,它虽然适合在每个不同文件名里调用这个函数,但是也是有前提的,下面让我们来仔细看看其中的原委。
下面这段是基本的分页代码:
<% sql = "select……………………省略了sql语句
Set rs=Server ......
<bgsound src="wen.mid" loop="0">
<% dim weh
If Time >=#1:00:00 AM# And Time < #6:00:00 PM# Then
weh = "<bgsound src="1.mid" loop="0">"
Else If Time >#6:00:00 AM# And Time < #9:00:00 PM#
weh = "<bgso ......