如何使用ODF Toolkit在表格单元格中设置特定字体?

How set specific font in table cells using ODF Toolkit?

提问人:Unearthly 提问时间:6/26/2023 更新时间:6/26/2023 访问量:69

问:

如何更改 OdfTable 单元格的文本字体?我正在使用 ODF 工具包库,我只在网上找到了这个资源: https://odftoolkit.org/simple/document/cookbook/Style%20Handling.html 它不起作用,因为我没有收到表,而是收到 OdfTable。

为了清楚起见,这是我写的方法。我正在向表中添加一个新行,并在每个单元格中为存在的每个计划设置一个值。

谢谢!

static void fillRipartitionTable(Initiative principalInitiative, List<OdfTable> tableList, ProjectProposal proposal, int ripartitionTableIndex) {
        boolean hasPlan = !Objects.isNull(principalInitiative.getPlan());
        proposal
            .getInitiatives()
            .forEach(
                initiativeProjectProposal -> {
                    Initiative currentInitiative = initiativeProjectProposal.getInitiative();
                    OdfTableRow odfTableRow = tableList.get(ripartitionTableIndex).appendRow();
                    odfTableRow
                        .getCellByIndex(0)
                        .setStringValue(
                            hasPlan
                                ? String.format(
                                "%d-%02d",
                                currentInitiative.getPlan().getYear(),
                                principalInitiative.getPlan().getProgressive())
                                : "");
                    odfTableRow
                        .getCellByIndex(1)
                        .setStringValue(Optional.ofNullable(currentInitiative.getPlanPoint()).orElse(""));
                    odfTableRow
                        .getCellByIndex(2)
                        .setStringValue(Optional.ofNullable(currentInitiative.getCode()).orElse(""));
                    odfTableRow
                        .getCellByIndex(3)
                        .setStringValue(
                            Optional.ofNullable(currentInitiative.getDescription()).orElse(""));
                    odfTableRow
                        .getCellByIndex(4)
                        .setStringValue(
                            Optional.ofNullable(
                                    makeFormattedNumber(currentInitiative.getTotalAgreedCost(), "€"))
                                .orElse(""));
                });
    }
Java 字体 ODT ODF工具包

评论


答: 暂无答案