java 怎么去掉word 边框内部竖线,例如:
修改前:
修改后:
使用的类是XWPFTableRow
https://blog.csdn.net/qijingpei/article/details/80274308
示例代码:
if(currentRow.getCell(0).getText().equals("测试文本")) {
CTTcBorders tblBorders = currentRow.getCell(0).getCTTc().getTcPr().addNewTcBorders();
tblBorders.addNewLeft().setVal(STBorder.NIL);
tblBorders.addNewRight().setVal(STBorder.NIL);
for(int i=0; i<currentRow.getTableCells().size(); i++) {
currentRow.getCell(i).getCTTc().getTcPr().setTcBorders(tblBorders);
}
}
思路:
1)获得CTTcBorders 对象,设置样式为去掉框线
2)把这个样式设置到单元格或某行的所有单元格上
用free spire.doc for java来合并Word 表格中的单元格
import com.spire.doc.*;
public class MergeOrSplitCells {
public static void main(String[] args){
//创建Document类的对象
Document doc = new Document();
Section sec = doc.addSection();
//添加一个4行4列的表格
Table tb= sec.addTable(true);
tb.resetCells(4,4);
//调用方法横向合并第1行中的第2、3、4个单元格
tb.applyHorizontalMerge(0,1,3);
//保存文档
doc.saveToFile("MergeOrSplitCells.docx",FileFormat.Docx_2010);
}
}