private void mergeRows(Sheet sheet,CellStyle cellStyle,ExcelMeta excelMeta) {
    	
    	Row row = null;
    	Cell cell = null;
    	String[] lastRowVals = new String[excelMeta.getTitleColumnNum()];
    	for (int r = 0; r < excelMeta.getTitleRowNum(); r++) {
			for (int c = 0; c < excelMeta.getTitleColumnNum(); c++) {
				row = sheet.getRow(r);
                cell = row.getCell(c);
                if(r == 0){
                	lastRowVals[c] = cell.getStringCellValue();
                }else{                	
                	if(StringUtils.equals(lastRowVals[c],cell.getStringCellValue())){
                		cell.setCellValue("");
                		sheet.addMergedRegion(new CellRangeAddress(0, r, c, c));
                		Cell nowCell = sheet.getRow(0).getCell(c);
                		nowCell.setCellStyle(cellStyle);
                	}
                }
                
			}
		}
    
    }
private void mergeRows ( Sheet sheet , CellStyle cellStyle , ExcelMeta excelMeta ) { Row row = null ; Cell cell = null ; String [ ] lastRowVals = new String [ excelMeta . getTitleColumnNum ( ) ] ; for ( int r = 0 ; r < excelMeta . getTitleRowNum ( ) ; r ++ ) { for ( int c = 0 ; c < excelMeta . getTitleColumnNum ( ) ; c ++ ) { row = sheet . getRow ( r ) ; cell = row . getCell ( c ) ; if ( r == 0 ) { lastRowVals [ c ] = cell . getStringCellValue ( ) ; } else { if ( StringUtils . equals ( lastRowVals [ c ] , cell . getStringCellValue ( ) ) ) { cell . setCellValue ( "" ) ; sheet . addMergedRegion ( new CellRangeAddress ( 0 , r , c , c ) ) ; Cell nowCell = sheet . getRow ( 0 ) . getCell ( c ) ; nowCell . setCellStyle ( cellStyle ) ; } } } } }
TODO 暂时支持两行表头