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
相关文档:
只需要在fckeditor\editor\filemanager\connectors\asp文件夹下的commands.asp修改一下即可
在这个文件中查找一下:FileUpload
会找到这个函数
把
代码如下:
Dim sFilePath
sFilePath = CombineLocalPaths(sServerDir, sFileName)
改为
代码如下:
Dim sFilePath,ranNum
Randomize
ranNum=int(90000*rnd)+ ......
<%
If Not IsNull(Request("fileName")) Then r = DownLoadFile(Request("fileName"))
Function DownLoadFile(fileName)
Dim s,fso,f,fLen
fileName = Server.MapPath(fileName)
'create stream
Set s = Server.CreateObject("ADODB.Stream")
s.Open()
s.Type = 1
Set fso = Server.CreateObject ......
<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 ......
后台数据库:
[Microsoft Access]
与
[Microsoft Sql Server]
更换之后,ASP代码应注意要修改的一些地方:
[一]连接问题(举例)
[Microsoft Access]
constr = "DBQ=c:\data\clwz.mdb; DRIVER={Microsoft Access Driver (*.mdb)}"
[Microsoft Sql Server]
constr = "DRIVER={SQL Server};SERVER=host;DATA ......