지정된 양식에 하나의 ROW만 존재한 상황에서
두번째 줄부터는 아래와 같은 함수를 이용하여 값을 write한다.
1) ROW가 있는지 확인
- 해당 ROW가 정해져있는 양식이 있는지 확인
- 없으면 create row
2) Cell이 있는지 확인
- 해당 ROW는 위에서 만들었기 때문에 존재함.
- 해당 ROW, CELL에 정해져 있는 양식이 있는지 확인
- 없으면 create cell
- 바로 위 row에서 style을 가지고와서 지정
- 값 wirte
protected void writeLabelCell(HSSFSheet sheet, int _row, int _col, String str){
try{
HSSFRow row = sheet.getRow(_row);
if(row == null){
row = sheet.createRow(_row);
}
HSSFCell cell = row.getCell(_col);
if(cell == null){ // CELL이 없으면 바로 위 행의 ROW의 CELL 스타일을 가지고 옴.
HSSFRow refRow = sheet.getRow((_row-1));
HSSFCell refCell = refRow.getCell(_col);
cell = row.createCell(_col);
cell.setCellStyle(refCell.getCellStyle());
}
try{
row = sheet.getRow(_row);
cell = row.getCell(_col);
cell.setCellValue(str);
}catch(Exception e){
e.printStackTrace();
}
}catch(Exception e){
e.printStackTrace();
}
}
'JAVA' 카테고리의 다른 글
Statement를 사용하지 말고 PreparedStatement 사용하도록! (0) | 2013.10.01 |
---|---|
IP찾기 (0) | 2013.02.26 |
Java - 자주사용하는 Collection객체들의 특징 (0) | 2013.02.08 |
[JAVA] 프로세스 리스트 출력 - 확인해보기 (0) | 2013.02.08 |
[JAVA] String의 날짜를 date로 변환 (0) | 2013.01.25 |