Export report to jasper plain xml format

Hi, I already know that we can export XML data from jasper. But it also returns a jasper tag that I don't need. I need only a simple xml form. Is it possible? if so, how?

I generate the XML format using the instructions below:

jrExporter = new JRXmlExporter(); jrExporter.setParameter(JRXmlExporterParameter.IS_EMBEDDING_IMAGES, Boolean.FALSE); response.setContentType("application/xml"); jrExporter.setParameter(JRXmlExporterParameter.JASPER_PRINT, jasperPrint); jrExporter.setParameter(JRXmlExporterParameter.OUTPUT_STREAM, response.getOutputStream()); jrExporter.exportReport(); 

Putting on some attributes needs to be set before exporting, but I don’t know which one.

+4
source share
1 answer

This is a common misunderstanding for JRXmlExporter. JasperReport does not support extracting report data via XML. JRXmlExporter exports the generated report output, that is, the exact layout specification for each page and item. In addition, everything is treated as plain text, so all information, if the field was a date or a number, is not available.

If you want to export data only as an XML structure, you will need to implement a custom exporter. To do this, you will need to define a logic that translates the layout structures back into data structures. Based on my research, this can be partially achieved if:

  • you limit the scope of the report (i.e. tables, groups, lists) - some recognizable structures
  • you can also use custom properties for fields and ranges to support information such as data type, etc.
+1
source

Source: https://habr.com/ru/post/1447887/


All Articles