Exporting comma delimited csv file from entity

Hey guys!

We are developing an online payment application where the payments will be sent to the bank via a batch file (comma delimited csv file).

What we would like to do is the generate that file from the invoices selected by the user in our application and put it in a specific directory(statically set). What is also important are the file’s headers that we would like to setup (in order to the Payment provider API to understand and process).

Is there a way to be able to create the csv file programmatically and put it in a specific directory ?

Thanks!

1 Like

Hi Jade,
Do you use Reporting add-on?
There are two ways to generate CSV file:

  • Generate CVS file using Reporting. You should configure report with XSLX template. This report print CSV file by XSLX template
  • Generate CSV file directly from Java code. You should write a Java code that creates and stores CSV
Which solution do you prefer? I'll help you with a sample.

Hey Andrey,

Thanks for the reply.

I still don`t use Reporting add-on.
I would like to generate CSV file directly from Java code.

Thank you!

Hi Jade.

I prepared an example https://github.com/andreysubbotin/sample-sales and git changes in a sample project: https://github.com/andreysubbotin/sample-sales/commit/6fb88bd1b124719eed41a4940eb37fbcd2a0044a.
You can try to export orders from Order Browse screen (button Export to CSV)

Orders are exported to CSV using com.company.sales.service.ExportCsvServiceBean (https://github.com/andreysubbotin/sample-sales/blob/master/modules/core/src/com/company/sales/service/ExportCsvServiceBean.java)

Thanks,
Andrey Subbotin

Hey Andrey!

Thanks a lot for the help.

I’m trying to launch the sample project but i’m having the following error
"The project uses an application component that is not supported by this version of Studio or was not found in both local Maven and https://repo.cuba-platform.com/content/groups/work".

I didn`t quite understand the issue, i’m using CUBA platform-6.4.5 version.

Can you please help me in that,

Thank you!
Jade

Hi Jade,

What is the version of CUBA Studio? Please try to update Studio version to v.6.5.5.

Thanks,
Andrey

Hey Andrey!

Thanks man, didn`t realize that v6.5 was available because i was updating the versions from the project property.

Now i’m able to open the project. Will check it out.

Thanks a lot for the continuous help!
You are awesome!

Jade