当前位置: 首页>>代码示例>>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;未经允许,请勿转载。