05.JSP2008. 11. 19. 13:53
반응형

JExcelApi(jxl.jar 다운로드)


http://www.andykhan.com/jexcelapi/index.html 에서 download JExcelApi에 가면
(http://www.andykhan.com/jexcelapi/download.html) tar.gz로 되어 있는데 압축풀면 jxl.jar있음


POI다운로드
http://jakarta.apache.org/poi/index.html /download/release


[엑셀파일읽기]

<%@ page language="java" %>
<%@ page contentType="text/html; charset=euc-kr"%>
<%@ page import="java.io.File,jxl.*"%>
<%


Workbook workbook = Workbook.getWorkbook(new File("E:/_Workspace/blr/blr/cms/excel/data/Book1.xls"));


Sheet sheet = workbook.getSheet(0);
Cell a1 = sheet.getCell(0,0);
Cell b2 = sheet.getCell(1,1);
Cell c3 = sheet.getCell(0,2);


String stringa1 = a1.getContents();
String stringb2 = b2.getContents();
String stringc3 = c3.getContents();


workbook.close();


%>


<%=stringa1%>
<%=stringb2%>
<%=stringc3%>


[엑셀파일로 저장]


<%@ page language="java" %>
<%@ page contentType="text/html; charset=euc-kr"%>
<%@ page import="java.io.File,java.util.Date,jxl.*,jxl.write.*"%>
<%
WritableWorkbook workbook = Workbook.createWorkbook(new File("E:/_Workspace/blr/blr/cms/excel/data/aaa.xls"));


WritableSheet sheet = workbook.createSheet("First Sheet", 0);
Label label = new Label(0,2,"A label record");
sheet.addCell(label);


// java.lang.Number 인지 jxl.write.Number  구분해야지^^


jxl.write.Number number = new jxl.write.Number(3,4,3.1415);
sheet.addCell(number);


workbook.write();
workbook.close();
%>


[POI로 테이블에 값넣기] poi.jsp참조


/***************************************************************************************/


엑셀파일처리 POI,JXL비교해 보았습니다.


10000번 for문을 돌려 첫번째 칼럼에 데이타를 입력하였습니다.


이걸 10번 반복한 체크시간입니다.




측정시간단위(밀리세컨)
D:\>java writeTest
============= jxl write time =============
0=>write time::719
1=>write time::281
2=>write time::250
3=>write time::266
4=>write time::234
5=>write time::266
6=>write time::234
7=>write time::266
8=>write time::234
9=>write time::329
=============      end      =============
============= poi write time =============
0=>write time::1110
1=>write time::922
2=>write time::1031
3=>write time::734
4=>write time::1328
5=>write time::766
6=>write time::797
7=>write time::1515
8=>write time::1719
9=>write time::2890
=============      end      =============



거의 2~3배 가까이 시간의 차이가 있더군여.. 단순히 엑셀파일만 다룬다면
jxl패키지를 사용하시는게 훨씬 좋을듯 합니다.

Posted by 1010