In this tutorial, I show you how to create a simple jasper report with a static text in TIBCO Jasper Report Studio. Then run the jrmxl file in a Maven Java Project in visual studio code to get a pdf.
Main Class
package com.abc; import java.util.HashMap; import net.sf.jasperreports.engine.*; import net.sf.jasperreports.engine.JREmptyDataSource; import net.sf.jasperreports.engine.JasperCompileManager; import net.sf.jasperreports.engine.JasperExportManager; import net.sf.jasperreports.engine.JasperFillManager; import net.sf.jasperreports.engine.JasperPrint; import net.sf.jasperreports.engine.design.JasperDesign; import net.sf.jasperreports.engine.xml.JRXmlLoader; /** * Hello world! * */ public class App { public static void main( String[] args ) { String fileNameJrxml = "E:/Jasper/HelloPDF.jrxml"; String fileNamePdf = "E:/Jasper/HelloPDF.pdf"; try { System.out.println("Loading the .JRMXML file ...."); JasperDesign jasperDesign = JRXmlLoader.load(fileNameJrxml); System.out.println("Compiling the .JRMXML file to .JASPER file...."); JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign); HashMaphm = new HashMap (); System.out.println("filling parameters to .JASPER file...."); JasperPrint jprint = (JasperPrint) JasperFillManager.fillReport(jasperReport, hm, new JREmptyDataSource()); System.out.println("exporting the JASPER file to PDF file...."); JasperExportManager.exportReportToPdfFile(jprint, fileNamePdf); System.out.println("Successfully completed the export"); } catch (Exception e) { System.out.print("Exception:" + e); } } }
junit junit 4.11 test net.sf.jasperreports jasperreports 6.8.0 commons-beanutils commons-beanutils 1.9.3 compile false commons-digester commons-digester 2.1 compile false commons-logging commons-logging 1.1.1 compile false org.apache.commons commons-collections4 4.2 compile false com.lowagie itext 2.1.7.js6 compile false org.bouncycastle bcmail-jdk15on org.bouncycastle bcpkix-jdk15on org.apache.poi poi 4.0.1 compile true org.apache.poi poi-ooxml 4.0.1 compile true org.eclipse.jdt.core.compiler ecj 4.4.2 compile false org.codehaus.groovy groovy-all 2.4.5 compile true org.apache.logging.log4j log4j-core 2.8.2 test org.apache.logging.log4j log4j-jcl 2.8.2 test net.sf.jasperreports jasperreports-fonts 6.8.0 test org.apache.lucene lucene-core 7.3.0 compile true org.apache.lucene lucene-analyzers-common 7.3.0 compile true org.apache.lucene lucene-queryparser 7.3.0 compile true org.olap4j olap4j 0.9.7.309-JS-3 compile true org.apache.commons commons-pool2 2.4.2 compile true commons-codec commons-codec 1.5 compile true net.sf.jasperreports jasperreports-metadata 6.8.0 compile true
No comments:
Post a Comment