水平合并单元格时需要从右侧删除边框

时间:2019-11-02 08:21:58

标签: apache-poi apache-poi-4

我正在尝试将边框添加到合并的单元格中,但是使用下面的代码行是不可能的:

XWPFDocument document = new XWPFDocument();
XWPFTable table = document.createTable(1, 8);
CTTblBorders borders = table.getCTTbl().getTblPr().addNewTblBorders();
borders.addNewBottom().setVal(STBorder.THICK);
borders.addNewLeft().setVal(STBorder.NONE);
borders.addNewRight().setVal(STBorder.NONE);
borders.addNewTop().setVal(STBorder.THICK);
borders.addNewInsideV().setVal(STBorder.THICK);
table.getCTTbl().getTblPr().setTblBorders(borders);
table.setWidth(1440);

for (int col = 0 ; col < 8; col++) {
CTTblWidth tblWidth = table.getRow(0).getCell(col).getCTTc().addNewTcPr().addNewTcW();
tblWidth.setW(BigInteger.valueOf(1440));
//STTblWidth.DXA is used to specify width in twentieths of a point.
tblWidth.setType(STTblWidth.DXA);
}    
**mergeCellHorizontally(table, 0, 0, 1);**
XWPFTableCell cell = table.getRow(0).getCell(1);
CTTcPr ctTcPr = cell.getCTTc().getTcPr();
CTTcBorders ctTcBorders = ctTcPr.addNewTcBorders();
ctTcBorders.addNewRight().setVal(STBorder.NONE);
ctTcBorders.addNewBottom().setVal(STBorder.NONE);

0 个答案:

没有答案
相关问题