繁体   English   中英

iText 7 无边框表格(无边框)

[英]iText 7 borderless table (no border)

下面的这段代码不起作用。

Table table = new Table(2); 
table.setBorder(Border.NO_BORDER);

我是 iText 7 的新手,我想要的只是让我的表格无边框。 喜欢怎么做?

默认情况下,表格本身不负责 iText7 中的边框,单元格负责。 如果您想要一个无边框表格,您需要将每个单元格设置为无边框(如果您仍然想要内部边框,则将外部单元格设置为边缘没有边框)。

Cell cell = new Cell();
cell.add("contents go here");
cell.setBorder(Border.NO_BORDER);
table.addCell(cell);

您可以编写一个方法来运行表的所有子项并设置 NO_BORDER。

private static void RemoveBorder(Table table)
{
    for (IElement iElement : table.getChildren()) {
        ((Cell)iElement).setBorder(Border.NO_BORDER);
    }
}

这为您提供了仍然可以使用的优势

table.add("whatever");
table.add("whatever");
RemoveBorder(table);

而不是在所有单元格手册上更改它。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM