본문 바로가기

asp

csv 파일로 다운로드

<%@Language="VBScript" CODEPAGE="65001" %>
<%
    Response.CharSet="utf-8"
    Session.codepage="65001"
    Response.codepage="65001"
    Response.ContentType="text/html;charset=utf-8"
%>  

<%

    Response.Buffer = True
    Response.Expires = 0
    Response.ContentType = "text/csv"
    Response.Charset = "euc-kr"
    Session.codepage="949"
    Response.codepage="949"
    Response.CacheControl = "public"
    Response.AddHeader "Content-Disposition","attachment; filename=통계_" & left(now(),10) & ".csv"


    nstr = "no,항목1,항목2,항목3,항목4,항목5" & vbcrlf


    for i=1 to 10 step +1

            nstr = nstr & chr(34) & i & chr(34)
            nstr = nstr & "," & chr(34) & str1 & chr(34)
            nstr = nstr & "," & chr(34) & str2 & chr(34)
            nstr = nstr & "," & chr(34) & str3 & chr(34)
            nstr = nstr & "," & chr(34) & str4 & chr(34)
            nstr = nstr & "," & chr(34) & str5 & chr(34)
            nstr = nstr & vbcrlf

   next

%>