Jump to content
Changes to the Jaspersoft community edition download ×

CSV file from a Collection


Recommended Posts

Hello I've a collection List<MyBean>

MyBean contains all String-int field

For each MyBean field I want to print its fields comma separated in a CSV file.


I've done something like that


JasperDesign jasperDesign = JRXmlLoader.load(this.getServlet().getServletContext().getRealPath("reports/reportCsv.jrxml"«»));
JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);

//JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, new JRBeanCollectionDataSource(listMediaBean));
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, new JRBeanCollectionDataSource(collection));

JRCsvExporter csvExporter = new JRCsvExporter();
csvExporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
csvExporter.setParameter(JRHtmlExporterParameter.OUTPUT_STREAM, response.getOutputStream());

csvExporter.setParameter(JRExporterParameter.CHARACTER_ENCODING, "ISO8859_1"«»);
csvExporter.setParameter(JRCsvExporterParameter.FIELD_DELIMITER, ","«»);



in the detail section of my reportCsv.jrxml I've put all the fields of MyBean

fields are many and long, and if I order in VERTICAL the csv print the values in vertical (looks like different object) and not in orizzontal and comma separated


someone can help me to solve this problem?

that code doesn't work,

maybe there's a way to don't create an jrxml and say jasper to print all my fields without specify any jasperPrint?

thanks a lot


Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...