當前位置: 首頁>>代碼示例>>Java>>正文


Java HSSFSheet.setDefaultColumnWidth方法代碼示例

本文整理匯總了Java中org.apache.poi.hssf.usermodel.HSSFSheet.setDefaultColumnWidth方法的典型用法代碼示例。如果您正苦於以下問題:Java HSSFSheet.setDefaultColumnWidth方法的具體用法?Java HSSFSheet.setDefaultColumnWidth怎麽用?Java HSSFSheet.setDefaultColumnWidth使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.poi.hssf.usermodel.HSSFSheet的用法示例。


在下文中一共展示了HSSFSheet.setDefaultColumnWidth方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: buildExcelDocument

import org.apache.poi.hssf.usermodel.HSSFSheet; //導入方法依賴的package包/類
@Override
protected void buildExcelDocument(Map<String, Object> model,
		HSSFWorkbook workbook, HttpServletRequest request, HttpServletResponse response)
		throws Exception {
	// get data model which is passed by the Spring container
	List<RatingCountBean> listOfRating = (List<RatingCountBean>) model.get("listOfRatingCount");
	
	// create a new Excel sheet
	HSSFSheet sheet = workbook.createSheet("Feedback Report");
	sheet.setDefaultColumnWidth(30);
	
	// create style for header cells
	CellStyle style = workbook.createCellStyle();
	Font font = workbook.createFont();
	font.setFontName("Arial");
	style.setFillForegroundColor(HSSFColor.BLUE.index);
	style.setFillPattern(CellStyle.SOLID_FOREGROUND);
	font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
	font.setColor(HSSFColor.WHITE.index);
	style.setFont(font);
	
	// create header row
	HSSFRow header = sheet.createRow(0);
	
               
               header.createCell(0).setCellValue("Question Number");
	header.getCell(0).setCellStyle(style);
               
	header.createCell(1).setCellValue("Question");
	header.getCell(1).setCellStyle(style);
	
	header.createCell(2).setCellValue("Very Poor");
	header.getCell(2).setCellStyle(style);
	
	header.createCell(3).setCellValue("Poor");
	header.getCell(3).setCellStyle(style);
	
	header.createCell(4).setCellValue("Good");
	header.getCell(4).setCellStyle(style);
	
	header.createCell(5).setCellValue("Best");
	header.getCell(5).setCellStyle(style);
               
               header.createCell(6).setCellValue("Excellent");
	header.getCell(6).setCellStyle(style);
	
	// create data rows
	int rowCount = 1;
	
	for (RatingCountBean rating : listOfRating) {
		HSSFRow aRow = sheet.createRow(rowCount++);
		aRow.createCell(0).setCellValue(rating.getQuestionId());
		aRow.createCell(1).setCellValue(rating.getQuestionText());
		aRow.createCell(2).setCellValue(rating.getRating_one_total_count());
		aRow.createCell(3).setCellValue(rating.getRating_two_total_count());
		aRow.createCell(4).setCellValue(rating.getRating_three_total_count());
                       aRow.createCell(5).setCellValue(rating.getRating_four_total_count());
                       aRow.createCell(6).setCellValue(rating.getRating_five_total_count());
	}
}
 
開發者ID:mustafamym,項目名稱:FeedbackCollectionAndMgmtSystem,代碼行數:61,代碼來源:ExcelBuilder.java

示例2: buildExcelDocument

import org.apache.poi.hssf.usermodel.HSSFSheet; //導入方法依賴的package包/類
@Override
   protected void buildExcelDocument(Map<String, Object> model,
           HSSFWorkbook workbook, HttpServletRequest request, HttpServletResponse response)
           throws Exception {
       // get data model which is passed by the Spring container
       @SuppressWarnings("unchecked")
	List<HrmsLogin> users = (List<HrmsLogin>) model.get("allUsers");
        
       // create a new Excel sheet
       HSSFSheet sheet = workbook.createSheet("User List");
       sheet.setDefaultColumnWidth(30);
        
       // create style for header cells
       CellStyle style = workbook.createCellStyle();
       Font font = workbook.createFont();
       font.setFontName("Arial");
       style.setFillForegroundColor(HSSFColor.BLUE.index);
       style.setFillPattern(CellStyle.SOLID_FOREGROUND);
       font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
       font.setColor(HSSFColor.WHITE.index);
       style.setFont(font);
        
       // create header row
       HSSFRow header = sheet.createRow(0);
        
       header.createCell(0).setCellValue("Employee ID");
       header.getCell(0).setCellStyle(style);
        
       header.createCell(1).setCellValue("Username");
       header.getCell(1).setCellStyle(style);
        
       header.createCell(2).setCellValue("Password");
       header.getCell(2).setCellStyle(style);
        
       header.createCell(3).setCellValue("Role");
       header.getCell(3).setCellStyle(style);
        
             
       // create data rows
       int rowCount = 1;
        
       for (HrmsLogin account : users) {
           HSSFRow aRow = sheet.createRow(rowCount++);
           aRow.createCell(0).setCellValue(account.getHrmsEmployeeDetails().getEmpId());
           aRow.createCell(1).setCellValue(account.getUsername());
           aRow.createCell(2).setCellValue(account.getPassword());
           aRow.createCell(3).setCellValue(account.getRole());
          
       }
       
}
 
