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);
}
}
}
}