ASP动态生成CSV文件的实现方法 - TOMMYHU - 专注互联网开发及运营技术,提供相关资料及软件下载,奇趣网络时事评论!
Apr 19

ASP动态生成CSV文件的实现方法 不指定

tommyhu , 12:43 , ASP , Comments(0) , Trackbacks(0) , Reads(10578) , Via Original Large | Medium | Small
ASP动态生成CSV文件的实现方法


[/c<%            '生成文件名流水号                                                    
                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()
%>

▲返回顶部

Add a comment

Nickname

emotemotemotemotemotemotemotemotemotemotemotemotemotemotemotemot