如何在 EasyTable 中创建这种格式的 table

How to create a table of this format in EasyTable

我希望在我的案例中有一个单一的 header Notes rowspaning 到多行 (2)。当我尝试编写相同的代码时,我得到

rg.vandeseer.easytable.structure.Table$TableBuilder$TableSetupException: Number of table cells does not match with table setup. This could be due to row or col spanning not being correct. at org.vandeseer.easytable.structure.Table$TableBuilder.build(Table.java:223) ~[easytable-0.8.5.jar:na] at com.fedex.airops.pilot.bank.util.pdf.RollOverPDFAAPB.createSimplePDF(RollOverPDFAAPB.java:79) ~[classes/:na]

谁能告诉我如何使用 easy-table 为给定的示例 Table 编码

这是上面结构的最小工作示例:

try (PDDocument document = new PDDocument()) {
    final PDPage page = new PDPage(PDRectangle.A4);
    document.addPage(page);

    try (PDPageContentStream contentStream = new PDPageContentStream(document, page)) {

        // Build the table
        Table myTable = Table.builder()
                .addColumnsOfWidth(20, 20, 20, 20, 20, 20, 20)
                .padding(2)
                .borderWidth(1)
                .borderColor(Color.gray)
                .horizontalAlignment(HorizontalAlignment.CENTER)
                .addRow(Row.builder()
                        .add(TextCell.builder().text("a").colSpan(7).build())
                        .build())
                .addRow(Row.builder()
                        .add(TextCell.builder().text("b").rowSpan(2).build())
                        .add(TextCell.builder().text("c").colSpan(3).build())
                        .add(TextCell.builder().text("d").colSpan(3).build())
                        .build())
                .addRow(Row.builder()
                        .add(TextCell.builder().text("e").build())
                        .add(TextCell.builder().text("f").build())
                        .add(TextCell.builder().text("g").build())
                        .add(TextCell.builder().text("h").build())
                        .add(TextCell.builder().text("i").build())
                        .add(TextCell.builder().text("j").build())
                        .build())
                .build();

        // Set up the drawer
        TableDrawer tableDrawer = TableDrawer.builder()
                .contentStream(contentStream)
                .startX(20f)
                .startY(page.getMediaBox().getUpperRightY() - 20f)
                .table(myTable)
                .build();

        // And go for it!
        tableDrawer.draw();
    }

    document.save("example.pdf");
}