페이지에 출력한 목록을 엑셀로 저장하고 싶을 때....

<a href="list_for_excel.asp" target="_blank"> [엑셀로 저장하기] </a>

페이지 상단에 아래와 같이 4줄의 코드만 추가해주면 엑셀로 열기, 저장, 취소를 묻는 창이 뜬다.

-- list_for_excel.asp --------------------------------------------------------------------------
<%
Response.Buffer = TRUE
Response.CacheControl = "public"
Response.ContentType = "application/vnd.ms_excel"
Response.AddHeader "Content-disposition", "attachment;filename=" & "test.xls"   '저장할 엑셀 파일명
%>
<html>
<head>
<title>수신통계</title>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html;charset=euc-kr">
</head>
<body>
<table>
<tr><td>1</td><td>개똥이</td></tr>
<tr><td>2</td><td>길동이</td></tr>
</table>
</body>
</html>







반응형
function CheckNumber(num)
{
    if(isNaN(num)) { alert("숫자만 입력할 수 있습니다.");return ""}           
    return num
}

<input type="text" onKeyUp="this.value=CheckNumber(this.value)">
반응형
function IsEmail( strEmail )
{
return (/^[_0-9a-zA-Z-]+(\.[_0-9a-zA-Z-]+)*@[0-9a-zA-Z-]+(\.)+([0-9a-zA-Z-]+)([\.0-9a-zA-Z-])*$/.test( strEmail ) );
}
반응형
FUNCTION Ceil(nPnanum,nNanum)
    DIM nResult1, nResult2, nRetValue
   
    nResult1 = nPnanum/nNanum
    nResult2 = ROUND(nPnanum/nNanum)

    IF nResult1 <> nResult2 THEN
        nRetValue = FIX(nResult1) + 1
    ELSE
        nRetValue = nResult1
    END IF

    Ceil = nRetValue
END FUNCTION

<예>
2 = Ceil( 8, 7)
반응형
    ' Feel Free to Add Your Own Content-Types Here
    Select Case strFileType
        Case ".asf"
            ContentType = "video/x-ms-asf"
        Case ".avi"
            ContentType = "video/avi"
        Case ".doc"
            ContentType = "application/msword"
        Case ".zip"
            ContentType = "application/zip"
        Case ".xls"
            ContentType = "application/vnd.ms-excel"
       ' Case ".ppt"
        '    ContentType = "application/vnd.ms-PowerPoint"
        Case ".gif"
            ContentType = "image/gif"
        Case ".jpg", "jpeg"
            ContentType = "image/jpeg"
        Case ".wav"
            ContentType = "audio/wav"
        Case ".mp3"
            ContentType = "audio/mpeg3"
        Case ".mpg", "mpeg"
            ContentType = "video/mpeg"
        Case ".rtf"
            ContentType = "application/rtf"
        Case ".htm", "html"
            ContentType = "text/html"
        Case ".asp"
            ContentType = "text/asp"
        Case Else
            'Handle All Other Files
            ContentType = "application/octet-stream"
    End Select
반응형

+ Recent posts