This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Other Open Source Projects and the fly likes Jasper Reports - empty report Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Jasper Reports - empty report" Watch "Jasper Reports - empty report" New topic
Author

Jasper Reports - empty report

Melanie Jones
Greenhorn

Joined: Dec 16, 2005
Posts: 21
Hi,

I have an application that uses Jasper Reports to show contents from a table onto a PDF file. (basically a select * from some table with a where condition)

This is my problem. When the sql returns data the PDF is shows up correctly. The PDF is generated even when the database does not return any rows. A message stating "The file cannot be opened because it has no pages" is shown on the screen.

How do I avoid an empty report to be displayed. The byte array returned is not empty so the the report pops up the pdf.

Can you help me capture an empty report???

Thanks for your help!!!

Chris Jose
Chengwei Lee
Ranch Hand

Joined: Apr 02, 2004
Posts: 884
When your query yields no results, there're 3 options that are provided by JR that you could make use of:
(a) generate empty report (PDF), i.e., no pages
(b) generate a single blank page report
(c) generate a report showing all sections, except the detail section

This can be done by setting the value of the attribute [B}whenNoDataType[/B] for element jasperReport. The 3 accepted values are:
(a) NoPages
(b) BlankPage
(c) AllSectionsNoDetail

Hope this helps.

Cheers!


SCJP 1.4 * SCWCD 1.4 * SCBCD 1.3 * SCJA 1.0 * TOGAF 8
Ania Pilecka
Greenhorn

Joined: Mar 18, 2009
Posts: 1
Is it possible to make a report without connectiing to database, only to pass parameters we want use in raport?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Jasper Reports - empty report