Report output in text

Hi,

I have a question which i think is very simple, but i can’t seem to find the answer for. Please help.
I have a report which output is in .docx format. Now i want the output of that same report in .txt format. The solution seems so far for.

Can anyone please help?

Regards,

Lloyd

Hi.
There is no ability to set output report format for .txt, check Output format compliance matrix

This is an example of the output i want to generate, so i can be opened with notepad.
${account.accoutnumber}/${account.amount} Salary for ${account. month} ${account.year}/${account.voornaam} ${account.familienaam}

There is a CSV output format, it is very similar to TXT and can be opened by both Notepad and spreadsheet programs.

If you need custom format, you could generate the document without using reporting module.

Thanks Alexander i will look into that.

I’ve been looking for a solution, but still no luck. Is there an example i can use?

Regards,
LS

Hi,
To create a TXT content, use StringBuilder class from the Java standard library.
To download a file, inject ExportDisplay class to the screen controller.

Example:

    @Inject
    private CollectionContainer<Deck> decksDc;
    @Inject
    private ExportDisplay exportDisplay;

    @Subscribe("decksTable.exportText")
    public void onDecksTableExportText(Action.ActionPerformedEvent event) {
        List<Deck> decks = decksDc.getItems();
        StringBuilder text = new StringBuilder();
        for (Deck deck: decks) {
            text.append(deck.getName())
                    .append("/")
                    .append(deck.getCreationDate())
                    .append("/")
                    .append(deck.getPriority())
            .append("\n");
        }
        exportDisplay.show(new ExportDataProvider() {
            @Override
            public InputStream provide() {
                return new ByteArrayInputStream(text.toString().getBytes(StandardCharsets.UTF_8));
            }
        }, "report.txt");
    }

Resulting file:
image

Many thanks Alexander.