欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

POI导出word单元格合并

程序员文章站 2022-06-14 09:10:30
...

1、跨列合并

POI导出word单元格合并

 //合并单元格
  			    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导出word单元格合并

相关标签: poi java