aspose word for java解決Word中部分表格跨頁線框缺失問題


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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM