개발중/Java

java / Excel 만들기 할 때 이거 갖다 쓰기

Binsoo 2021. 7. 13. 11:52
728x90
반응형

 

	public void createWorkbookIp(String comSeqs, String sdate, String edate, String path ) throws ParseException {

		HSSFWorkbook workbook = new HSSFWorkbook();
		HSSFSheet    sheet    = workbook.createSheet("계정별 검색로그");
		
		sheet.setColumnWidth(1, 8000 );
		sheet.setColumnWidth(2, 10000);
		
		int rowLocation = 0;
		
		Row row = null;
		Cell cell = null;
		
		row = sheet.createRow( ++rowLocation );
		cell = row.createCell(1);
		cell.setCellValue("TITLE");
		
		cell = row.createCell(2);
		cell.setCellValue("CONTENT");
		
		
		row = sheet.createRow( ++rowLocation );
		cell = row.createCell(1);
		cell.setCellValue("제 목");
		
		cell = row.createCell(2);
		cell.setCellValue("컨텐츠");
		
		try {
			File file = new File(path);
			FileOutputStream out = new FileOutputStream(file);
			
			workbook.write(out);
			out.flush();
			out.close();
			
		}catch (Exception e) {
			e.printStackTrace();
		}
		
	}
728x90
반응형