2014. 3. 31. 13:44ㆍ프로그래밍/Jsp
1. Jsp 에서 엑셀 다운로드 하기
=========================================================================================================
================================================List.jsp==================================================
=========================================================================================================
<html>
<head>
<title>엑셀 다운로드 Test</title>
<script type="text/javascript">
function excelDown(){
var f = document.form1;
f.action="/test/downList.jsp";
f.submit();
}
</head>
<body>
<form name="form1" method="post">
<table border="1">
<thead>
<tr>
<th>번호</th>
<th>제목</th>
<th>작성자</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>테스트</td>
<td>홍길동</td>
</tr>
</tbody>
</table>
<input type="button" value="excelDown" onClick="excelDown()" />
</form>
</body>
</html>
=========================================================================================================
=============================================downList.jsp================================================
=========================================================================================================
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>엑셀 다운로드</title>
</head>
<body>
<%
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition", "inline; filename=excelDown.xls");
%>
<table border="1">
<thead>
<tr>
<th>번호</th>
<th>제목</th>
<th>작성자</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>테스트</td>
<td>홍길동</td>
</tr>
</tbody>
</table>
</body>
</html>
'프로그래밍 > Jsp' 카테고리의 다른 글
[Jsp] Jsp 페이징처리 (0) | 2015.02.25 |
---|---|
[Jsp] Jsp 페이징처리 (0) | 2014.04.02 |
[JSP] JSTL 오늘날짜 구하기 (0) | 2014.03.24 |
[Jsp] enctype="multipart/form-data" 에서 request.getParameter null 문제 (0) | 2014.03.07 |
[Java/Jsp] Excel 다운로드 시 제목 깨짐현상 방지 (0) | 2014.02.21 |