본문 바로가기
develop/jsp

CSV 다운로드 기능

by hybr1d 2014. 11. 5.

CSV JSP 부분 

구분자 , 

개행문자 "

<%@ page contentType="text/html;charset=utf-8" %>

<%@ include file="/WEB-INF/jsp/egovframework/cmmn/taglibs.jsp"%>

<%@ page trimDirectiveWhitespaces="true" %> //줄바꿈 삭제 

<%

response.setHeader("Content-Type", "text/csv; charset=MS949");

response.setHeader("Content-Disposition", "attachment;filename=CsvDownload.csv");

%>

 <c:forEach items="${surveyPopList}" var="list" varStatus="i" >

"${list.sd_name}","${list.area}","${list.quantity}"

<c:forEach items="${surveySggList}" var="sggList" varStatus="i" >

<c:if test="${list.sd_name == sggList.sd_name}">

"${sggList.sgg_name}","${sggList.area}","${sggList.quantity}","${sggList.department}","${sggList.contact}"    

</c:if>

</c:forEach>

 </c:forEach>

  <c:if test="${!empty surveyPopList}">

"합계","${totArea}","${totQuantity}"

  </c:if>

  <c:if test="${empty surveyPopList}">

"조회 된 데이터가 없습니다."

  </c:if>