기억저장소

기억저장소

Web/JSP

POI를 이용한 엑셀

roaminpixel 2013. 7. 27. 04:58
728x90


lib.zip

<%@ page contentType="application/vnd.ms-excel; charset=EUC-KR"%>

<%@ page import="org.apache.poi.hssf.usermodel.*" %>

<%@ page import="java.io.*" %>


<%


try {


String fileName = "test.xls";

response.setHeader("Content-Disposition", "attachment; filename=" + fileName); 

response.setHeader("Content-Description", "JSP Generated Data"); 


//신규 워크북을 작성

HSSFWorkbook wb = new HSSFWorkbook();


//sheet1」라는 이름의 워크시트를 표시하는 오브젝트 생성

HSSFSheet sheet1 = wb.createSheet("sheet1"); 


for(int i = 0; i < 100; i++) {


//행의 작성

HSSFRow row = sheet1.createRow((short)i); 


//행에 셀의 데이터를 설정 

row.createCell((short)0).setCellValue("text value");

row.createCell((short)1).setCellValue(123456);

row.createCell((short)2).setCellValue(25.45);

}


OutputStream fileOut = response.getOutputStream();

wb.write(fileOut);


} catch (Exception e) {


e.printStackTrace(); 


}

%>




http://lonbekim.blogspot.kr/2008/03/jsp-jakarta-poi-excel.html

http://blog.daum.net/kibbmcc/7718692

http://yanggoony.tistory.com/3


꾸미기

http://sinope.tistory.com/28

http://blog.daum.net/wiznel/4653768

728x90
반응형

'Web > JSP' 카테고리의 다른 글

getOutputStream() has already been called for this response  (0) 2013.07.27
특정문자  (0) 2013.07.24
jsp 페이지 직접 접근 막기  (0) 2013.07.04
jsp + mysql 한글 깨짐 현상  (0) 2013.07.01
jsp + php 연동하기  (0) 2013.06.22