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


Java XSSFSheet.addMergedRegion方法代碼示例

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


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

示例1: createMergedRegionIfNotPresent

import org.apache.poi.xssf.usermodel.XSSFSheet; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
>>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
	public static void createMergedRegionIfNotPresent(XSSFSheet sheet,int firstRow, int lastRow, int firstCol, int lastCol){
		String message="XSSFSheet must not be null!";
		Objects.requireNonNull(sheet, () -> message);
		sheet.addMergedRegion(new CellRangeAddress(firstRow,  lastRow,  firstCol,  lastCol)); 
	}
 
開發者ID:gp15237125756,項目名稱:PoiExcelExport2.0,代碼行數:8,代碼來源:XSSFCellUtil.java

示例2: copyRow

import org.apache.poi.xssf.usermodel.XSSFSheet; //導入方法依賴的package包/類
/**
 * @param srcSheet the sheet to copy.
 * @param destSheet the sheet to create.
 * @param srcRow the row to copy.
 * @param destRow the row to create.
 * @param styleMap -
 */
public static void copyRow(XSSFSheet srcSheet, XSSFSheet destSheet, XSSFRow srcRow, XSSFRow destRow, Map<Integer, XSSFCellStyle> styleMap) {
    // manage a list of merged zone in order to not insert two times a merged zone  
    Set<CellRangeAddressWrapper> mergedRegions = new TreeSet<CellRangeAddressWrapper>();
    destRow.setHeight(srcRow.getHeight());
    // pour chaque row  
    for (int j = srcRow.getFirstCellNum(); j <= srcRow.getLastCellNum(); j++) {
        if(j<0){
        }else{
            XSSFCell oldCell = srcRow.getCell(j);   // ancienne cell  
        XSSFCell newCell = destRow.getCell(j);  // new cell   
        if (oldCell != null) {
            if (newCell == null) {
                newCell = destRow.createCell(j);
            }
            // copy chaque cell  
            copyCell(oldCell, newCell, styleMap);
                  // copy les informations de fusion entre les cellules  
            //System.out.println("row num: " + srcRow.getRowNum() + " , col: " + (short)oldCell.getColumnIndex());  
            CellRangeAddress mergedRegion = getMergedRegion(srcSheet, srcRow.getRowNum(), (short) oldCell.getColumnIndex());

            if (mergedRegion != null) {
                //System.out.println("Selected merged region: " + mergedRegion.toString());  
                CellRangeAddress newMergedRegion = new CellRangeAddress(mergedRegion.getFirstRow(), mergedRegion.getLastRow(), mergedRegion.getFirstColumn(), mergedRegion.getLastColumn());
                //System.out.println("New merged region: " + newMergedRegion.toString());  
                CellRangeAddressWrapper wrapper = new CellRangeAddressWrapper(newMergedRegion);
                if (isNewMergedRegion(wrapper, mergedRegions)) {
                    mergedRegions.add(wrapper);
                    destSheet.addMergedRegion(wrapper.range);
                }
            }
        }
        }
        
    }

}
 
開發者ID:likelet,項目名稱:DAtools,代碼行數:44,代碼來源:Util.java

示例3: createMergedRegionIfNotPresent

import org.apache.poi.xssf.usermodel.XSSFSheet; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
public static void createMergedRegionIfNotPresent(XSSFSheet sheet,int firstRow, int lastRow, int firstCol, int lastCol){
	String message="XSSFSheet must not be null!";
	Objects.requireNonNull(sheet, () -> message);
	sheet.addMergedRegion(new CellRangeAddress(firstRow,  lastRow,  firstCol,  lastCol)); 
}
 
開發者ID:gp15237125756,項目名稱:PoiExcelExport,代碼行數:7,代碼來源:XSSFCellUtil.java

示例4: mergedRegionForItemsRow

import org.apache.poi.xssf.usermodel.XSSFSheet; //導入方法依賴的package包/類
private int mergedRegionForItemsRow(XSSFWorkbook wb, XSSFSheet sh, int row, List<PdcaItemVO> items) throws Exception {
	sh.addMergedRegion( new CellRangeAddress(row, row+items.size()-1, 0, 0) );
	sh.addMergedRegion( new CellRangeAddress(row, row+items.size()-1, 4, 4) );
	sh.addMergedRegion( new CellRangeAddress(row, row+items.size()-1, 5, 5) );
	return row + items.size();
}
 
