POI导出word单元格合并

1、跨列合并

在这里插入图片描述

 //合并单元格
  			    for (int cellIndex = 2; cellIndex <= 3; cellIndex++) {  
    	            XWPFTableCell cellMerge = row.getCell(cellIndex);  
    	            if ( cellIndex == 2 ) {  
    	                // The first merged cell is set with RESTART merge value  
    	            	cellMerge.getCTTc().addNewTcPr().addNewHMerge().setVal(STMerge.RESTART);  
    	            } else {  
    	                // Cells which join (merge) the first one, are set with CONTINUE  
    	            	cellMerge.getCTTc().addNewTcPr().addNewHMerge().setVal(STMerge.CONTINUE);  
    	            }  
    	        }

在这里插入图片描述

你可能感兴趣的:(文档操作,poi)