POI, Excel 숫자 셀 생성
Java2015. 6. 30. 14:50
POI, Excel 숫자 셀 생성
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | /** * 숫자 서식 셀을 생성한다. * 세로 맞춤 : 가운데 * 테두리 : 모두 * @param row * @param nCell 생성할 셀 인덱스 * @param font 글꼴 * @param bgColor 배경색 * @param hAlign 가로 맞춤 * @return */ private XSSFCell createNumericCell(XSSFRow row, int nCell, Font font, XSSFColor bgColor, short hAlign) { short vAlign = CellStyle.VERTICAL_CENTER; short border = CellStyle.BORDER_THIN; XSSFSheet sheet = row.getSheet(); XSSFWorkbook wb = sheet.getWorkbook(); XSSFCellStyle cs = wb.createCellStyle(); cs.setAlignment(hAlign); cs.setVerticalAlignment(vAlign); cs.setBorderTop(border); cs.setBorderRight(border); cs.setBorderBottom(border); cs.setBorderLeft(border); cs.setFont(font); //배경색 설정 if (bgColor != null ) { cs.setFillForegroundColor(bgColor); cs.setFillPattern(CellStyle.SOLID_FOREGROUND); } XSSFDataFormat df = (XSSFDataFormat) wb.createDataFormat(); cs.setDataFormat(df.getFormat( "#,###" )); XSSFCell cell = row.createCell(nCell); cell.setCellStyle(cs); return cell; } |
'Java' 카테고리의 다른 글
JDK 8 인스톨 없이 설치하기 (0) | 2018.10.20 |
---|---|
사진 이미지 크기 변경 후 Base64 문자열 변환 (0) | 2018.04.26 |
POI, Excel 셀 생성 (0) | 2015.06.30 |
POI, Excel 병합 셀 생성 (0) | 2015.06.30 |
POI, Excel 한 Cell에 여러 줄 표시 (0) | 2015.06.30 |