반응형

[python] 엑셀 읽고 쓰기 

 

https://pypi.org/project/openpyxl/

 

openpyxl

A Python library to read/write Excel 2010 xlsx/xlsm files

pypi.org

 

pip install openpyxl

 

반응형
반응형

[엑셀] 틀고정 2개 하기. 

 

[보기] - [틀고정]  

 - 첫 행 고정

 - 첫 열 고정

  : 첫 열이나 첫 행을 고정해서 첫 열이나 행에 내용을 추가해도 된다. 

 

-  틀고정

  : D,E열과 E열 4번과 5번열을 틀고정으로 구분하고 싶으면 바로 밑인 E열5번 셀을 선택하고 틀고정을 눌러주면 된다.  

반응형
반응형

[EXCEL] 지정한 수만큼 지정한 문자를 반복해 주는 REPT 함수

 

* REPT 함수

수치만큼 지정한 문자를 반복 표시해 준다.

형식 : =REPT("반복할문자", "반복할 숫자 또는 셀주소)


 

 

반응형
반응형

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(); 

반응형
반응형

[POI] POI 엑셀 - Using newlines in cells ( 셀에서 줄바꿈 )
//////////////////////////////
cs.setWrapText( true );
//////////////////////////////////

 

// 엑셀 파일 로드
HSSFWorkbook wb = excelService.loadWorkbook(sb.toString());
 
HSSFSheet sheet = wb.createSheet("cell test sheet2");
sheet.setColumnWidth((short) 3, (short) 200);	// column Width
 
HSSFCellStyle cs = wb.createCellStyle();
HSSFFont font = wb.createFont();
font.setFontHeight((short) 16);
font.setBoldweight((short) 3);
font.setFontName("fixedsys");
 
cs.setFont(font);
cs.setAlignment(HSSFCellStyle.ALIGN_RIGHT);	// cell 정렬
cs.setWrapText( true );
 
for (int i = 0; i < 100; i++) {
	HSSFRow row = sheet.createRow(i);
	row.setHeight((short)300); // row의 height 설정
 
	for (int j = 0; j < 5; j++) {
		HSSFCell cell = row.createCell((short) j);
		cell.setCellValue(new HSSFRichTextString("row " + i + ", cell " + j));
		cell.setCellStyle( cs );
	}
}
 
// 엑셀 파일 저장
FileOutputStream out = new FileOutputStream(sb.toString());
wb.write(out);
out.close();

https://www.egovframe.go.kr/wiki/doku.php?id=egovframework:rte2:fdl:excel

 

egovframework:rte2:fdl:excel [eGovFrame]

Excel 파일 포맷을 다룰 수 있는 자바 라이브러리를 제공하여, 사용자들이 데이터를 Excel 파일 포맷으로 다운받거나, 대량의 Excel 데이터를 시스템에 올릴 수 있도록 지원하기 위한 서비스이다. Excel 서비스는 Apache POI 오픈소스를 사용하여 구현하였으며 주요 Excel접근 기능 외에 Excel 다운로드, Excel 파일 업로드 등의 기능이 있다. 엑셀 파일을 생성하여 지정된 위치에 저장하는 기능을 제공한다. HSSFWorkbook 인스

www.egovframe.go.kr

 

반응형

+ Recent posts