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
I found them to be very easy to install. The learning curve is in learning how to use JasperAssistant. Not because JasperAssistant is difficult, but because you have to learn Jasper Reports and and how banding, and grouping and such works. If you happen to have Crystal experience, it won’t take as much time, but I didn’t. Installing them is trivial.
I have not used them from within Cocoon. Jasper Reports should be easy to use from within Cocoon, but I don’t think you’d be able to use Open Reports from within Cocoon. It is its own separate web application. We are keeping it separated from our intranet/extranet, and just linking to it (and integrated the security between the two). It uses WebWork as a web framework. The time to port that to Cocoon would be massive.
Good luck with setup, and let me know if you have any other questions.
I’m looking for open source solution for reporting server. Your Blog already very descriptive how to perparing a reporting service.
I have feel question as follow about the development flow and system architecture. My project have 2 type of report (Adhoc, Batch)
1. JasperAssistant is it better then Open Report Designer?
2. If I use JasperAssistant create a report within my Application? How can I deploy the report to Open Report?
3. Currently I have use WAS as Application Server, Can I use JBoss & Open Report as Reporting Server?
Cheers,
Alex
1. If I recall correctly, Open Report Designer did not allow filling a report with data from a Collection of business objects, which JasperAssistant did. Also, since I’m a huge fan of Eclipse, I very much enjoy having my Jasper report designer be fully integrated with Eclipse.
2. I have the open report web application as a project in Eclpse. The reports are in a reports folder in the web application. I just double click on them in Eclipse, and edit them. Then you can use deploy them however you normally would from eclipse (personally, I use the MyEclipse plugin for web app deployment).
3. Open Reports is a web appliation that should work with any application server, including WAS, Tomcat, JBoss, etc.
Thsank for you prompted reply.
Compare with Hibernate and Open Report which one is better for a reporting server in term of performance and usability?
Jasper Reports is the reporting engine. Open Reports is a web gui front end for that engine, and Hibernate is an “object/relational persistence and query service for Java”.
Jasper Reports can fill a report from a Collection of Business Objects, which were filled with data from a relational database via Hibernate. Open Reports is a web gui which allows users to select a report, enter parameters for a report, and then schedule to report to be run, or run the report in real time, and view the results in PDF, HTML, CSV, etc.
All three work together to provide a wonderful reporting solution for a Java environment. You can do without the Hibernate if you don’t need to fill the report from business objects, and just use standard JDBC to fill the reports.
Thanks Brian,
Your opinion help me a lot. Thank again.
Would you tell me how to do the crosstab report in Jasper Reports?
Cheers,
Alex
Setup issues - you say “I found them to be very easy to install”. I have not had any success with Open Reports. I tried to follow their less-than-minimal installation guide; got to the point where I dropped the expanded web app into Tomcat, rerstarted and then… the guide does not even say what you should see or expect or the app should start up. There’s also no way to know what and how to populate and use all the tables (report_* ). Is there a more comprehensive and step-by-step guide anywhere else?
There is an installation guide in the docs folder of the web application. It directs you to create the db schema using the sql provided in the database/schema directory. It then walks you through Configuring Hibernate, Creating the Admin User, Setting the Report Directory and Configuring the Scheduler.
For Configuring Hibernate, I personally choose to use a JNDI connection. You don’t have to populate any of the tables, only create them in your database.
Hi there,
I will only make 2 annotation to the previous postings …
To posting 3, about how to deploy the Reports … in OpenReports there is the possibility to upload the JasperReport-Templates (not the xml, but the precompiled templates) into the configured directory which stores the JasperReport-Files …
So if, like in my case, the “OpenReport-Server” is located on another machine, thats no problem, you can just upload the compiled reports over the OpenReports-Interface and than use them to show your Reports
.
The second is the hint to iReport … it’s a GUI for creating JasperReport-Templates too … is easy to use and nearly uptodate with the current JasperReport-Version …
It’s a standalone-java-application so that someone who don’t use eclipse could use iReport without any other software (except java of course).
It’s also possible to bind the Template at the develop-time to several DataSources like any relational database with jdbc-support, JavaBeans, xml- and csv-files and show the filled report in all the possible output-formats (pdf, html, csv, excel and in the JRViewer itself …).
So i use iReport since a while and i think thats a realy nice program to create the needed templates to use in OpenReports (or whatelse programm
.
Have a nice day …
Steffen
Hi,
I prefer Open Report Designer (ORD) than JasperAssistant because ORD is a standalone solution.
ORD is not intrusive in Jasper template than iReport.
To improve Jasper and ORDesigner I want to use Jasper with Hibernate, and manipulate UML model.
Re: Post 9
Yes, I did read the [minimal] installation guide (as I mentioned in my previous post) and worked through all the steps. The point was that then nothing happened, and its not clear at all what additional steps are required to have a complete application running under Tomcat. Perhaps you could write up some of the “missing steps” and post them on a blog. Failing which, where else can I look for more detailed information?
It’s hard for me to know what is missing in the install guide, without knowing what errors you are getting when you try to run the web application. I followed the install guide, and it worked fine for me, so I have no way of knowing what might be missing. I would suggest you contact the developers of Open Reports. Perhaps they can help you.
I interested with this software and I’ve download it. but i dont know how to use it
because i dont have OpenReports Administration Guide because i dont have credit card to pay it. if u dont mind can you
tell me how to use this software.
what is the function of ORD for OpenReports?
I have not used ORD. I believe that is the designer for Jasper Reports. It allows you to use a WYSIWYG interface for laying out the report. It produces a compiled file with a .jasper extension, which is what you use in the Open Reports web engine to setup the usage of that report with an interface. I do not have the administractio guide, either, but setting up the interface portion of a report is very easy. However, using the ORD may be more complex and I have no experience with that.
Would you tell me how to do the crosstab report in Jasper Reports?
Will be if real help
The current version of Jasper Reports does not support cross tab reports. From what I read they are working on it for a future release. Ironically, the current report I’m working on requires that, but I’m going to have to rearrange the data into a List of BusinessObjects and then populate my Jasper report from that.
Hi Brian
Thanks for the report. One more question. How to populate the column dynamically in Jasper
I have following colunms
Name Jan-04 Feb-05…. Total
Month Column will either increase or decrease
Can we do the same in Jasper report. Do u have a sample for the same
What is driving the dates? Do they come from a database? Or are they derived in some other way?
Data comes from Database in the below format
Name Date Amount
***************************
Dis1 10/04 5000
Dis1 11/04 2000
Dis2 10/04 3000
Dis1 11/04 3000
I am rearranging the same using Arraylist and hashmap like this format
Name 10/04 11/05
**********************
Dis1 5000 2000
Dis2 3000 3000
In the above example dates are dynamic
Will have 2 months of date or one year depending on user selection
I’m actually working on something exactly like that. When I get it done I’ll do a post about it for anyone who might still need a solution to that situation.
Currently we are planning to user Jasper and we use J2EE (EJB, Servlet and JSP) and for passing the result to jsp we are using Arraylist of Hashmap
Do you have any sample code that will get the value in Arraylist of Hashmap and pass the same to Jasper report?
Can you paste one example in your web site?
I am also attaching a sample ArrayList/Hashmap object
[{Dec 04=559230, Jan 05=530845, Name=4Spine, LLC, Total=1888085.0, Feb 05=396010, Nov 04=402000},
{Jan 05=23000, Name=Act 2 Medical, Total=44800.0, Feb 05=21800},
{Dec 04=56615.2, Jan 05=83141.6, Name=David Tyre, Inc., Total=215895.2, Feb 05=51889.6, Nov 04=24248.8},
{Dec 04=103258, Jan 05=78625.25, Name=Gilman Surgical, Total=359186.75, Feb 05=68564.2, Nov 04=108739.3},
{Dec 04=159679, Jan 05=93790, Name=Gulf Coast Orthopedics Inc., Total=568842.3, Feb 05=107253.3, Nov 04=208120},
{Dec 04=201400.6, Jan 05=162199.2, Name=ISpine, Total=606636.2000000001, Feb 05=104127.8, Nov 04=138908.6},
{Dec 04=37655, Jan 05=83998, Name=Intramedix Medical Inc., Total=275657.0, Feb 05=92740, Nov 04=61264}]
Hi Brain
Any update on my pervious Question
I haven’t tried that before, so I really don’t know. In the class I’m currently writing, I convert a HashMap to an ArrayList (the values of the HashMap), and send that to Jasper, but I’m not sure if you could access an ArrayList of HashMaps.
Hello brian,
Can we apply html style-sheet to the jasper reports ?
thnx in advance.
I’m sure using CSS is possible, however, generally the point of the Jasper XML file is to describe to Jasper how you want to the report to look. It then creates the HTML or the PDF, or whatever your export type is, and ensures that export type looks like you’ve described in the Jasper XML. All the GUI’s like JasperAssistant and iReport, allow the user to describe the look. CSS is used by Jasper in the HTML it creates, but changing that would be counter to how Jasper is designed.
How to send the Arraylist to the jasper report can you paste an sample pl
Hi Brian,
I’m writing a Swing based desktop application that needs to produce a 10 page PDF document. The document is composed of various sections containing paragraphs of text from various different datasources.
I’ve tried to produce the document using Jasper and iReport, however I’m reaching the conclusion that the format of my document is too complex for Jasper/iReport.
I’ve constructed various custom datasource classes that implement the JRDataSource interface to return the contents of the various sections within the document. In iReport, I’ve created a collection of subreports for each of the different sections. Each subreport is associated with a custom datasource.
The problem I’m experiencing is that the layout of the resultant PDF does not reflect what I’ve designed in iReport. The subreports appear overlapped instead of appearing in the sequence I’ve designed in iReport. I’ll need to produce about 8 of these subreports for the entire document.
Do you think its possible to produce this type of multiple page documet with various subsections using Jasper/iReport or is this too complex? Would JasperAssistant be more suitable?
I’m thinking maybe I should be using a framework like iText?
Thanks in advance.
I don’t have any experience with iReport, and haven’t done much with subreports. You are correct to use subreports in your situation, but I’m surprised that it isn’t coming out the same as you design. So far, with the 35+ reports we’ve done with Jasper using JasperAssistant, they have all come out looking exactly as we have designed them. The PDF version is exact, while the HTML is a little off, but I don’t think that’s to be expected.
Before using Jasper, I created a report with iText, and it did work, but it was more time consuming than creating a report with JasperAssistant.
I believe iText is used by Jasper, but if you use just iText alone, you may run into some problems when you want to do parts of a form that grow. I don’t believe iText is very good for that. When I came across the requirement to have dyanamic reports as opposed to a form that could be filled out, I had to move from iText to Jasper.
Yes, Open Reports is fantastic because it is a good simple reporting framework. I come from a Visual FoxPro background and have a some conversion program to translate a FoxPro report directly into the band based XML definition. It works like a dream because both reporting methods use bands and it is only a matter of converting the band scaling between the two types of reports. The SQL to drive the report is simply inserted into the XML.
The problem I have found is in the use of American date format in Open Reports but I am sure that this can be solved.
Regards
Anton
Being one of the usual requirements, dynamic column report is quite difficult and report specific with JR. I’m planning to write Generic Report Design Modifier based on query and parameters. All i want to know is
-> have u attempted this
-> other possible way u can think, i know this things can hardly get any generalization.
Thanks,
A few of the reports I had to create, required a form of cross tab reporting. So I created a framework within Open Reports to accomplish this. It is report specific, but is very simple to implement per report. It works on the premise that Jasper can populate the report from a Collection of objects. So instead of populating from a JDBC results set, a CrosstabAction is used to convert the JDBC result set into a generic Collection which the Jasper report uses to fill itself. The Action reverses the data from column to row, or performs any other type of “rearrangement” of the data that you may need to do that can’t be done via SQL. We have used it now for two reports and once I figured out the idea and the framework in the first report, the second report only took a few minutes to implement.
hello,
I want to generate a dynamic columns report in jasper report ,(ireport), i want the column shold be decresed in number or increased in number as user wants,
if user want 2 coloum he will get 2 coloums if he select 3 coloumns then three and so on…so pls help me i have urgency to produce the report thanking you alll…
u can contact me rashesh_patel007@yahoo.com
Waiting for reply…eagerly
Hi,
I am using Jasper Reports for my current project. Things are working fine except for one thing.
When i generate a Jasper Report, it opens up on the server not on the client.
Please tell me what I need to do to open up a Jasper Report on the client.
Right now it is opening up in the server, I need to open it on the client.
My code is as follows:
JasperDesign gratuityReportDesign = JasperManager.loadXmlDesign (”../server/default/deploy/reports/GratuityConsoleReport.jrxml”);
JasperReport gratuityJasperReport = JasperManager.compileReport (gratuityReportDesign);
Map parameters = new HashMap ();
parameters.put (”Title”, “Gratuity Report”);
parameters.put (”FromDate”, ( (GratuityConsoleInputDataVO) data )
.getFromDate ());
parameters.put (”ToDate”, ( (GratuityConsoleInputDataVO) data )
.getToDate ());
parameters.put (”LOGO”,
“../server/default/deploy/reports/logo.jpg”);
conn = DataAccessUtil.getConnection ();
JasperPrint jasperPrint = JasperManager
.fillReport (gratuityJasperReport, parameters, conn);
JasperViewer jasperViewer = new JasperViewer (jasperPrint, false);
jasperViewer.show ();
This code opens the report on the server. Please tell me how to open it on the client.
Thanks alot
Sandeep
I’m not sure if you are running this in a Servlet/JSP or in a Java class, but the reason its opening on the server is because your use of JasperView.show(). Instead, if you wanted to create a PDF and stream it to the user, you would use some code like this:
ReportWriteProvider reportWriteProvider;
byte[] pdfByteArray = JasperExportManager.exportReportToPdf(jasperPrint);
response.setContentType(”application/pdf”);
response.setHeader(”Content-disposition”, “inline; filename=” + report.getName() + “.pdf”); response.setContentLength(pdfByteArray.length);
ServletOutputStream out = response.getOutputStream();
reportWriteProvider.sendPDFToStream(pdfByteArray, out);
Hi,
there is a user requierement to be able to generate ad-hoc reports. Something like user may decide which columns to render, or even decide the font size, padding, and so.
Do you know any solution, which will satisfy this requirement?
(we’re using jasperreports)
I am not currently familiar with any software that would fulfill those requirements. Open Reports would come the closest, but probably would not allow users to customize their own reports.
JasperReports is not intutive enough, you need to have allot of knowlegde of JAVA to run for example your own applet implementation, this is the fact with most opensource tools (not php, apache, they are really good documented, but this)
I can find no specific documentation on instaling JaspeReports. There seems to be a lot of piecemeal stuff but no detailed guide as to how one installs and configures this product. Can anyone point me in the right direction?
Thanks
I’ve been evaluating JasperReports and found it almost answers all our requirements. For us to commit to it we need to know the following:
- How easy it would be to add a feature that would allow to save instances of report templates, preferrably in a database table? In this case, an instance would be a group of parameters values.
We need a mechanism for users to 1) define this group of parameters 2) save the instance parameter values in the database 3) pull up this instance (predefined values of parameters) from the database. This feature would allow users to avoid specifying parameter values every time through the UI.
The workaround is to save every instance as a separate report file. But this solution isn’t scalable when targeting an ASP market.
can we add or remove the columns dynamically in jasperreports
performance issue in jasperreports , jaspereports is fine for reports contain minimum number of records , when go for large number of records application performance will down , any one can help me , please very urgent
I suppose performance depends on your point of view. We have a report that returns a PDF that is over 500 pages, which is approximately over 30,000 rows. It takes about 2 or 3 minutes to run. To me, that is very acceptable performance for a report of that size.
As for adding or removing columns, there are two options. First, you can use conditionals as the column expression to dynamicaly choose which field to populate a column with. I used this in one report that can have three different looks. It checks a passed parameter to determine which report it is, and from that alters the header for each column, and the value for each column.
The second method would be to alter the jasper report xml based on your critera, then compile it and run it. I do a lot of xml creation, so that part of it I don’t have a problem with. However, I have not compiled a Jasper report on the fly and I would worry that doing so would be a performance hit.
Other than that, I do not believe that Jasper has any features for dynamically designing reports on the fly.
Gerry - it sounds to me like you are describing Open Reports, which is a web framework on top of Jasper. That is what I use (although very customized from what I downloaded). Have you tried that?
Del Thompson - the best way to get started with Jasper Reports is to download the demo project, put it in Eclipse, and play around with running the reports. That is how I got started.
To get the samples, go here: http://sourceforge.net/projects/jasperreports
Click on jasperreports, and then choose to download the jasper project zip file.
I have a reporting tool which uses the Jasper Reports. I feel there is a functionality using RDL’s where we can have alternate background colors in JasperSoft Reports. Now I am not able to export them to PDF. Do you have any idea of tags required to enable it?
For ex I use rowStyle as RDL Arguments to enable
You can mail me to my email-id. Thanks in Advance
hi,
I am planning to use Jasper Reports insted of Crystal Reports in my new project can u plz tell me Jasper Reports suported to .net technology
Hi,
I need to export reports to PDF and CSV/EXCEL formats. I am able to successfully export reports to all three format(with same jasper print object) the only problem is the export includes page elements that are not really relevant to the format.
For example, if you I create a report with a footer that contians page numbers and fill/export the report to PDF I generate a nice paginated report with page numbers at the bottom. If I fill/export to EXCEL I get EXCEL that is paginated with page numbers at what would be the bottom of the page only all of this is on one page. If I fill/export to CSV I get comma delimited rows that are again paginated and page numbers at what would be the bottom of the page. This makes no sense from a semantic point of view. The purpose of exporting to CSV would be to provide the detail of the report in tabular format for conversion into another format, like Excel. You don’t care about page numbers nor do you want them.
So, I was wondering if anyone else has had this same problem and created a workaround. If so, what was the workaround?
VJ,
When I first did an export to CSV/Excel I was just as surprised as you were about the result. And to my knowledge, there is nothing you can do about, other, than to add in a suppression expression for every element you wouldn’t want in the CSV/Excel (which I think is way too much work). But, keep one thing in mind before you label this a bug. JasperReports is not a database tool. It is a reporting tool. All the XML that describes a Jasper Report would be worthless if all you wanted was a data dump from an SQL statement.
That can be done so easily without JasperReports, that it really makes no sense to use a reporting engine for a simple dump like that. I’m not sure who uses the CSV/Excel versions, as they strike me as very useless, but once I remembered what the point of Jasper Reports is, it didn’t surprise me as much.
Brian
Brian,
“………..
than to add in a suppression expression for every element you wouldn’t want in the CSV/Excel” - But how we do this, if we use same jasper print for both export to excel and export to pdf? AS in pdf i need pagenumber whereas in excel i don’t
You pass in a parameter to the Jasper Report that tells it how its being exported (PDF, XSL, etc). Then in the Print When Expression for each element, you check that parameter to decide if you want it printed.
So do you mean to say that we need to have have two different JasperPrint objects - one for excel and one for pdf?
Brian,
To build jasper for reports that have dynamic columns, i am building the jasper using java code.But if the value is null its throwing,
net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression : null
Source text : $F{col8}
at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:407)
but the same design works with non null values data.
This is the code thru which i build detail part.
public static JRDesignTextField buildTextField(Class clazz, int xcorod,
int ycoord, int width, int height, JRFont fontType, String fieldName) {
JRDesignTextField textField = new JRDesignTextField();
textField.setBlankWhenNull(true);
textField.setStretchWithOverflow(true);
textField.setX(xcorod);
textField.setY(ycoord);
textField.setWidth(width);
textField.setHeight(height);
textField.setTextAlignment(JRTextElement.TEXT_ALIGN_RIGHT);
textField.setFont(fontType);
JRDesignExpression expression = new JRDesignExpression();
expression.setText(”$F{” + fieldName + “}”);
expression.setValueClass(clazz);
textField.setExpression(expression);
return textField;
}
Kindly let me know where the problem is..
Thanks
VJ
My requirement is to generate a HTML output using JasperReports, with pagination.ie say 50 records per page and then on clicking the next button should display the next page.I do not want all the records on just one page.
Thanks in advance
RT
hi,
We are using Jasper Assistant for generation of reports, it is a good tool as an eclipse plugin to generate reports, but we are having problem with it that is The reports which we print does not have a line in the header which we require,how to print lines in our report.
Please help us.
Bye
RT
If you want to paginate in HTML, there is a parameter in Jasper using the JRHtmlExporter class, that basically sets the number of the page to visualize inside the browser, your code only have to set this number properly when the action is called with the ‘next’ button, like in the following code snippet:
JRHtmlExporter exporter = new JRHtmlExporter();
...
exporter.setParameter(JRExporterParameter.PAGE_INDEX, new Integer(pageIndex));
...
exporter.exportReport();
Hope it helps.
Cheers.
Viva México
Is the Jasper Assitant free ?
Which took can i use to create reports.
Jasper Assitant or Open report designer
I personally prefer Jasper Assistant. It is not free, but to me it was well worth the cost.
The company that produces Open Report designer is certainly good as well. I don’t use their designer, but I rely heavily on their Open Reports system, which is a web gui for Jasper Reports.
Brian
Hi Brian,
Should I try to declare more of my methods to be static?How would i know i am overusing static methods? What are ideal scenarios where i can use static methods? Say in my module, i have a separate database entity file wherein i put all the methods which access database.Is it ok to declare all the methods static?
Say i have ReportDb.Java and i have
public static ResultSet getDataResultset(String storeprocName){
//Code to access DB and return resultset
}
kindly let me know..
Hi
I am designing report with iReport and than using Jasper Code I am running that jrxml file to generate report files and save them in a Location, The export options in jasper code are limited to pdf, xml, html, csv only. But, I want to export the report into Microsoft’s Excel Format, So could anybody please guide me how i can manage that using jasper code.
I shall be thank Full to You.
Thanx in advance.
Sunil,
There is a JRXlsExporter() in Jasper.
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, ds);
JRXlsExporter exporter = new JRXlsExporter();
ByteArrayOutputStream xlsReport = new ByteArrayOutputStream();
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, xlsReport);
exporter.exportReport();
System.out.println(”Sixe of byte array:”+xlsReport.size());
bytes = xlsReport.toByteArray();
response.setContentType(”application/vnd.ms-excel”);
response.setContentLength(bytes.length);
ServletOutputStream ouputStream = response.getOutputStream();
ouputStream.write(bytes, 0, bytes.length);
ouputStream.flush();
ouputStream.close();
Brian
VJ,
The compiler will certainly let you know if you have wrongly marked a method static. You don’t have to worry that if it compiled and ran as static, that you shouldn’t have marked it static.
Best to read some existing information on the net about when to use static. For example:
http://www.artima.com/designtechniques/staticP.html
Brian
Dear Brian,
I am really very thankfull for your co-opration,
But the problem still remain, because i could’nt found JRXlsExporter() in my jasper code, So could you please guide what should i do to solve this problem.
Thanx a lot.
Sunil
Hi all,
i would like to generate my JasperReport to html file on the server for my clients.
I use on my jsp:
JasperExportManager.exportReportToHtmlFile
but my problem is, i generate the report_html_files on the server, but i would like it on a outputstream.
Have anyone a solution for me?
Thanks,
Mat
Does anyone have experience with using an html document as a source field? I have database text items that store html documents that need to be included into a report. The report currently prints out the tags.
I changed the field to styledtext=”true” which stops the tags from printing but does not produce the proper result. For example, if the html has a tag I would expect a new line. Currently, nothing happens. Any idea how to make the work.
Thanks for your help.
John
Hello,
Thanks much for responding. I have started using IReport Designer. But i have a problem. Iam almsot done with the designs. But the labels on the chart x-axis are getting shortened to 2 letters or either replaced with dots “…” like this. Someone told me that i need to implement JRChartCustomizer. But ours is not swing based application. Can you please show me the proper way. Iam almost done with my designs and stuck up there.
Thanks
Sam
hi all
i have the same problem with a html field source, i try to with the styledtext=”true” clausule and it print a blank line for each html tag. I try with the last version of JasperReport and nothing.
Thanks a lot for your help.
Franklin
I need jasper report step by step guide, pls help me
I’m working with Jasperreport-1.1.0 and i’m using JasperAssistant. Whenever i try to create a custom data source i get the following error:
Data Source failed
Reason:
Failed to load the specified provider class:
datasource.ExampleDataSourceProvider
The location of the file in my project folder is webapp/WEB-INF/classes/datasource/ExampleDataSourceProvider
This is my code:
public class ExampleDataSourceProvider extends JRAbstractBeanDataSourceProvider{
public ExampleDataSourceProvider() {
super(CustomBean.class);
}
public JRDataSource create(JasperReport report)
throws JRException {
ArrayList list =new ArrayList();
list.add( new CustomBean(”Berne”, new Integer(9), “James Schneider”, “277 Seventh Av.”));
list.add( new CustomBean(”Berne”, new Integer(22), “Bill Ott”, “250 - 20th Ave.”));
list.add( new CustomBean(”Boston”, new Integer(23), “Julia Heiniger”, “358 College Av.”));
list.add( new CustomBean(”Boston”, new Integer(32), “Michael Ott”, “339 College Av.”));
list.add( new CustomBean(”Chicago”, new Integer(39), “Mary Karsen”, “202 College Av.”));
list.add( new CustomBean(”Chicago”, new Integer(35), “George Karsen”, “412 College Av.”));
return new JRBeanCollectionDataSource(list);
}
public void dispose(JRDataSource dataSource)
throws JRException {
// nothing to dispose
}
}
I’d really appreciate your help. Thanks in advance.
Cherry
Hi All
Subject: Designing in ireport
I have a report having many four groups, and i want to print values in groupheaders, It is working well, But It is printing one line per group header. But i want to merge following band in that printed band (as “underlay following section” option in Crystal Report). Please Guide me, It is blocker Issue to me. I ma using SQL procedure in backend for data source
Thanx a lot.
Subject: localized resources
Hi all,
Is it possible to use a field value as input to a localized resource value.
I have a code coming from the database $F{CODE}.
I want to retrieve the resource bundle value for this code using something like $R{CODE} or $R{$F{CODE}, but neither seems to work.
Has anyone managed to do something similar ?
Thanks,
Alan
Hi All
I am new use Jasper Report and iReport ( designer ).
How to call jasper report file use apache web ? please give example script ( to call report jasper from client )
Thx
Budi Santoso
Hi team
I am using jsp to generate pdf. i generate the pdf file on the server, but i would like it on a outputstream.
But in JSP i am unable to open the output stream.
also i need to open the pdf in a new window with out distrubing the application.
jasperPrint = JasperFillManager.fillReport(report, parameters,conn);
byte[] pdfasbytes = JasperExportManager.exportReportToPdf(jasperPrint);
JRPdfExporter exporter = new JRPdfExporter();
ByteArrayOutputStream pdfReport = new ByteArrayOutputStream();
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, pdfReport);
exporter.exportReport();
pdfasbytes = pdfReport.toByteArray();
response.setContentLength(pdfasbytes.length);
ServletOutputStream ouputStream = response.getOutputStream();
ouputStream.write(pdfasbytes, 0, pdfasbytes.length);
ouputStream.flush();
ouputStream.close();
I am trying to deploy JasperReport in JBOSS.
The same WAR file work in JDEV 10G application server, but when I try to deploy it in JBOSS its throwing me “org.apache.jasper.JasperException: tried to access field org.apache.commons.digester.Digester.log from class org.apache.commons.digester.SetNestedPropertiesRule$AnyChildRule
” error.
I guess its some to do with classpath setting, but not sure.
Let me know if anybody else had the same problem and find solutions.
Thanks,
-Varun Chudiwale
Subhashini, you need to set the “Content-Disposition” header in your response object. In doing this you then have the ability to tell the browser that the response content is an attachment (causing it to open in another window).
Like so:
response.setHeader(”Content-Disposition “, “attachment; filename=”+theFileName);
using the filename, your client should be able to open/save the report using a more friendlier filename rather than the page name (which would be the default).
Does anybody know how to tell when a generated report contains no data before sending it to the client?
Comment no. 74 is ok to genrate the report in sepeate window without disturb current application, but this code does not work soetime so anybody has idea about that.
Hai Brian,
how to create on the fly query in JR ?
example :
1: SELECT * FROM user a
2: inner join tables_priv b on b.host = a.host
3: Where user = ‘anyone’
i would like to change line 2 in this query to become
inner join host b on b.host = a.host
why i use like that because i like to use one JR file and i can get two result report, of course i must use an alias for field name.
TIA,
andy
i think i solve my problem with my trial and Error Method
Thanks,
Andy
I how to create a matrik Report like this
Jan Feb April
=========================
David 1 2 3
Guest 2 5 1
TIA,
Andy
Use CustomDataSource for getting Matrix Reports
Hi,
I have seen few questions above asking about how to send a collection object (Hashmap, ArrayList) to fill a report; but there is no reply on this.
I can do this by passing data source, Result set but my requirement is to send data in any collection object to fill in report as my results are out come of many queries.
Please share your thoughts.
Thanks,
Sandeep
I need to open exported PDF file to open. I am using the code pasted in this blog, but not sure which “ReportWriteProvider” to use and how, from where to get this class.
Code is :
ReportWriteProvider reportWriteProvider;
byte[] pdfByteArray = JasperExportManager.exportReportToPdf(jasperPrint);
response.setContentType(”application/pdf”);
response.setHeader(”Content-disposition”, “inline; filename=” + report.getName() + “.pdf”); response.setContentLength(pdfByteArray.length);
ServletOutputStream out = response.getOutputStream();
reportWriteProvider.sendPDFToStream(pdfByteArray, out);
I’d really appreciate your help. Thanks in advance.
Hai Brian,
you have given this code for create pdf file at client side..
ReportWriteProvider reportWriteProvider;
byte[] pdfByteArray = JasperExportManager.exportReportToPdf(jasperPrint);
response.setContentType(”application/pdf”);
response.setHeader(”Content-disposition”, “inline; filename=” + report.getName() + “.pdf”); response.setContentLength(pdfByteArray.length);
ServletOutputStream out = response.getOutputStream();
reportWriteProvider.sendPDFToStream(pdfByteArray, out);
in the above code what type of obeject “report”(report.getName())..
don’t mind could you explain it…
thanks in advance..
regards,
Brahma
Hi
I am java newbie and would like to know if it is possible to let an action call the necessary code to generate a report using Jasper Reports.Would Jasper Assistant help?Could you explain the process to me?
thanks and regards,
Vijay
Hello,
I have been using jasperreports for some time now.
I am facing some problems while designing my report.
1. My report has varied no.of columns i.e. it could contain 2,3 or 4 columns. I cant figure out as how to adjust the no.of columns dynamically within the same page width.
Say, if my page width is x, then x should be sum of either c1+c2 or c1+c2+c3 or c1+c2+c3+c4.
2. Second problem is a similar one, only difference would be that the no.of columns is fixed i.e but their width is supposed to the varied.
3. Finally, 2 sets of data to be displayed in MainHeaderGroupFooter, with varying no.of rows.
Now if I give a fixed height, both these overlap.
Your help is much appreciated.
Regards,
Dev
As you all can see, there have been a lot of comments and questions for help on Jasper, and I haven’t had time lately to help you out.
I have added a forum to allow further discussion, and hopefully input from other Jasper users. Feel free to post there or to continue to post comments here. I will answer questions as time allows.
The main forum is here. The thread for this comment is here.
Brian
mi problem is with the query
i’m using ireport but i do not know how write the sql syntax for LIKE, y tried all the ways and when excute the report show me nothing, totally blank
SELECT [_Empleados].EM_Nombre, [_Empleados].EM_RFC, BienesMuebles.BM_Descripcion, BienesMuebles.BM_NumeroInventario, BienesMuebles.BM_NumeroSerie1, BienesMuebles.BM_NumeroSerie2, BienesMuebles.BM_Observaciones, [_Departamentos].DP_Descripcion, BienesMuebles_Empleados.BMEM_FechaInicio FROM BienesMuebles INNER JOIN ((_Empleados INNER JOIN _Departamentos ON [_Empleados].DP_ID = [_Departamentos].DP_ID) INNER JOIN BienesMuebles_Empleados ON ([_Empleados].EM_ID = BienesMuebles_Empleados.EM_ID) AND ([_Departamentos].DP_ID = BienesMuebles_Empleados.DP_ID)) ON BienesMuebles.BM_ID = BienesMuebles_Empleados.BM_ID WHERE ((BienesMuebles_Empleados.BMEM_FechaFin) Is Null) AND BienesMuebles.BM_NumeroInventario Like $P{INVENTARIO};
some ideA?
[…] Jasper and Open Reports - Brian Burridge on Internet Development Jasper and Open Reports - Brian Burridge on Internet Development […]
Edgar,
To do a like statement using a parameter you have to do it like this:
like $P{INVENTARIO} + ‘%’
This should work.
I am trying to do a crosstab report in jasper and I can’t seem to get it working. If anyone has any good examples for me it would be greatly appreciated.
Thanks,
hai,
in my client computer i can not show print dialog from JasperReport.
i am using a Tomcat 5.5.x, is there something wrong in Tomcat. Because if i running Tomcat from eclipse printdialog will showing
any suggestion ?
TIA,
Andy Susanto
Hi, i try use crosstab of jasperreport too. But without succes. It doesn’t work.
If anybody has some simple example of jasperreport crosstab using, please send me the reference.
Tahnks, regard Michal.
Hi, i am getting this exception when trying
to save the report to pdf using the “save as” button in JasperViewer.
(i have itext-1.3.jar)
Exception in thread “AWT-EventQueue-0″ java.lang.NoSuchMethodError:
com.lowagie.text.pdf.PdfContentByte.transform(Ljava/awt/geom/AffineTransform;)V
at
net.sf.jasperreports.engine.export.JRPdfExporter.exportText(JRPdfExporter.java:1469)
part of the code :
Statement stmt = database1.createStatement();
ResultSet rs = stmt.executeQuery (wsql);
JRDataSource jrRS = new JRResultSetDataSource( rs );
HashMap hs = new HashMap();
JasperPrint prt = JasperFillManager.fillReport(pathRelatorios +
relatorio + “.jasper”, hs, jrRS);
JasperViewer jrviewer = new JasperViewer(prt, false);
jrviewer.setVisible(true);
Thanks
We are trying to use OpenReports with Oracle9 to store the report meta data. When we try to create a new object (e.g. new user) we get the following error:
“SEVERE: could not read a hi value
java.sql.SQLException: ORA-00942: table or view does not exist”
Any idea/help will be much appreciated.
Thanks
Can you help me setup Openreports.
I am using Linux (RH). What do I need to do.
I downloaded Open Reports and Open Reports -Tomcat , but it seems like it is setup for the windows platform.
help!
Karl,
I don’t recall having to do anything. When you unzip the download, there is a WebRoot folder. The contents of that is your web app. If you just copy the WebRoot directory to your $TOMCAT_HOME/webapps directory and rename it to openreports, you should then be able to go to your url/openreports/ and see the basic openreports come up. There are some settings to set the correct path to where you will put the reports, but at lesat you should see it running very quickly.
Anirban,
Did you follow all the steps for setting up the database? The install guide lists out all these steps, and that error you are getting seems to imply that you don’t have the tables its looking for.
Michal,
I haven’t yet used Jasper built in crosstab features. When I began using Jasper there was no crosstab, so I wrote my own. What I did was so simple that we have continued to use it. Its so quick to do what we need. One day I’ll sit down with Jasper’s solution and see which I like best.
andy susanto,
I’m not really sure what print dialog you are looking for. Are you using a graphical interface like JasperAssistant, or are you running a report from within Tomcat? Any report you want to print from within Tomcat would use your browsers print functionality.
I want to use JRBeanCollectionDataSource with jasper,this is my code:
public class create_report {
public static void main(String[] args) throws JRException, IOException {
Session session = HibernateSessionFactory.currentSession();
List cats = session.createQuery(”from Book “).list();
Map parameters = new HashMap();
parameters.put(”Title”, “The Cat Report”);
Class aclass=create_report.class;
InputStream reportStream = aclass.getResourceAsStream(”/the-cat-report.xml”);
JasperDesign jasperDesign = JasperManager.loadXmlDesign(reportStream);
JasperReport jasperReport = JasperManager.compileReport(jasperDesign);
String[] fields = new String[] { “id”, “title”, “author”,”borrowallowed”};
HibernateQueryResultDataSource ds = new HibernateQueryResultDataSource(cats, fields);
JasperPrint jasperPrint = JasperManager.fillReport(jasperReport, parameters, ds);
JasperManager.printReportToPdfFile(jasperPrint, “the-cat-report.pdf”);
HibernateSessionFactory.closeSession();
}
}
I use eclipse,the-cat-report.xml under “src”,
After run it,I get
Exception in thread “main” java.io.FileNotFoundException: D:\Program Files\eclipse\workspace\SecondTest\Unnamed.class (系统找不到指定的文件。)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.(FileInputStream.java:106)
at net.sf.jasperreports.engine.util.JRLoader.loadBytes(Unknown Source)
at net.sf.jasperreports.engine.design.JRAbstractClassCompiler.compileReport(Unknown Source)
at net.sf.jasperreports.engine.design.JRDefaultCompiler.compileReport(Unknown Source)
at net.sf.jasperreports.engine.JasperCompileManager.compileReport(Unknown Source)
at net.sf.jasperreports.engine.JasperManager.compileReport(Unknown Source)
at com.yfsy.jasper.create_report.main(create_report.java:60)
NESTED BY :
net.sf.jasperreports.engine.JRException: Error loading byte data : D:\Program Files\eclipse\workspace\SecondTest\Unnamed.class
at net.sf.jasperreports.engine.util.JRLoader.loadBytes(Unknown Source)
at net.sf.jasperreports.engine.design.JRAbstractClassCompiler.compileReport(Unknown Source)
at net.sf.jasperreports.engine.design.JRDefaultCompiler.compileReport(Unknown Source)
at net.sf.jasperreports.engine.JasperCompileManager.compileReport(Unknown Source)
at net.sf.jasperreports.engine.JasperManager.compileReport(Unknown Source)
at com.yfsy.jasper.create_report.main(create_report.java:60)
Caused by: java.io.FileNotFoundException: D:\Program Files\eclipse\workspace\SecondTest\Unnamed.class (system not find the file。)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.(FileInputStream.java:106)
… 6 more
Thanks
hi there, first of all, im glad to see an active thread about jasperreports. their own sites seem abandoned (can you blame them…). my problem had come a few times across but no answer. i have a fully working program (servlets/ireport/jasperreports) but i cant get the export pdf and print dialog to go to the client side. always it comes up on the server.
what can i (we) do to send it to the client. can we keep a central topic here?
please help, it is driving me insane in the membrane…:-)
thanx in advance
Frederik
Dear All,
please tell me, to use JasperReport-
-which webserver i need to install
-how to configure jasperreport and downloaded files after i downloaded it.
thanks
Hi there,
I found a solution to my problem: the client side doesnt get a printdialog but the server side does. i used this code to export it to a pdf in the client sides browser. now the client can save and print it. only thing is that the font is standard (all my bod texts are normal now), but it works. i hope someone finds this usefull.
if someone has an addition or improvement please tell.
JasperPrint print = JasperFillManager.fillReport(bestandsnaam, reportParam, c);
//JasperPrintManager.printReport(print,true);
//JasperViewer jv = new JasperViewer(print);
//jv.viewReport(print);
byte[] pdfasbytes = JasperExportManager.exportReportToPdf(print);
JRPdfExporter exporter = new JRPdfExporter();
ByteArrayOutputStream pdfReport = new ByteArrayOutputStream();
exporter.setParameter(JRExporterParameter.JASPER_PRINT, print);
exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, pdfReport);
exporter.exportReport();
pdfasbytes = pdfReport.toByteArray();
response.setContentLength(pdfasbytes.length);
//response.setHeader(”Content-Disposition”, “attachment; filename=”);
ServletOutputStream ouputStream = response.getOutputStream();
ouputStream.write(pdfasbytes, 0, pdfasbytes.length);
ouputStream.flush();
ouputStream.close();
none of the forums was about to answer to my question. can any one of u help me …
question: how to execute oracle procedure in ireports
i experimented it with following code.
@exe{procedure_name(parameter)} but it shows sql syntax error.
i need the solution as early as possible.
going through this forum i found this as good problem solver forum.
so please help me.
advanced thanks
with regards
mohan kumar
Hi all,
are anyone work with resource bundle in combination jasper report and ireport.
If anybody has some simple example of it, please send me the reference.
Thanks in advance.
Mohan Kumar,
I was never able to call an oracle stored procedure, but I was able to call an Oracle stored function. Once you’ve written the stored function, calling it is exactly like a regular select, which is why it works ok in Jasper. So for example, you would call it like this:
select column1, column2, column3 from table( RPT_ASBUILT_D_FUNC(param, param))
I have used that in at least 20 different reports.
Hi everyone
Im working with a javabean set datasource
my bean has a java.util.ArrayList with beans inside and i need to iterate the arrayList in a group to show the details, can you help me?
Thanks
Hi Brian,
You said you could use the Oracle functions in Jasper reeports.
I am trying to do the same but in vain.
I have a function which returns 2 values, so I have followed u r example and trying the sql as:
SELECT dayeRemaining, totalDays FROM table (FN_CALCULATE_DAYS ())
but it throws an exception saying
java.sql.SQLException: ORA-22905: cannot access rows from a non-nested table item
Any suggestions please.
pls tell me how to call a stored procedure/function from jasper report
while calling the function from the jasper report, i’m also getting the same excepton as mohan is geeting, pls tell us the syntax of calling a function form jasper report
java.sql.SQLException: ORA-22905: cannot access rows from a non-nested table item
hey,
Im using jasperreports and facing 2 probs…firstly the inputstream doesnt seem to read the jrxml; file and the compile manager throws an exception…secondly the query needs to b satisfied wit a parameter which i have given as follows[CDATA[select distinct a.ArticleNumber,a.Name,a.Note,b.ProductSpecification,b.ProductionDate,b.ExpirationDate,b.LotNumber,c.ColorLevelName
,d.TrueValue,e.Name as UnitName,f.Name as ParaName,f.Calculated,g.ProductionOnlyParameter,h.Name as StatusType from QCColorLevel as c inner join QCType as a on
a.IDQCColorLevel=c.ID inner join Lot as b on a.ID=b.IDQCType inner join LotParameterUnit as d on b.ID=d.IDLot
inner join ParameterUnit as e on e.ID=d.IDParameterUnit inner join QCTypeParameterUnit as g on e.ID=g.IDParameterUnit
inner join Parameter as f on e.IDParameter=f.ID inner join StatusType as h on h.ID=b.IDStatusType where b.LotNumber like $P[LotNumber]….yet it throws an exception of an error in preapring the statement…any ideas ppl
i have not seen where this below problem is handled in jasperReport-iReport.
how can one send several different javabean collections as a datasource to iReport using jasperreports?
i think this is a required anser.
Hi,
subject: Custom Datasource - Subreports
situation: The master report uses a JRDataSource (say MasterDS) with fieldA and fieldB. While filling the master report, the MasterDS also fills a bean which must serve as a custom datasource for a subreport with fieldC. This subreport is called in the report Summary . problem: It’s strange but when running, Jasper needs getFieldA() and getFieldB() in the bean although these fields are not needed in the subreport.First I’ve tried to use a second JRDataSource instead of a bean but with the same result.
Questioin: Is there some way to use multiple total independant datasources within the same report-subreport. If so, please any hint would be welcome as this whole thing keeps me busy for 2 days.
Thanks and have a nice day,
Rose
Hi,
I want to change the report font at run time. But i have no idea. please guide me
concerns my post of 21th april:Custom Datasource - Subreports.
My problem is solved, i’ve made a very stupied error. Meanwhile: Jasper - iReport is great, thanks!
Rose
Hi,
I see dependencies on iText, POI, JExcel, JFreechart. Are these optional?
I have to generate a simple report that is sent to a printer. It has a title, page header, column header, detail and summary.
Can I just not include those jar files?
Thanks,
BP
http://www.ProblemSolvingSkill.net
Hi
i am using iReport to create reports.
i am unable to fill the subreport with data. it compiles but when i execute, it gives the error
” [subreport subreport filler] WARN query.JRJdbcQueryExecuter - The supplied java.sql.Connection object is null.”
when i run the subreport independently with a default value of the parameter, it gives the error
“Error filling print…
java.sql.SQLException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘{EMPID}’ at line 1 at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2926)
…”
How do i solve this ?
can someone please tell me a simple example of how to use crosstab for generating matrix style reports …
when i use jasper for filling crosstab reports i get the fillowing error:
NESTED BY :
net.sf.jasperreports.engine.JRRuntimeException: Error incrementing crosstab dataset
at net.sf.jasperreports.engine.fill.JRFillCrosstab$JRFillCrosstabDataset.customIncrement(JRFillCrosstab.java:638)
at net.sf.jasperreports.engine.fill.JRFillElementDataset.increment(JRFillElementDataset.java:134)
at net.sf.jasperreports.engine.fill.JRCalculator.calculateVariables(JRCalculator.java:154)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:621)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportContent(JRVerticalFiller.java:248)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:132)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:747)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:644)
at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:63)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:402)
at com.tcs.rdv.rdm.rdc.XYZ.reportgenerator(XYZ.java:108)
at com.tcs.rdv.rdm.rdc.XYZ.main(XYZ.java:143)
Caused by: net.sf.jasperreports.engine.JRException: Crosstab data has already been processed.
at net.sf.jasperreports.crosstabs.fill.calculation.BucketingService.addData(BucketingService.java:280)
at net.sf.jasperreports.engine.fill.JRFillCrosstab$JRFillCrosstabDataset.customIncrement(JRFillCrosstab.java:634)
… 11 more
Hi,
I am having a problem while exporting a jasper report in html viewer.Some fields are missing in the html page.Can anyone please provide me any solution?
Hi,
I try export report to pdf file but i met this error
>>java.lang.IllegalAccessError: tried to access >>field org.apache.commons.digester.Digester.log >>from class >>org.apache.commons.digester.SetNestedProperties>>Rule$AnyChildRule
I haven’t found the way to fix it yet. Can anybody help me ?
Regards,
Tu
what Brian N. Burridge said is right.yes,i managed to call oracle stored function at last.
my table:
–create table:
SQL> create table a (id number,name varchar2(50),doctime date);
Table created.
–insert test data:
SQL> insert into a values (1,’aaa’,to_date(’2002-07-01′,’yyyy-mm-dd’));
1 row created.
SQL> insert into a values (2,’bbb’,to_date(’2002-07-02′,’yyyy-mm-dd’));
1 row created.
SQL> insert into a values (3,’ccc’,to_date(’2002-07-03′,’yyyy-mm-dd’));
1 row created.
SQL> insert into a values (4,’ddd’,to_date(’2002-07-04′,’yyyy-mm-dd’));
1 row created.
SQL> insert into a values (5,’eee’,to_date(’2002-07-05′,’yyyy-mm-dd’));
1 row created.
SQL> insert into a values (6,’fff’,to_date(’2002-07-06′,’yyyy-mm-dd’));
1 row created.
SQL> commit;
Commit complete.
–create two types
SQL> create or replace type myobjectype as object (x int,y date,z varchar2(50));
2 /
Type created.
SQL> create or replace type mytabletype as table of myobjectype
2 /
Type created.
–create function
SQL> create or replace function testrerecordnotabname (tableid in number)
2 return mytabletype
3 as
4 l_data mytabletype :=mytabletype();
5 begin
6 for i in (select * from a where id>=tableid) loop
7 l_data.extend;
8 l_data(l_data.count) := myobjectype(i.id,i.doctime,i.name);
9 exit when i.id = 62;
10 end loop;
11 return l_data;
12 end;
13 /
Function created.
SQL> commit;
Commit complete.
———————————————-
then in ireport ,i could write query sql:
select * from table(testrerecordnotabname(1))
order by Name desc
in this case, the fields returned is X, Y and Z.
to be more readable ,i wrote this:
select x as id,z as Name,y as doctime from table(testrerecordnotabname(1))
order by Name desc
Change the definition of type ‘myobjectype’ also does .
I know it is a bit fussy.But i hope it can help.
Wheather you can call a function in pakage,i didn’t try yet.
Hi everyone
Im working with a javabean set datasource
my bean has a java.util.ArrayList with beans inside and i need to iterate the arrayList in a group to show the details, can you help me?
Thanks
how to call a stored procederes using jrxml file
Hi Frederik,
Even i am facing the same problem printing the report in the client side..
Can you please explain it little briefly about printing it in client side
With Regards
SeshaGiri.V
Bhaskar,
You cannot call a stored procedure from a jasper report, since stored procedures do not return standard result sets (at least in most databases, there may be some exceptions).
However, I know you can in Oracle call a stored function, which can be made to return a standard result set. I hope to be writing up some instructions on how to do this over the next week.
sesha,
Can you explain what you are trying to do? My experience with JasperReports is all web based, and in that situation, the server returns a PDF, HTML, or whatever file you request to the user’s browser. The printing is then handled by the browser. Are you working with a web application or a desktop application?
chaitanyareddy_p,
You must pass your ArrayList of object to jasper as a JRBeanCollectionDataSource:
JRBeanCollectionDataSource ds = new JRBeanCollectionDataSource(list);
jasperPrint = JasperFillManager.fillReport(jr, reportParameters, ds);
Then in the JasperReport you refer to the object’s properties or methods, in an OGNL type manner. For example, to access the name property of an employee object within list objects, use:
employee.name
OR to reference a property called name within the list objects:
name
Regarding AUTHOR COMMENT for stored procedures
127. by Brian Burridge, @ May 26th, 2006
I am doing a research for using Jasper with stored procedures. Here are some ideas:
1. JavaBeans datasource could be used instead of queries. You can fill JavaBeans objects external to jasper calling stored procedures and pass this to jasper xml templates. Hibernate/Jasper integration is using it. For example:
http://www.jroller.com/page/wakaleo/?anchor=using_hibernate_queries_with_jasperreports
2. There is something written in the ‘JasperReports Ultimate Guide’ http://jasperreports.sourceforge.net/more.docs.html you can see table of contents 9.4.2
The problem is you have to pay to see the content. I didn’t buy it yet.
I want to print only 10 records per page while generating jasper report. but record size is 100. so i want to paginate that. How to do this? I want complete code. For both bean and datasource. Anybody can help me please?
Vector abcd[] = new Vector[3];
abcd[0] = new Vector();
abcd[1] = new Vector();
abcd[2] = new Vector();
abcd[0].add(”srikanth”);
abcd[0].add(”naga”);
abcd[0].add(”vani”);
abcd[1].add(”subadhra”);
abcd[1].add(”subadhra”);
abcd[1].add(”subadhra”);
abcd[2].add(”devui”);
abcd[2].add(”devui”);
abcd[2].add(”devui”);
Object os[] = abcd[1].toArray();
System.out.println(”this is os length”+os.length);
JRMapArrayDataSource vd = new JRMapArrayDataSource(os);
parameters.put (”Title”, “Gratuity Report”);
parameters.put(”Logo”,”C:/Documents and Settings/srikanth.ETG/Desktop/World_s_Tallest_Man.jpg”);
jasperReport = JasperCompileManager.compileReport(”C:/Documents and Settings/srikanth.ETG/Desktop/d.jrxml”);
//jasperPrint = JasperFillManager.fillReport(jasperReport,parameters,ac);
jasperPrint = JasperFillManager.fillReport(jasperReport,parameters,vd);
//JRPdfExporter exporter = new JRPdfExporter();
setParameter(JRExporterParameter.JASPER_PRINT,jasperPrint);
setParameter(JRExporterParameter.OUTPUT_FILE_NAME,”C:/Documents and Settings/srikanth.ETG/Desktop/classic1.pdf”);
System.out.println(”{{{{}}}}}}}”);
//exportElements(tm);
System.out.println(”{{{{}888}}}}}}”);
exportReport();
JasperViewer jasperViewer = new JasperViewer (jasperPrint, true);
jasperViewer.show ();
}
catch(Exception e)
{
e.printStackTrace();
}
}
public void addVectorToReport(Vector Elements)
{
try
{
//
}
catch(Exception e2)
{
e2.printStackTrace();
}
}
public static void main(String args[]) throws Exception
{
example e = new example();
System.out.println(”AFTER”);
}
}
I am adding the elements in mapArrayDataSource & MapCollectionDataSource it is compied successfully & executed successfully but the objects are not adding in thr report
Vector abcd[] = new Vector[3];
abcd[0] = new Vector();
abcd[1] = new Vector();
abcd[2] = new Vector();
abcd[0].add(”srikanth”);
abcd[0].add(”naga”);
abcd[0].add(”vani”);
abcd[1].add(”subadhra”);
abcd[1].add(”subadhra”);
abcd[1].add(”subadhra”);
abcd[2].add(”devui”);
abcd[2].add(”devui”);
abcd[2].add(”devui”);
Object os[] = abcd[1].toArray();
System.out.println(”this is os length”+os.length);
JRMapArrayDataSource vd = new JRMapArrayDataSource(os);
parameters.put (”Title”, “Gratuity Report”);
parameters.put(”Logo”,”C:/Documents and Settings/srikanth.ETG/Desktop/World_s_Tallest_Man.jpg”);
jasperReport = JasperCompileManager.compileReport(”C:/Documents and Settings/srikanth.ETG/Desktop/d.jrxml”);
//jasperPrint = JasperFillManager.fillReport(jasperReport,parameters,ac);
jasperPrint = JasperFillManager.fillReport(jasperReport,parameters,vd);
//JRPdfExporter exporter = new JRPdfExporter();
setParameter(JRExporterParameter.JASPER_PRINT,jasperPrint);
setParameter(JRExporterParameter.OUTPUT_FILE_NAME,”C:/Documents and Settings/srikanth.ETG/Desktop/classic1.pdf”);
System.out.println(”{{{{}}}}}}}”);
//exportElements(tm);
System.out.println(”{{{{}888}}}}}}”);
exportReport();
JasperViewer jasperViewer = new JasperViewer (jasperPrint, true);
jasperViewer.show ();
}
catch(Exception e)
{
e.printStackTrace();
}
}
public void addVectorToReport(Vector Elements)
{
try
{
//
}
catch(Exception e2)
{
e2.printStackTrace();
}
}
public static void main(String args[]) throws Exception
{
example e = new example();
System.out.println(”AFTER”);
}
}
I am adding the elements in mapArrayDataSource & MapCollectionDataSource it is compied successfully & executed successfully but the objects are not adding in thr report
I have posted a tutorial on a solution to calling Oracle Stored Procedures from within Jasper Reports:
http://www.brianburridge.com/2006/06/04/how-to-call-stored-procedures-from-jasper-reports/
Has any one tried LogiXML
We report to an organization on a complex form that they provide — the form is available as a pdf. In moving the report to Jasper, can work the of duplicating all of the graphical elements be avoided by pasting the pdf into the background and layering the data fields on top as unframed transparent objects? If this could be done, the data (mainly checkmarks) would appear in the right place in the printed view.
Rob, in theory, yes. though I have never tried to do something like that. What I would worry about is getting the checkmarks perfectly aligned. They could be off by a bit on every machine, do to variances in font sizes from computer to computer.
I know its more work, but I have successfully rebuilt complete PDF forms in JasperReports and had great success. Its virtually impossible to perceive a difference between the original form and the JasperReport created one.
how to sequence of number in each column in IReport(ie. Serial number of each column)
Sunil,
If you create a text field within the detail band, with an expression of: $F{LINE_NUMBER} and make that field a class of BigDecimal, it will provide the line number of the detail row you are on.
Is that what you are looking for?
java.lang.NoClassDefFoundError
java.lang.Class.forName0(Native Method)
java.lang.Class.forName(Class.java:141)
java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:62)
net.sf.jasperreports.engine.util.JRGraphEnvInitializer.initializeGraphEnv(JRGraphEnvInitializer.java:58)
net.sf.jasperreports.engine.fill.JRBaseFiller.(JRBaseFiller.java:404)
net.sf.jasperreports.engine.fill.JRVerticalFiller.(JRVerticalFiller.java:92)
net.sf.jasperreports.engine.fill.JRVerticalFiller.(JRVerticalFiller.java:74)
net.sf.jasperreports.engine.fill.JRFiller.createFiller(JRFiller.java:113)
net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:83)
net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:428)
com.etisbew.rezengine.report.JSPReports.processRequest(JSPReports.java:579)
com.etisbew.rezengine.report.ReportController.processRequest(ReportController.java:371)
com.etisbew.rezengine.servlet.REServlet.doPerform(REServlet.java:502)
com.etisbew.rezengine.servlet.REServlet.doPost(REServlet.java:237)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
thaks for ur help Mr.Brian Burridge
yes i want the row number in detail band, to increment when the new column is read. iam not want
for group header.
To Brian Burridge,
yes, i will try this. i want the each line number
in the detail band, when each line is created
by sunil
Hi,
I tried Brain method to call functions inside jasper reports and it works fine when the statement is in the following format
SELECT * FROM TABLE(Sys_54(10,’10/JUN/2000′,’10/JUL/2006′))
But I get an error when I need to pass a parameter instead of the predefined input,
SELECT * FROM TABLE(SYS_54($P!{SELECT_DEPARTMENT_ID}, $P{START_DATE}, $P{END_DATE}))
java.sql.SQLException: ORA-22905: cannot access rows from a non-nested table item
Please give me any idea.
NOTE this statements worked :
SELECT * FROM TABLE(SYS_54($P!{SELECT_DEPARTMENT_ID}, ‘10/JUN/2000′,’10/JUL/2006′))
i m getting ….java.lang.NoSuchMethodError: com.lowagie.text.pdf.PdfContentByte.transform(Ljava/awt/geom/AffineTransform
at net.sf.jasperreports.engine.export.JRPdfExporter.exportText(JRPdfExporter.java:1512)
at net.sf.jasperreports.engine.export.JRPdfExporter.exportElements(JRPdfExporter.java:523)
at net.sf.jasperreports.engine.export.JRPdfExporter.exportPage(JRPdfExporter.java:487)
at net.sf.jasperreports.engine.export.JRPdfExporter.exportReportToStream(JRPdfExporter.java:452)
at net.sf.jasperreports.engine.export.JRPdfExporter.exportReport(JRPdfExporter.java:260)
at net.sf.jasperreports.engine.JasperExportManager.exportReportToPdfStream(JasperExportManager.java:1
when i m going to show report in a PDf format as a servlet response .My code is as follows.
InputStream i=cl.getResourceAsStream(”itemReport.jrxml”);
jasperReport = JasperCompileManager.compileReport(i);
jasperPrint=JasperFillManager.fillReport(jasperReport, new HashMap(), new JRResultSetDataSource(resultSet));
JasperExportManager.exportReportToPdfStream(jasperPrint,out);
here out is OutputStream object passed by a servlet.
Please help me out.i have deployed all the required jars also.
Hello Brian. Thank you for your ongoing support.
In our (jakarta-based) jsp, we’ve compiled and exported our ResultSet data to pdf via:
JRPdfExporter exporter = new JRPdfExporter();
ByteArrayOutputStream pdfReport = new ByteArrayOutputStream();
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, pdfReport);
exporter.exportReport();
Things seem to be okay to this point.
However, we’re trying to then display this exported pdf info in browser window via:
byte[] pdfasbytes = pdfReport.toByteArray();
response.setContentType(”application/pdf”);
response.setContentLength(pdfasbytes.length);
ServletOutputStream ouputStream = response.getOutputStream();
ouputStream.write(pdfasbytes, 0, pdfasbytes.length);
ouputStream.flush();
ouputStream.close();
What we’re getting, though, looks like:
%PDF-1.4 %⣏ӊ3 0 obj stream x???]O㸔?ﳫ,͍?????ϞB???4″ьŪ.??i?䃍m? q@’1?HZҧ?I?dӜ????ﳙ`¬ݸ??ǡ?믦X?뽽˼?g?%1앏{/?˝_⤰?ٻ?]ٯ
[last post got cut off…sorry]
, etc.
Any ideas or suggestions would be greatly appreciated.
-eric-
Eric,
Have you checked to be sure your jasperPrint has some pages?
jasperPrint.getPages().size()
I don’t use the JRPdfExporter. After I have filled the jasperPrint (which I’m assuming you already did before the code you pasted), I then:
byte[] pdfByteArray = JasperExportManager.exportReportToPdf(jasperPrint);
Then I set the content type and length like you are. I also set the header ( I think IE needed this?):
response.setHeader(”Content-disposition”, “inline; filename=report.pdf”);
Then:
ServletOutputStream out = response.getOutputStream();
out.write(pdfByteArray, 0, pdfByteArray.length);
out.flush();
out.close()
When i create crosstab report…
The following types of error occurring:
Error filling print…
net.sf.jasperreports.engine.JRException: Crosstab data has already been processed.
at net.sf.jasperreports.crosstabs.fill.calculation.BucketingService.addData(BucketingService.java:280)
at net.sf.jasperreports.engine.fill.JRFillCrosstab$JRFillCrosstabDataset.customIncrement(JRFillCrosstab.java:634)
at net.sf.jasperreports.engine.fill.JRFillElementDataset.increment(JRFillElementDataset.java:134)
at net.sf.jasperreports.engine.fill.JRCalculator.calculateVariables(JRCalculator.java:154)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:621)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportContent(JRVerticalFiller.java:248)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:132)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:747)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:644)
at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:63)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.ja
Please tell me if:
(a)these packages were easy to setup
(b)you have used these tools from/within Cocoon
(c)you mind the odd question or two when I try and get them setup..?
Thanks