title: Export JasperReports query results
body: <p>in my Java project I have a lot of JasperReports reports with complex SQL queries, containing a lot of parameters. The reports are used to produce pdf documents containing the data returned by the query, grouped and formatted in various ways.</p>
  
  <p>Now I also have the need to export directly the query result (e.g. a ResultSet, or a Map or a csv file, or similar...).
  Is it possible to ask JasperReports to execute only the query and return results instead of rendering the pdf page?</p>
  
  <p>(NOTE: it's not the same as choosing a csv output format to the report rendering, because this method tries to convert the report design to a csv file... Instead, I'd like only to "reuse" the query inside a report, also taking advantage of JR parameters management, etc...)</p>
  
  <p>This is my Java code to produce a pdf document from a report:</p>
  
  <pre><code>JasperReport report = (JasperReport) JRLoader.loadObject(inStream);
  JasperPrint jasperprint = JasperFillManager.fillReport(report, params, conn);
  JRAbstractExporter exporter = new JRPdfExporter();
  exporter.exportReport();
  ByteArrayOutputStream os = (ByteArrayOutputStream) exporter.getParameter(JRExporterParameter.OUTPUT_STREAM);
  byte[] formattedReportBytes = os.toByteArray();
  return formattedReportBytes;
  </code></pre>
  
  <p>I saw there's a class called <code>JRJdbcQueryExecuter</code> inside JasperReports...
  Is it possible to call it directly instead of calling <code>fillReport</code>, in order to get the ResultSet of the executed SQL query?</p>
  
  <p>Thanks</p>