#1 2024-02-08 16:46:12

marcioribeiro1979
Member
Registered: 2023-04-18

Generator do CSV file

Hi,

I´m trying to create an output generator in RS 4.6.

In the documentation I see an example about creating a TableOutputGenerator from scratch.

However, I don´t want to create it from scratch. I want to extend output generator for CSV files, just changing the extension of the output file.

Is there any example that you could provide or any class I should use as reference ?

Thanks.

Offline

#2 2024-02-09 08:42:47

Felix
Moderator
Registered: 2022-08-01

Re: Generator do CSV file

There is a CSVOutputGenerator class: https://reportserver.net/api/latest/jav … rator.html

this should create you a csv out of your table ... and you can stream it into any file you want.

Or do you need an example how to execute a report? I'll suggest https://github.com/infofabrik/reportser … ail.groovy

just strip off the "send email" part wink

you can play around with the OUTPUT_FORMAT_XYZ part to get different results (just like the "export to" button in the report view)
further reading: https://reportserver.net/api/latest/jav … rvice.html


kind regards

Felix


Softwareentwickler bei Infofabrik

Offline

#3 2024-03-19 13:45:09

marcioribeiro1979
Member
Registered: 2023-04-18

Re: Generator do CSV file

Do you have an sample like this you provided , but for sending to local file instead of email ?

Offline

#4 2024-03-19 15:03:55

eduardo
Administrator
Registered: 2016-11-01
Website

Re: Generator do CSV file

Hi marcioribeiro1979,

you can define a local filesystem datasink and then send your report like this:
https://github.com/infofabrik/reportser … ink.groovy

Regards,
Eduardo

Offline

#5 2024-03-20 10:49:25

marcioribeiro1979
Member
Registered: 2023-04-18

Re: Generator do CSV file

Thanks Eduardo.

One final question: how to send the email to multiple destinations ? I´ve tried comma (,) , I´ve tried semicolon (;) but they didn´t´work.

Offline

#6 2024-03-20 14:09:34

eduardo
Administrator
Registered: 2016-11-01
Website

Re: Generator do CSV file

Hi marcioribeiro1979,

you can see here: https://reportserver.net/api/latest/jav … ang.String...-
that this is a list. So you should be able to do this like this:

mail.toRecipients = ['my@email.com', 'my2@email.com']

You can also use the overloaded method:

mail.toRecipients = 'my@email.com', 'my2@email.com'

Pls always refer to the javadocs for scripting:

The javadocs can be found here: https://reportserver.net/api/latest/javadoc/index.html
List of entities: https://reportserver.net/api/latest/entities.html
List of hooks: https://reportserver.net/api/latest/hooks.html
List of services: https://reportserver.net/api/latest/services.html

Also, pls refer to the scripting guide:
https://reportserver.net/en/guides/script/main/

Regards,
Eduardo

Offline

#7 2024-03-20 14:16:50

marcioribeiro1979
Member
Registered: 2023-04-18

Re: Generator do CSV file

Hi Eduardo,

I´m capturing the email in a form, same as the example provided:

"form" : {
                "labelAlign": "top",
                "fields": [{
                        "id": "email",
                        "type": "string",
                        "label": "Email Address",
                        "value": "name@example.com"
                }]
        }

Then, the value of input goes to script as a string:

mail.toRecipients = values['email']

So, I´m assuming in this example I cannot use multiple destinations, unless I convert the form to accept multiple entries, is that correct ?

Offline

#8 2024-03-20 14:20:19

eduardo
Administrator
Registered: 2016-11-01
Website

Re: Generator do CSV file

Hi marcioribeiro1979,

you can also accept ","-separated emails in the form, parse this string and convert it to a list:
mail.toRecipients = convertToList(values['email'])

Regards,
Eduardo

Offline

Board footer

Powered by FluxBB