When poi merges the cells of a table in word, cross-row merging is correct and cross-column merging fails.

when poi merges the cells of a table in word, cross-row merging can be done correctly, while cross-column merging fails. The following is the code for merging columns


 public  void mergeCellsHorizontal(XWPFTable table, int row, int fromCell, int toCell) {  
        for (int cellIndex = fromCell; cellIndex <= toCell; cellIndexPP) {  
            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);  
            }  
        }  
    }  

do you know why?

Feb.28,2021

use addNewHMerge (), across columns and addNewVMerge () across rows. Recently, I have also been using poi to export word, and found that it is actually two different methods. To be careful, brother dei


has the landlord solved it? I have the same problem!


the merged column needs to be set to the appropriate width.
cell.getCTTc (). AddNewTcPr (). AddNewHMerge (). SetVal (STMerge.RESTART);
followed by
/ / cellCount is the total number of columns in the table
Integer width = (toCell-fromCell+1) / cellCount*table.getCTTbl (). GetTblPr (). GetTblW (). GetW (). IntValue ();
cell.getCTTc (). GetTcPr (). AddNewTcW (). SetW (BigInteger.valueOf (width));

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e93b69-461c0.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e93b69-461c0.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?