WritableWorkbook myWorkbook = Workbook.createWorkbook(new File("C:/excel/el/"+filename+".xls"));
WritableSheet mySheet = myWorkbook.createSheet("first sheet", 0);
WritableCellFormat dataFormat = new WritableCellFormat(new WritableFont (WritableFont.ARIAL, 9,WritableFont.NO_BOLD, false, UnderlineStyle.NO_UNDERLINE, Colour.BLACK,ScriptStyle.NORMAL_SCRIPT)); // 데이터 셀 포멧 생성
WritableCellFormat dataFormat2 = new WritableCellFormat(new WritableFont (WritableFont.ARIAL, 9,WritableFont.NO_BOLD, false, UnderlineStyle.NO_UNDERLINE, Colour.BLACK,ScriptStyle.NORMAL_SCRIPT)); // 데이터 셀 포멧 생성
WritableCellFormat titleFormat = new WritableCellFormat( new WritableFont (WritableFont.ARIAL, 18,WritableFont.BOLD, false, UnderlineStyle.NO_UNDERLINE, Colour.BLACK,ScriptStyle.NORMAL_SCRIPT));
WritableCellFormat topFormat = new WritableCellFormat(new WritableFont (WritableFont.ARIAL, 9,WritableFont.NO_BOLD, false, UnderlineStyle.NO_UNDERLINE, Colour.BLACK,ScriptStyle.NORMAL_SCRIPT)); // 데이터 셀 포멧 생성
titleFormat.setAlignment(Alignment.CENTRE); // 셀 가운데 정렬
titleFormat.setVerticalAlignment(VerticalAlignment.CENTRE); // 셀 수직 가운데 정렬
dataFormat.setWrap(true);//자동 줄바꿈
dataFormat.setAlignment(Alignment.CENTRE); // 셀 가운데 정렬
dataFormat.setVerticalAlignment(VerticalAlignment.CENTRE); // 셀 수직 가운데 정렬
dataFormat.setBorder(Border.ALL, BorderLineStyle.THIN); // 보더와 보더라인스타일 설정
dataFormat2.setWrap(true);
dataFormat2.setAlignment(Alignment.LEFT); // 셀 가운데 정렬
dataFormat2.setVerticalAlignment(VerticalAlignment.CENTRE); // 셀 수직 가운데 정렬
dataFormat2.setBorder(Border.ALL, BorderLineStyle.THIN); // 보더와 보더라인스타일 설정
topFormat.setAlignment(Alignment.CENTRE); // 셀 가운데 정렬
topFormat.setVerticalAlignment(VerticalAlignment.CENTRE); // 셀 수직 가운데 정렬
topFormat.setBorder(Border.BOTTOM, BorderLineStyle.DOUBLE); // 보더와 보더라인스타일 설정
topFormat.setBorder(Border.LEFT, BorderLineStyle.THIN); // 보더와 보더라인스타일 설정
topFormat.setBorder(Border.RIGHT, BorderLineStyle.THIN); // 보더와 보더라인스타일 설정
topFormat.setBorder(Border.TOP, BorderLineStyle.THIN); // 보더와 보더라인스타일 설정
topFormat.setBackground(Colour.GRAY_25); // 여름에 맞는 색깔 두번째 ? ^^
mySheet.setColumnView(0, 8);
mySheet.setColumnView(1, 10);
mySheet.setColumnView(2, 6);
mySheet.setColumnView(3, 6);
mySheet.setColumnView(4, 30);
mySheet.setColumnView(5, 30);
mySheet.setRowView(3,700);
mySheet.setRowView(9,600);
mySheet.mergeCells(0,3,5,3);
Label nameLabel = new Label(0, 3, "수질관리 절차서", titleFormat);
mySheet.addCell(nameLabel);
Label nameLabel7 = new Label(0, 9, "개정차수", topFormat);
mySheet.addCell(nameLabel7);
Label nameLabel8 = new Label(1, 9, "일자", topFormat);
mySheet.addCell(nameLabel8);
Label nameLabel9 = new Label(2, 9, "기안자", topFormat);
mySheet.addCell(nameLabel9);
Label nameLabel12 = new Label(3, 9, "Page", topFormat);
mySheet.addCell(nameLabel12);
Label nameLabel10 = new Label(4, 9, "제 · 개정 사유", topFormat);
mySheet.addCell(nameLabel10);
Label nameLabel11 = new Label(5, 9, "개정 전 · 후 내용 ", topFormat);
mySheet.addCell(nameLabel11);
List articleList=null;
Manager manager = Manager.instance();
String reg_date=request.getParameter("reg_date").substring(0,4)+request.getParameter("reg_date").substring(5,7)+request.getParameter("reg_date").substring(8,10);
articleList = manager.getArticles2(reg_date);
Iterator iter = articleList.iterator();
int i=0;
while(iter.hasNext()){
ElForm article = (ElForm)iter.next();
mySheet.setRowView(10+i,800);
Label nameLabel13 = new Label(0, 10+i, Integer.toString(article.getStep_cha()), dataFormat);
mySheet.addCell(nameLabel13);
Label nameLabel14 = new Label(1, 10+i, article.getReg_date(), dataFormat);
mySheet.addCell(nameLabel14);
Label nameLabel15 = new Label(2, 10+i, article.getGian_emp(), dataFormat);
mySheet.addCell(nameLabel15);
Label nameLabel16 = new Label(3, 10+i, article.getPage(), dataFormat);
mySheet.addCell(nameLabel16);
Label nameLabel17 = new Label(4, 10+i, article.getReason().replaceAll("\r", ""), dataFormat2); //.replaceAll("\r", "") 수식을 텍스트로 변경
mySheet.addCell(nameLabel17);
Label nameLabel18 = new Label(5, 10+i, article.getBef_aft_con().replaceAll("\r", ""), dataFormat2);
mySheet.addCell(nameLabel18);
i++;
}
myWorkbook.write();
myWorkbook.close();
'프로그래밍 > java' 카테고리의 다른 글
자바 시리얼 통신 설명 자료[펌] (0) | 2009.06.10 |
---|---|
jxl (0) | 2009.06.10 |
jxl 수정 (0) | 2009.06.10 |
POI (0) | 2009.06.10 |
문자열 자르기 ( substring ) (0) | 2009.06.10 |