2004 IR Help Posted August 21, 2006 Share Posted August 21, 2006 By: jman - hestonfernandes Newbie Question 2005-05-04 14:37 Hi, I've just started using Jasper Reports and have so far managed to compile and generate a few reports. I am able to get the number of records from within the report using the pre-defined variable. I would like to export the report to PDF only if it contains records. How do I get the number of records from outside the report (the method that compiles and fills the jasper report) ? Thanks By: alanHardwick - alan314 RE: Newbie Question 2005-05-04 23:52 Do you have a java Data Source Class file?... If so then 1 method is to include a public instance variable (say noRecs) and increment it in the next() method (if hasNext() condition is true)... and in your code... MyDS myDS = new MyDS(.....); JasperPrint jPrint = fillReport bit...... if (myDS.noRecs > 0) do your PDF export bit Should work!! Prob other ways too but this works for me.! Al By: jman - hestonfernandes RE: Newbie Question 2005-05-05 06:16 I'm using an SQL query in the jrxml file and not a custom datasource. Is there some method I can use after the fillReport bit to check if fillReport actually put in some records? By: Teodor Danciu - teodord RE: Newbie Question 2005-05-05 06:21 Hi, A solution would be to use whenNoDataType="NoPages" for your report and after you filll it, you test the resulting JasperPrint object to see if it has pages or not. If it does not have pages, then there was no record returned by the query. I hope this helps. Teodor By: jman - hestonfernandes RE: Newbie Question 2005-05-05 11:05 Perfect. Worked for me. Thanks a bunch Teodor By: jorasmi - j_gagarin RE: Newbie Question 2005-05-09 17:37 Hi jman, I'm just taking a plunge in using Jasper Reports. It seems that I dont have that luck. Can you please tell me how you did it. I'm using eclipse as my ide. When trying to compile the program, I always get errors. I would greatly appreciate if you can post a sample project. Please help. Thnaks in advance jman. :) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now