Menu

Description

Tarun Tyagi

Hi
Here we are giving demo of generating the jasper reports using our api which is written on top of Jasper-report-api version 4.0.1+.
Dependencies :

        <artifactId>log4j</artifactId>
        <version>1.2.16</version>

        <artifactId>jasperreports</artifactId>
        <version>4.0.1</version>

        <artifactId>itext</artifactId>
        <version>2.1.7</version>

        <artifactId>commons-digester</artifactId>
        <version>1.7</version>

        <artifactId>commons-beanutils</artifactId>
        <version>1.8.0</version>

        <artifactId>groovy-all</artifactId>
        <version>1.7.5</version>

        <artifactId>commons-collections</artifactId>
        <version>3.1</version>

        <artifactId>commons-logging</artifactId>
        <version>1.1.1</version>

        <artifactId>mysql-connector-java</artifactId>
        <version>5.1.8</version>

Sample report creation: Report creation is very simple and there is no need to learn various classes of Jasper report api.

//getting the instance of report generator interface's implementation
JasperReportGenerator reportGen=JasperReportGenerator.Factory.getReportGenerator();

//Getting template as .jasper file
String reportTemplate="hallTicket.jasper";

//Creating the empty report of desired type which will be filled by report //generator. Here creating the PDF report.
String reportFile="TestAbsoluteFilePath.pdf";
reportGen.setReportTemplate(new File(reportTemplate));
reportGen.setOutputReportFile(new File(reportFile));
reportGen.setReportType(ReportType.PDF);//PDF report type enum
reportGen.setParams(new HashMap<string, string="">());//Map of parameters which //report requires to get filled
reportGen.generate();//You are done with report generation and using the same //empty file path you can get the newly created report</string,>



MongoDB Logo MongoDB
Gen AI apps are built with MongoDB Atlas
Atlas offers built-in vector search and global availability across 125+ regions. Start building AI apps faster, all in one place.
Try Free →