JAVA excel - [POI] POI 엑셀 - Using newlines in cells ( 셀에서 줄바꿈 )
 CellStyle cs = wb.createCellStyle(); 
    cs.setWrapText(true); 
    cell.setCellStyle(cs);
   Workbook wb = new XSSFWorkbook();   //or new HSSFWorkbook();
    Sheet sheet = wb.createSheet();
    Row row = sheet.createRow(2);
    Cell cell = row.createCell(2);
    cell.setCellValue("Use \n with word wrap on to create a new line");
    //to enable newlines you need set a cell styles with wrap=true
    CellStyle cs = wb.createCellStyle();
    cs.setWrapText(true);
    cell.setCellStyle(cs);
    //increase row height to accomodate two lines of text
    row.setHeightInPoints((2*sheet.getDefaultRowHeightInPoints()));
    //adjust column width to fit the content
    sheet.autoSizeColumn((short)2);
    FileOutputStream fileOut = new FileOutputStream("ooxml-newlines.xlsx");
    wb.write(fileOut);
    fileOut.close(); 
'프로그래밍 > JAVA' 카테고리의 다른 글
| Java Default Heap/Perm Size 알아내는 방법 (0) | 2020.12.11 | 
|---|---|
| 자바 명명 규칙 - 클래스 / 메서드 / 변수 (0) | 2020.06.18 | 
| [JEUS 8] response charset 변경하기 페이지 인코딩 변경 (0) | 2020.01.04 | 
| [POI] POI 엑셀 - Using newlines in cells ( 셀에서 줄바꿈 ) (0) | 2019.12.30 | 
| [Java] 문자열 치환(Replace) 사용법 & 예제 (0) | 2019.12.30 | 

