tags: Java
, JasperReports
, J2EE
posted: Friday, April 8th, 2005
The most recent project I have been working on involved creating a large number of reports for the company’s extranet/intranet. In the past, I have usually done reports using some form of JSP and JDBC. But in this case, there is a large number of reports to be developed, and so I was tasked with researching some of the open source solutions for reporting, in hopes we could find a solution that would allow us to get the reports done faster, and be provided to the user with more functionality, and with less custom code.
In the end we compared Crystal reports with JasperReports, and JasperReports was picked. JasperReports is not only free, but also is proven in the Java world, and has a lot of users. It is customizable, since its Java and open source, and has support for using Collections or Lists of Business Objects, such as those populated via Hibernate.
Once JasperReports was chosen, I tested several GUI’s to help build the reports instead of editing them strictly in their native XML. JasperAssistant was found to be the best of all of them, and integrates seamlessly with Eclipse. If you are an Eclipse fan as I am, then you’ll love using JasperAssistant. It even allows you to preview the report against your database right in Eclipse.
Next, I looked into OpenReports. OpenReports is a front end for JasperReports. It was written in WebWork, and provides a lot of functionality that you would have to write yourself to get the reports running on the web. It comes with basic security (users, passwords, and reporting groups). You can assign which users can access which groups, and which reports are in which groups. You can also add parameters, and then assign them to a report. You create the JasperReport in JasperAssistant (or with any other tool, including a text editor if you want to do the XML by hand), and then compile it (which JasperAssistant does for you). Then when you add a new report to OpenReports, you select which JasperReport file to use, select your datasource, assign your parameters and the report is ready to be used on the web.
OpenReports allows the user to export the report as a PDF, HTML, CSV, XLS, or PNG. This is all done for you without any additional work. As for parameters, there is some good functionality built in. When you add a Date parameter to your report, it automatically brings up a calendar for the user to select the date with. Also, you can add a query parameter which runs an sql that you have specified, and populates a drop down select box with the results. Parameters can be marked as required or optional, can be several different data types, and can be told to come in in any order needed. There are other parameter options as well. It also allows the user to schedule a report and have it emailed to a user.
I have made some improvements to OpenReports, including the Collection/List functionality to use Business Objects which JasperReports supports, but OpenReports currently doesn’t. At some point I’ll pass that code on to the original developers.
In the end, with JasperReports and OpenReports, the only thing you have to worry about is creating the SQL to get the data. After that, it takes little work to provide a nice looking report in multiple formats on a web site.
Comments (275)
Leave a Comment
Pages: « 28 … 23 22 21 20 19 [18] 17 16 15 14 13 … 1 » Show All
I need to paginate for PDF and show them in a single page for HTML and XLS ? Is this achievable using Jasper If How?
I cant set remove_empty_space between rows as I also need that to differentiate between data
so Is it achievable?
I am using Jasper Reports for my report building it workd completely fine with windows buton Unix platform it gives Broken pipe Error after analyzing more and the thread Dump we found :
– Holding lock: java/lang/NumberFormatException@0×200430d0[thin lock]
at java/lang/Throwable.(Unknown Source)@0×40c8ba13
at java/lang/Exception.(Exception.java:41)@0×40c8b9f5
at java/lang/RuntimeException.(RuntimeException.java:43)@0×40c93655
at java/lang/IllegalArgumentException.(IllegalArgumentException.java:36)@0×40c93645
at java/lang/NumberFormatException.(NumberFormatException.java:38)@0×40c93635
at java/lang/FloatingDecimal.readJavaFormatString(FloatingDecimal.java:983)@0×431b1946
at java/lang/Double.parseDouble(Double.java:220)@0×470de681
at net/sf/jasperreports/engine/export/JRXlsExporter.exportText(Optimized Method)@0×447ecf91
at net/sf/jasperreports/engine/export/JRXlsAbstractExporter.exportPage(JRXlsAbstractExporter.java:367)@0×4709cb23
at net/sf/jasperreports/engine/export/JRXlsAbstractExporter.exportReportToStream(JRXlsAbstractExporter.java:289)@0×47097918
at net/sf/jasperreports/engine/export/JRXlsAbstractExporter.exportReport(JRXlsAbstractExporter.java:135)@0×47096e1a
could you please suggest me Why do we get Number Format Exception that causes Thread Lock and hence Broken Pipe Error
José Luis,
JasperReports should not be viewed as an export tool. But, if you are using it anyway for reports, and you want the same data you are using in a report, to be exported in XLS, then certainly it will work. I added a type parameter that was passed to all reports, and I added a print when expression to all fields in the jasper report for that type when it was XSL. This way I can suppress all the headers, groups, etc, and only export the detail records.
Do you think Jasper Report is a good tool for export a report as XLS?
I just need to export the detail section of my reports (not title, images, lines between rows, foot section, etc.) The exported sheet should be simple and ready for work.
I’ve heard selective export is a weak point of JRreport. You have to export the whole report, getting a complex sheet full of empty narrow cols to preserve coordinates of non-relevant elements (images, corporative information, decorative lines, etc.) I suppose exporting as CVS is affected by similar limitations…
Do you think this is a real problem?
Thanks in advance,
José Luis
Hi is it possible to use a simple comma seperated file as a data source to a JasperReport instead of a DB or any other datasource.
Thanks in advance for the info!
Hi Brian
I am a software engineer. My company makes a stand alone application. I introduced them to Jasper and implemented it. In the coming future ie. around 2007 we intend to take our application to the web. This would involve a huge effort and we would also want to be able to present our reports over the web. In kind of getting prepared for that I stumbled on open reports which sounds promising. Now the issue.
Our jasperreports do not connect to the database. We supply it with Java’s business objects and it reads them to populate the report. Can open reports accept these objects like an arrayList, hashmap or vector ? It seems from your blog that it cannot and it seems you changed the code of open reports to do so. If so, I do not want to reinvent the wheel and was wondering if you could provide me with your version of open reports. Please confirm my suspicions, thanks for your time.
I need to set the same font name namely “verdana”
while export to HTML or PDF
Newbie questions. I use iReport to create the jrxml files.
1. Where do I put the jrxml files after I create them? Or do I use the jasper files that iReport makes?
2. When I run the ant script to build the war file, what do I do to make sure my jrxml or jasper files are part of the openreports application?
3. Is it possible to force openreports not to use spacer gif images to lay out the html version of the reports that use the jasper files? I hate spacer gifs.
Hi,
The article helped me to get the code from SorceForge to execute the stored procedure call. thanks for the article.
How to call MulitValue parameter like
{call GroupsPackage.project_sel2(’$P!{Team}’, ‘$P!{TeamMember}’, $P{cursor})}
Where Team and TeamMemeber or Multiple Values, I tried without quotes then it is trhowing ‘number of arguments doesnot match’
so I added ‘’ around the argument. Then It is not working, No error - no values, mostly it is takin g the value of ‘xxxxxx’ in the query.. Can you please suggest me how I can achieve..
Thanks in advance,
Murty
Pages: « 28 … 23 22 21 20 19 [18] 17 16 15 14 13 … 1 » Show All
RSS feed for comments on this post. TrackBack
Hi All,
I am using jasper for reporting in my application. The application “war” file is deployed in WebSphere, And it is failing during report initialization.
Can any body plz tell me, why I am getting this error. Probably what are the suspected cause behind this.
Thanks in advance,
Sanjib
[1/16/07 17:53:14:562 IST] 5639e40e WebGroup E SRVE0020E: [Servlet Error]-[reports]: Failed to load servlet: net.sf.jasperreports.engine.JRException: Errors were encountered when compiling report expressions class file:
1. java.sql.Connection cannot be resolved to a type value = (java.sql.Connection)(((java.sql.Connection)parameter_REPORT_CONNECTION.getValue()));
2. java.sql.Connection cannot be resolved to a type
value = (java.sql.Connection)(((java.sql.Connection)parameter_REPORT_CONNECTION.getValue()));
3. java.sql.Connection cannot be resolved to a type
value = (java.sql.Connection)(((java.sql.Connection)parameter_REPORT_CONNECTION.getValue()));
4. java.sql.Connection cannot be resolved to a type
value = (java.sql.Connection)(((java.sql.Connection)parameter_REPORT_CONNECTION.getValue()));
5. java.sql.Connection cannot be resolved to a type
value = (java.sql.Connection)(((java.sql.Connection)parameter_REPORT_CONNECTION.getValue()));
6. java.sql.Connection cannot be resolved to a type
value = (java.sql.Connection)(((java.sql.Connection)parameter_REPORT_CONNECTION.getValue()));
7. java.sql.Connection cannot be resolved to a type
value = (java.sql.Connection)(((java.sql.Connection)parameter_REPORT_CONNECTION.getValue()));
8. java.sql.Connection cannot be resolved to a type
value = (java.sql.Connection)(((java.sql.Connection)parameter_REPORT_CONNECTION.getValue()));
9. java.sql.Connection cannot be resolved to a type
value = (java.sql.Connection)(((java.sql.Connection)parameter_REPORT_CONNECTION.getValue()));
10. java.sql.Connection cannot be resolved to a type
value = (java.sql.Connection)(((java.sql.Connection)parameter_REPORT_CONNECTION.getValue()));
11. java.sql.Connection cannot be resolved to a type
value = (java.sql.Connection)(((java.sql.Connection)parameter_REPORT_CONNECTION.getValue()));
12. java.sql.Connection cannot be resolved to a type
value = (java.sql.Connection)(((java.sql.Connection)parameter_REPORT_CONNECTION.getValue()));
13. java.sql.Connection cannot be resolved to a type
value = (java.sql.Connection)(((java.sql.Connection)parameter_REPORT_CONNECTION.getValue()));
14. java.sql.Connection cannot be resolved to a type
value = (java.sql.Connection)(((java.sql.Connection)parameter_REPORT_CONNECTION.getValue()));
15. java.sql.Connection cannot be resolved to a type
value = (java.sql.Connection)(((java.sql.Connection)parameter_REPORT_CONNECTION.getValue()));
16. java.sql.Connection cannot be resolved to a type
value = (java.sql.Connection)(((java.sql.Connection)parameter_REPORT_CONNECTION.getValue()));
17. java.sql.Connection cannot be resolved to a type
value = (java.sql.Connection)(((java.sql.Connection)parameter_REPORT_CONNECTION.getValue()));
18. java.sql.Connection cannot be resolved to a type
value = (java.sql.Connection)(((java.sql.Connection)parameter_REPORT_CONNECTION.getValue()));
18 errors