Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>To view a report you must first fill the report. To fill the report you need a few things: a report file (.jrxml or .jasper), a parameter map, and a database connection. If you use a .jrxml file you must first compile it. To compile a .jrxml file first load it:</p> <pre><code>JasperDesign jasperDesign = JRXmlLoader.load(reportFile); </code></pre> <p>Then compile it:</p> <pre><code>JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign); </code></pre> <p>The <code>reportFile</code> variable passed to the JRXmlLoader.load() method is a String with the file path to your .jrxml file location and file name ("C:\ReportFile\TestReport.jrxml").</p> <p>Now that you've loaded and compiled your .jrxml file, you can fill your report. NOTE: if you use the .jasper file, you can jump right to this step. The <code>compiled_file_name</code> you would pass as a parameter is the file location and name of your .jasper file.</p> <p>To fill a report you call the JasperFillManager and assign its results to a JasperPrint variable:</p> <pre><code>JasperPrint jasperPrint = JasperFillManager.fillReport(compiled_file_name, jasperParameter, jdbcConnection); </code></pre> <p>NOTE: if you are loading and compiling the .jrxml file, as shown above, you would just use <code>jasperReport</code> as the first parameter in the JasperFillManager.fillReport method, since that holds your compiled file. The <code>compiled_file_name</code> is the reference to an already-compiled .jasper file. The filled report will be stored in <code>jasperPrint</code>, this is what you will pass around for various viewing and exporting options.</p> <p>Now to view your file. The easiest way to view it is to use the JasperViewer:</p> <pre><code>JasperViewer.viewReport(jasperPrint); </code></pre> <p>To export your report to a specific file format, use JasperExportManager:</p> <pre><code>JasperExportManager.exportReportToPdfFile(jasperPrint, file_export_location); </code></pre> <p>The <code>file_export_location</code> is the file location and name where you will save the file. There are various exporters in JasperExportManager, you should see them in NetBeans. I export reports to .pdf. To display them, I have my method send the view to another page which contains an <code>&lt;iframe width="800px" height="500px" src="relative location of your file" /&gt;</code>.</p> <p>Hope that helps.</p> <p>You may also want to consider purchasing <a href="http://www.jaspersoft.com/jasperreports-ultimate-guide" rel="nofollow">The Ultimate Guide to JasperReports</a> and <a href="http://www.jaspersoft.com/ireport-ultimate-guide" rel="nofollow">The Ultimate Guide to iReports</a>. Both are pretty good guides to how to use JasperReports.</p> <p>UPDATE:</p> <p>As I said in my comment below, I don't recall where I got this list (I lost the link), but these are the .jar files I use in my projects (I've tried paring it down, but end up getting errors so I've taken the rookie-road of just including them all):</p> <blockquote> <p>ant-1.7.1, antlr-2.7.5, barbecue-1.5-beta1, barcode4j-2.0, batik-anim, batik-awt-util, batik-bridge, batik-css, batik-dom, batik-ext, batik-gvt, batik-parser, batik-script, batik-svg-dom, batik-svggen, batik-util, batik-xml, batik-5.2, bsh-2.0b4, commons-beanutils-1.8.0, commons-collections-2.1.1, commons-digester-1.7, commons-javaflow-20060411, commons-logging-1.0.4, groovy-all-1.7.5, hibernate3, hsqldb-1.8.0-10, iText-2.1.7, jaxen-1.1.1, jcommon-1.0.15, jdt-compiler-3.1.1, jfreechart-1.0.12, jpa, jxl-2.6.10, log4j-1.2.15, mondrian-3.1.1.12687, png-encoder-1.5, poi-3.6, rhino-1.7R1, saaj-api-1.3, serializer, servlet, spring-beans-2.5.5, spring-core-2.5.5, xalan-2.7.1, xercesImpl-.7.0,<br> xml-apis, xml-apis-ext</p> </blockquote> <p>Hope that helps.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload