How set specific font in table cells using ODF Toolkit?

115 views Asked by At

how can I change the text font of my OdfTable's cells? I'm using ODF Toolkit library and I only found this resource online: https://odftoolkit.org/simple/document/cookbook/Style%20Handling.html which DOESN'T work since i don't receive a table but a OdfTable.

For clarity here's the method I wrote. I'm adding a new row to my table and I set a value in every cell for every initiative present.

Thanks!

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(""));
                });
    }
0

There are 0 answers