Archive for the 'JasperReports' Category

JasperReports TechMaps

Thursday, August 28th, 2008

If you are J2EE programmer & had ever needed to generate reports, you would have heard of JasperReports. While browsing, I came across documents called “TechMaps” on JavaBlackBelt.com. TechMaps are excellent visual aids introduction to understand basics of Jasper Reports. Hope this will be helpful to larger community.

What is a TechMap?
A TechMap is a kind of visual article which explains a technology with a minimal amount of words and maximum amount of graphics.

Difference Between JRXLSExporter & JExcelApiExporter

Tuesday, December 12th, 2006

Here’s a thread that throws some light on difference between using the JRXLSExporter and JExcelApiExporter. According to Teodor (creator of JasperReports), the difference between both the exporters is the library they use to generate the XLS reports.

While JRXLSExporter uses the POI library, which doesn’t support images, the JExcelApiExporter uses the JExcelApi to generate XLS reports. Other than this, there is slight difference in performance.

Export Jasper Report To XLS

Tuesday, December 12th, 2006

Here’s a sample function that allows you to export your JasperReport to XLS format.


public void generateXLSOutput(
JasperPrint jasperPrint,
HttpServletRequest req,
HttpServletResponse resp,
ServletContext scContext)
throws IOException, JRException {

// Either use JRXlsExporter or JExcelApiExporter, I'm not sure
// sure about the difference between the two.
//JRXlsExporter exporterXLS = new JRXlsExporter();
JExcelApiExporter exporterXLS = new JExcelApiExporter();

exporterXLS.setParameter(
JRXlsExporterParameter.JASPER_PRINT,
jasperPrint);

exporterXLS.setParameter(
JRXlsExporterParameter.IS_DETECT_CELL_TYPE,
Boolean.TRUE);

exporterXLS.setParameter(
JRXlsExporterParameter.IS_WHITE_PAGE_BACKGROUND,
Boolean.FALSE);

exporterXLS.setParameter(
JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS,
Boolean.TRUE);

// If you want to export the XLS report to physical file.
//xlsExporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME,"report.xls");

// This'll allows users to directly download the XLS report without
// having to save XLS report on server.
exporterXLS.setParameter(
JRXlsExporterParameter.OUTPUT_STREAM,
resp.getOutputStream());

// This'll trigger the browser to use excel application to deal with
// downloaded file.
resp.setContentType("application/vnd.ms-excel");

exporterXLS.exportReport();
}

Another Jasper report compile error!

Tuesday, December 5th, 2006

Errors! Errors! Another error when I try to compile the Jasper Reports 1.2.7,

net.sf.jasperreports.engine.JRException: Errors were encountered when compiling report expressions class file:
D:\Program Files\IBM\WebSphere Studio\Application Developer IE\v5.1.1\report3_1165303813734_427379.java:4: package net.sf.jasperreports.engine does not exist
import net.sf.jasperreports.engine.*;
^
D:\Program Files\IBM\WebSphere Studio\Application Developer IE\v5.1.1\report3_1165303813734_427379.java:5: package net.sf.jasperreports.engine.fill does not exist
import net.sf.jasperreports.engine.fill.*;
^
D:\Program Files\IBM\WebSphere Studio\Application Developer IE\v5.1.1\report3_1165303813734_427379.java:15: package net.sf.jasperreports.engine does not exist
import net.sf.jasperreports.engine.*;

Any ideas on this? Thanks.

======> Just an update - I got a solution to this problem..pls see comments for this post.

Cannot compile JasperReports!

Friday, December 1st, 2006

Yeah! I’m using Jasper Reports library to generate Reports for my j2ee web application. It’s open source library developed by JasperSoft Inc, fully written in Java. So here’s my problem -

JasperReports 1.2.7 - I try to compile the .jrxml (Jasper report template) file using following code snippet.

JasperDesign jasperDesign = JRXmlLoader.load(reportFile.getPath());

jasperReport = JasperCompileManager.compileReport(jasperDesign);

And after executing this I get JRException -

net.sf.jasperreports.engine.JRException: Errors were encountered when compiling report expressions class file:
1. java.lang.Boolean cannot be resolved or is not a type
value = (java.lang.Boolean)(new Boolean( 1 <= ((java.lang.Integer)parameter_TOTAL_COLUMN_COUNT.getValue()).intValue() ));

I believe its not able to find the runtime java classes which has the java.lang.Boolean class. I even tried setting the java.class.path system property with the rt.jar path but still no relief. If you know pls put a comment to this post with solution or if I find any solution, I’ll put it.

====> here’s the solution… ;) see comments for this post!