haohj
public void completeTableBorder(Document doc){
    for(Table table:(Iterable<Table>)doc.getChildNodes(NodeType.TABLE, true)){
        //设置表格居中
				table.setAlignment(TableAlignment.CENTER);
        //设置表格左边框线
				table.setBorder(BorderType.LEFT, LineStyle.SINGLE, 1, Color.black, true);
        //设置表格右边框线
				table.setBorder(BorderType.RIGHT, LineStyle.SINGLE, 1, Color.black, true);
        //设置表格上边框线
				table.setBorder(BorderType.TOP, LineStyle.SINGLE, 1, Color.black, true);
        //设置表格下边框线
				table.setBorder(BorderType.BOTTOM, LineStyle.SINGLE, 1, Color.black, true);
				for (Row row:(Iterable<Row>)table.getChildNodes(NodeType.ROW, true)){
					for (Cell cell:(Iterable<Cell>)row.getChildNodes(NodeType.CELL, true)){
						//设置单元格上下边框
						cell.getCellFormat().getBorders().getBottom().setLineStyle(LineStyle.SINGLE);
						cell.getCellFormat().getBorders().getTop().setLineStyle(LineStyle.SINGLE);
					}
				}
			}
}

分类:

技术点:

相关文章:

  • 2021-12-25
  • 2021-09-23
  • 2022-12-23
  • 2022-01-17
  • 2022-12-23
  • 2022-12-23
  • 2021-11-13
  • 2021-12-19
猜你喜欢
  • 2022-01-17
  • 2022-02-01
  • 2022-12-23
  • 2021-07-02
  • 2022-12-23
  • 2022-12-23
  • 2022-01-18
相关资源
相似解决方案