ASP动态生成CSV文件
2008-12-02 10:36
295 查看
<% '生成文件名流水号
birth = formatdatetime(now,2)
enyear = CStr(year(birth))
enmonth = month(birth)
enday = day(birth)
if len(CInt(enmonth))=1 then
enmonth="0"&CStr(enmonth)
end if
if len(CInt(enday))=1 then
enday="0"&CStr(enday)
end if
birth_no=enyear&enmonth&enday
birth2 = formatdatetime(now,3)
enhour = hour(birth2)
enminute = minute(birth2)
ensecond = second(birth2)
if len(CInt(enhour))=1 then
enhour="0"&CStr(enhour)
end if
if len(CInt(enminute))=1 then
enminute="0"&CStr(enminute)
end if
if len(CInt( ensecond))=1 then
ensecond="0"&CStr( ensecond)
end if
birth_no=enyear&enmonth&enday&enhour&enminute&ensecond
%>
<% Response.Buffer = true
Response.AddHeader "Content-Disposition","attachment; filename=文件名_"&birth_no&".csv"
Response.CharSet = "iso-8859-1" '文件编码
Response.ContentType = "application/octet-stream" %>
<!--#include file="conn.asp"-->
<%
set rs = conn.Execute("SELECT * FROM TABLES")
Response.Write rs.fields(0).name
for i=1 to rs.fields.count-1
Response.Write ";" & rs.fields(i).name
next
Response.Flush()
do while not rs.eof
Response.Write vbCrLf & rs(0)
for i=1 to rs.fields.count-1
Response.Write ";" & rs(i)
next
Response.Flush()
rs.Movenext
loop
rs.Close
conn.Close
set rs = nothing
set conn = nothing
Response.End()
%>
birth = formatdatetime(now,2)
enyear = CStr(year(birth))
enmonth = month(birth)
enday = day(birth)
if len(CInt(enmonth))=1 then
enmonth="0"&CStr(enmonth)
end if
if len(CInt(enday))=1 then
enday="0"&CStr(enday)
end if
birth_no=enyear&enmonth&enday
birth2 = formatdatetime(now,3)
enhour = hour(birth2)
enminute = minute(birth2)
ensecond = second(birth2)
if len(CInt(enhour))=1 then
enhour="0"&CStr(enhour)
end if
if len(CInt(enminute))=1 then
enminute="0"&CStr(enminute)
end if
if len(CInt( ensecond))=1 then
ensecond="0"&CStr( ensecond)
end if
birth_no=enyear&enmonth&enday&enhour&enminute&ensecond
%>
<% Response.Buffer = true
Response.AddHeader "Content-Disposition","attachment; filename=文件名_"&birth_no&".csv"
Response.CharSet = "iso-8859-1" '文件编码
Response.ContentType = "application/octet-stream" %>
<!--#include file="conn.asp"-->
<%
set rs = conn.Execute("SELECT * FROM TABLES")
Response.Write rs.fields(0).name
for i=1 to rs.fields.count-1
Response.Write ";" & rs.fields(i).name
next
Response.Flush()
do while not rs.eof
Response.Write vbCrLf & rs(0)
for i=1 to rs.fields.count-1
Response.Write ";" & rs(i)
next
Response.Flush()
rs.Movenext
loop
rs.Close
conn.Close
set rs = nothing
set conn = nothing
Response.End()
%>
相关文章推荐
- asp.net 动态地生成文件下载
- asp.net动态生成txt文本文件供用户下载
- ASP.NET动态数据填充空白文件生成图文并茂的Word文档
- PHP 动态导出生成 excel,csv文件
- 如何用Asp动态生成xml文件
- asp.net mvc动态生成file控件批量上传文件
- asp.net生成csv文件
- ASP动态生成XLS文件
- asp.net mvc动态生成file控件批量上传文件 .
- Asp.Net 中 动态生成 Excel 文件的心得
- C实现动态生成一个Asp文件
- 调用由ASP动态生成的JS文件
- asp.net生成csv文件,并在客户端点击下载(文件流直接输出到客户端而不是先生成保存在服务端再下载)
- asp.net动态生成txt文件并提供用户下载代码
- asp.net动态生成js文件
- Visual Studio Express 2013 for Windows Desktop 将c文件生成.dll动态链接库
- Asp.net生成Excel文件并下载(更新:解决使用迅雷下载页面而不是文件的问题)
- [转]Asp.net动态生成html页面
- ASP.NET动态生成HTML页面
- ASP.net后台动态加载Css文件