開發者ID:billchen198318,項目名稱:bamboobsc,代碼行數:7,代碼來源:PdcaReportExcelCommand.java

示例5: createFoot

import org.apache.poi.xssf.usermodel.XSSFSheet; //導入方法依賴的package包/類
private void createFoot(XSSFWorkbook wb, XSSFSheet sh, int row, VisionVO vision, Context context) throws Exception {
	
	Row footRow=sh.createRow(row);
	Row footRowB=sh.createRow(row+1);
	XSSFCellStyle cellStyle=wb.createCellStyle();
	
	cellStyle.setFillForegroundColor( new XSSFColor(SimpleUtils.getColorRGB4POIColor("#FFFFFF")) );
	cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);		
	cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
	cellStyle.setBorderBottom(BorderStyle.THIN);
	cellStyle.setBorderTop(BorderStyle.THIN);
	cellStyle.setBorderRight(BorderStyle.THIN);
	cellStyle.setBorderLeft(BorderStyle.THIN);					
	XSSFFont cellFont=wb.createFont();
	cellFont.setBold(true);
	cellStyle.setFont(cellFont);
	cellStyle.setWrapText(true);		
	
	Cell footCell1 = footRow.createCell(0);
	footCell1.setCellValue("assess:");
	footCell1.setCellStyle(cellStyle);			
	Cell footCell1B = footRowB.createCell(0);
	footCell1B.setCellValue("assess:");
	footCell1B.setCellStyle(cellStyle);		
	sh.addMergedRegion(new CellRangeAddress(row, row+1, 0, 0));					
	
	Cell footCell2 = footRow.createCell(1);
	footCell2.setCellValue( BscReportPropertyUtils.getPersonalReportClassLevel() );
	footCell2.setCellStyle(cellStyle);					
	Cell footCell3 = footRow.createCell(2);
	footCell3.setCellValue( BscReportPropertyUtils.getPersonalReportClassLevel() );
	footCell3.setCellStyle(cellStyle);			
	Cell footCell4 = footRow.createCell(3);
	footCell4.setCellValue( BscReportPropertyUtils.getPersonalReportClassLevel() );
	footCell4.setCellStyle(cellStyle);			
	Cell footCell2B = footRowB.createCell(1);
	footCell2B.setCellValue( BscReportPropertyUtils.getPersonalReportClassLevel() );
	footCell2B.setCellStyle(cellStyle);					
	Cell footCell3B = footRowB.createCell(2);
	footCell3B.setCellValue( BscReportPropertyUtils.getPersonalReportClassLevel() );
	footCell3B.setCellStyle(cellStyle);			
	Cell footCell4B = footRowB.createCell(3);
	footCell4B.setCellValue( BscReportPropertyUtils.getPersonalReportClassLevel() );
	footCell4B.setCellStyle(cellStyle);					
	sh.addMergedRegion(new CellRangeAddress(row, row+1, 1, 3));	
	
	Cell footCell5 = footRow.createCell(4);
	footCell5.setCellValue("Total");
	footCell5.setCellStyle(cellStyle);	
	
	float total = 0.0f;
	if ( context.get("total")!=null && context.get("total") instanceof Float ) {
		total = (Float)context.get("total");
	}
	
	Cell footCell6 = footRow.createCell(5);
	footCell6.setCellValue( BscReportSupportUtils.parse2(total) );
	footCell6.setCellStyle(cellStyle);			
	
	Cell footCell5b = footRowB.createCell(4);
	footCell5b.setCellValue("Class");
	footCell5b.setCellStyle(cellStyle);			
	
	Cell footCell6b = footRowB.createCell(5);
	footCell6b.setCellValue( "" );
	footCell6b.setCellStyle(cellStyle);				
	
}
 
開發者ID:billchen198318,項目名稱:bamboobsc,代碼行數:69,代碼來源:PersonalReportExcelCommand.java


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