Wednesday 6 April 2016

Learn how to create Report books in Jasper Studio 6.2 Pro or later - Step by Step procedure for Table of content example in 6.2 Pro Studio

Hi,


This post will teach you how to work with TOC report using Report books and best practices in Jasper Design Studio 6.2 Professional or later.

1) Report books is a new feature for TOC implementation in Japser Reports from 6.0 version.
2) Its always a best practice to write Report book JRXMLs in a separate project.
3) Saving report book doesn't support saving it in a folder in project.
4) All you need to know how to map exact data sources in Main Report book and content JRXML.
5) In addition to point-1 , need to know how to pass parameters correctly.
6) Understanding how book marks works on Text elements is required to work with Report books.

Questions : 
1) What is the difference between sub reports & Report books ?
2) What is the difference between drill down reports/ hyperlinks and book marks ?
3) Is it possible to get the TOC in word export as you see in PDF ? If yes, how ?

Report Books :
Jaspersoft Official documentation page : 
http://community.jaspersoft.com/documentation/tibco-jaspersoft-studio-user-guide/v60/report-books



Here you go with an example,

USE CASE :
Display State Table of contents for Customer Details Tabular Report 


1) Creating Project 
a) Click File->New -> Project -> JasperReprots Project -> Give name to the project (Lets say "ReportBooks_TOC_Example"

2) Creating Report Book
a)  Click on File->New -> JasperReport -> Report Books -> Select "Abstract Book" as shown in below image.

 3) Choosing Data source for Report book and writing Query. 


As shown in below images select foodmart data source and then write a sample query . Click on Next to get Report Book parts selection.



Report books contains 3 sections
They are
1) Front cover
2) Content
3) Back Cover
Select all of them and click on "Finish" button.

4) Observations
a) Generated JRXMLs in Project folder
b) Canvas of Report Book

a) Generated JRXML's in Project folder
Once you click on Finish button, the studio engine will generate below JRXMLs in project folder.
Abstract_Book.jrxml
Abstract_Book_backcover.jrxml
Abstract_Book_cover.jrxml
Abstract_Book_toc.jrxml


b) Canvas of Report Book - Canvas of report book looks as below. 


5) Lets have a quick look into the report book output and observe few more things. 
a) Click on Preview button (It will generate .jasper files for .jrxml files - you can do it by compiling too).
b) The default Preview should generate 3 tabs as shown in below image.
c) When you click on "TocReport" tab you will not find any thing, you need to change/remove the default styles on all the text fields. 


In the TOC JRXML make sure the content is dis-styled to get the labels view-able
  Understanding TOC JRXML
1) It is not required to connect to any data source in this JRXML
2) Don't change any field lables in it. The lables are pre-built for generating TOC.
3) You can change the styles for the lables.
4) You can not keep two labels in single Detail band.


6) Lets understand few more things in ReportBook JRXML

a) Report book out line is divided into 3 parats,
b) In each part, you will either keep .jasper or .jrxml files.
c) This outline section has the other general reporting elements as shown in below image.
d) Properties of the Report book is same as general report.
c) Each Report book part has its own properties as shown in below.

Cover page part properties.  - Notice that the evaluation time for this part is "Default"
Similarly the back cover has "Default" evaluation time as shown in below image. 

Toc Page part Properties - IMP : The evaluation time for TOC page is "Report"
 
7) Now create a content JRXML in the same project folder ( Tabular Report with State wise grouped example for content). 
Lets say the report name is : ContentReport.jrxml
Data source connection & Query :



Report Sample output(making sure that report working fine individually)


8) Giving Book Marks to the "state_province" text field to get the states in TOC jrxml 

a) Select the "$F{state_province}" text field and in its hyperlink give
Anchor Name Expression = $F{state_province}
Bookmark level=1 
(NOTE : By default TOC jrxml has 3 levels in which 1st level will be given to "$F{state_province}" text field. )



9) Now , Add this ContentReport.jrxml  to the ReportBook.jrxml

a) Right click on the content canvas  and then click on "Add book part"

b)  Select the ContentReport.jasper or ContentReport.jrxml and Report Connection as shown in below


Observation : Make sure that "Connection Expression" is set 

10) Save the report, Compile and Run. 

Sample output : (Shown TOC part) - Download the PDF output to view the TOC functionality. 

 Navigation output sample to Mexico grouped data or to 262nd page.

This way you can work with TOC -Report books in Jasper Design Studio.

Publishing TOC Report to Jasper Server and viewing the output
a) Click on Publish button and choose the folder of your choice 

 b) Observe the JRXMLs as resources to the Main Report book JRXML(not visible)
 c) Configure the data source.
 d) Successful of resources.
  
e) Viewing output in Jasper server

Observe the book mark popup and tabs for Report book sections. 

TOCReport Sample

 Performing click Action on "OR" state to drill down to the OR state grouped by data.



Download : All the examples works only on Professional or Enterprise Jasper 6.2
1) Studio Example Project Zip File
2) PDF Export output file
3) Jasper Server Export output.

Click Me to download 

Or Direct Link :
https://drive.google.com/folderview?id=0BymV_QP4TGBEUUVaaW1hM08xOE0&usp=sharing

I hope this helps someone getting started with it.

If you find it useful, please click on share button and help the community.

Thank you for visiting this page.

With Best Regards,
Sadakar Pochampalli 

1 comment:

  1. Thanks for the great post with informative information. This Blog contain “JasperSoft tutorial and tips tricks, use case etc.” but I found one good and effective E-learning website related to JasperSoft, and they provided interview Q/A’s as well. Just have a look: https://goo.gl/RfE3DK

    ReplyDelete