開發者ID:PacktPublishing,項目名稱:Spring-MVC-Blueprints,代碼行數:52,代碼來源:HRExcelBuilder.java

示例3: buildExcelDocument

import org.apache.poi.hssf.usermodel.HSSFSheet; //導入方法依賴的package包/類
/**
 * 엑셀파일을 설정하고 생성한다.
 * 
 * @param model
 * @param wb
 * @param request
 * @param response
 * @throws Exception
 */
@SuppressWarnings("unchecked")
@Override
protected void buildExcelDocument(Map<String, Object> model,
		HSSFWorkbook wb, HttpServletRequest request,
		HttpServletResponse response) throws Exception {

	String fileName = "CommonCode.xls"; 
	fileName = new String(fileName.getBytes("euc-kr"), "8859_1"); 
	response.setHeader("Content-Disposition", "attachment; fileName=\"" + fileName + "\";"); 
	response.setHeader("Content-Transfer-Encoding", "binary"); 

	HSSFCell cell = null;

	HSSFSheet sheet = wb.createSheet("Codes List");
	sheet.setDefaultColumnWidth(12);

	// set header information
	setText(getCell(sheet, 0, 0), "No.");
	setText(getCell(sheet, 0, 1), "코드ID");
	setText(getCell(sheet, 0, 2), "코드ID명");
	setText(getCell(sheet, 0, 3), "코드");
	setText(getCell(sheet, 0, 4), "코드명");
	setText(getCell(sheet, 0, 5), "사용여부");

	List<EgovMap> resultList = (List<EgovMap>) model.get("resultList");

	for (int i = 0; i < resultList.size(); i++) {
		EgovMap result = resultList.get(i);

		cell = getCell(sheet, 1 + i, 0);
		setText(cell, Integer.toString(i + 1));

		cell = getCell(sheet, 1 + i, 1);
		setText(cell, (String)result.get("codeId"));

		cell = getCell(sheet, 1 + i, 2);
		setText(cell, (String)result.get("codeIdNm"));

		cell = getCell(sheet, 1 + i, 3);
		setText(cell, (String)result.get("code"));

		cell = getCell(sheet, 1 + i, 4);
		setText(cell, (String)result.get("codeNm"));

		cell = getCell(sheet, 1 + i, 5);
		setText(cell, (String)result.get("useAt"));
	}
}
 
開發者ID:aramsoft,項目名稱:aramcomp,代碼行數:58,代碼來源:ExcelCmmnDetailView.java

示例4: buildExcelDocument

import org.apache.poi.hssf.usermodel.HSSFSheet; //導入方法依賴的package包/類
/**
 * 엑셀파일을 설정하고 생성한다.
 * 
 * @param model
 * @param wb
 * @param request
 * @param response
 * @throws Exception
 */
