poi 跨列合并word中的表格的单元格

poi 合并word中的表格的单元格时,跨行可以正确合并,跨列合并则失败, 以下是合并列的代码:(poi 版本是 3.14 )

  public  void mergeCellsHorizontal(XWPFTable table, int row, int fromCell, int toCell) {  
        for (int cellIndex = fromCell; cellIndex <= toCell; cellIndex++) {  
            XWPFTableCell cell = table.getRow(row).getCell(cellIndex);  
            if ( cellIndex == fromCell ) {  
                // The first merged cell is set with RESTART merge value  
                cell.getCTTc().addNewTcPr().addNewHMerge().setVal(STMerge.RESTART);  
            } else {  
                // Cells which join (merge) the first one, are set with CONTINUE  
                cell.getCTTc().addNewTcPr().addNewHMerge().setVal(STMerge.CONTINUE);  
            }  
        }  
    }

最后研究发现,该行代码在word2010有用,在wps中无效

http://blog.csdn.net/rudy1245/article/details/53421366