File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Jasper Reports - empty report" Watch "Jasper Reports - empty report" New topic

Jasper Reports - empty report

Melanie Jones

Joined: Dec 16, 2005
Posts: 21

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.


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

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:
subject: Jasper Reports - empty report
jQuery in Action, 3rd edition