@SuppressWarnings("unchecked")
@Override
protected void buildExcelDocument(Map<String, Object> model,
		HSSFWorkbook wb, HttpServletRequest request,
		HttpServletResponse response) throws Exception {

	String fileName = "메뉴.xls"; 
	fileName = new String(fileName.getBytes("euc-kr"), "8859_1"); 
	response.setHeader("Content-Disposition", "attachment; fileName=\"" + fileName + "\";"); 
	response.setHeader("Content-Transfer-Encoding", "binary"); 

	HSSFCell cell = null;

	HSSFSheet sheet = wb.createSheet("메뉴 List");
	sheet.setDefaultColumnWidth(20);

	// set header information
	setText(getCell(sheet, 0, 0), "매뉴번호");
	setText(getCell(sheet, 0, 1), "메뉴명");
	setText(getCell(sheet, 0, 2), "프로그램명");
	setText(getCell(sheet, 0, 3), "메뉴설명");
	setText(getCell(sheet, 0, 4), "사용여부");
	setText(getCell(sheet, 0, 5), "관리자여부");
	setText(getCell(sheet, 0, 6), "바로가기url");
	setText(getCell(sheet, 0, 7), "톱메뉴여부");
	setText(getCell(sheet, 0, 8), "메뉴별명");
	
	List<EgovMap> resultList = (List<EgovMap>) model.get("resultList");

	for (int i = 0; i < resultList.size(); i++) {
		EgovMap result = resultList.get(i);

		cell = getCell(sheet, 1 + i, 0);
		setText(cell, String.valueOf(result.get("menuNo")));

		cell = getCell(sheet, 1 + i, 1);
		setText(cell, (String)result.get("menuNm"));

		cell = getCell(sheet, 1 + i, 2);
		setText(cell, (String)result.get("progrmFileNm"));

		cell = getCell(sheet, 1 + i, 3);
		setText(cell, (String)result.get("menuDc"));

		cell = getCell(sheet, 1 + i, 4);
		setText(cell, (String)result.get("useAt"));
		
		cell = getCell(sheet, 1 + i, 5);
		setText(cell, (String)result.get("mgrAt"));
		
		cell = getCell(sheet, 1 + i, 6);
		setText(cell, (String)result.get("directUrl"));
		
		cell = getCell(sheet, 1 + i, 7);
		setText(cell, (String)result.get("topMenuAt"));
		
		cell = getCell(sheet, 1 + i, 8);
		setText(cell, (String)result.get("menuAlias"));
	}
}
 
開發者ID:aramsoft,項目名稱:aramcomp,代碼行數:70,代碼來源:ExcelCmyMenuView.java

示例5: publishResults

import org.apache.poi.hssf.usermodel.HSSFSheet; //導入方法依賴的package包/類
private void publishResults(String filename) {
//        System.out.println("DEBUG - starting generation of the excel file.");
        try {
            HSSFWorkbook workbook = new HSSFWorkbook();
            int rowCounter;
            int cellCounter;
            boolean generateHead;

            /* generating one sheet for each log */
            for( String miningAlgorithmName : measures.keySet() ) {
                generateHead = true;
                rowCounter = 0;

                HSSFSheet sheet = workbook.createSheet(miningAlgorithmName);
                sheet.setDefaultColumnWidth(12);
                HSSFRow rowhead = sheet.createRow((short) rowCounter);
                rowCounter++;

                for( String logName : measures.get(miningAlgorithmName).keySet() ) {
                    /* creating the row for this mining algorithm */
                    HSSFRow row = sheet.createRow((short) rowCounter);
                    rowCounter++;

                    cellCounter = 0;
                    if( generateHead ) rowhead.createCell(cellCounter).setCellValue("Log");
                    row.createCell(cellCounter).setCellValue(logName);
                    cellCounter++;

                    ArrayList<String> metrics = new ArrayList<>(measures.get(miningAlgorithmName).get(logName).keySet());
                    Collections.sort(metrics);

                    for( int i = 0; i < metrics.size(); i++ ) {
                        String metricName = metrics.get(i);
                        if( generateHead ) rowhead.createCell(cellCounter).setCellValue(metricName);
                        row.createCell(cellCounter).setCellValue(measures.get(miningAlgorithmName).get(logName).get(metricName));
                        cellCounter++;
                    }
                    generateHead = false;
                }
            }

            FileOutputStream fileOut = new FileOutputStream(filename);
            workbook.write(fileOut);
            fileOut.close();
            System.out.println("DEBUG - results exported to: " + filename);
        } catch ( Exception e ) {
            System.out.println("ERROR - something went wrong while writing the excel sheet: " + e.getMessage());
            e.printStackTrace();
        }
    }
 
開發者ID:raffaeleconforti,項目名稱:ResearchCode,代碼行數:51,代碼來源:Benchmark.java


注:本文中的org.apache.poi.hssf.usermodel.HSSFSheet.setDefaultColumnWidth方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。