How to create a header file to use on reports and be able to update the header file that will cascade down and update the reports?

I would like to create a header file that can be used on several reports in Jasper that are loaded on the JasperServer.  In turn I would like to update this header file in one location which inturn will update all the reports in Jasper without having to manually go into each report to update it.

 

jndh90's picture
13
Joined: Feb 27 2013 - 10:31am
Last seen: 5 years 3 months ago

4 Answers:

Here are things I have tried: create a header file and load it to the repository as a jrxml file.  On my report reference the jrxml file as a subreport in the subreport expression.

Create a header file and load it to the repository as a report.  On my report reference the report as a subreport in the subreport expression.  I get net.sf.jasperreports.engine.JRException: Error opening input stream from URL in both cases.

Must the header file to referenced within the report and loaded to the resource folder or can the header file be referenced outside the report but still in the same location on the repository as where the report resides?  Most information I have found says it must be loaded as a resouce under the report.  I would like to use this header file on several reports and be able to update the header file once and the reports using this file will also get updated.  If I have to load the header file as a resource under each report then this defeats the purpose of updating the file in one location.

jndh90's picture
13
Joined: Feb 27 2013 - 10:31am
Last seen: 5 years 3 months ago

Use the full path to refer to header report. It works well, I have tested.

example code

In main report, put a subreport refer to Header report.


        
            
                
                
                
            

        

    

Hope this help.

ozone0644_1's picture
Joined: May 14 2013 - 9:14pm
Last seen: 1 month 2 days ago
Attachments: 
AttachmentSize
Binary Data bodyreport.jrxml2.37 KB
ozone0644's picture
Joined: Apr 24 2008 - 2:02pm
Last seen: 6 years 11 months ago

Thanks for the response. Not quite following however. Where do I put the full path. I have the ltr_hdr.jrxml loaded to the repository. I've added a subreport to my letter and in the subreport expression put "repo:ltr_hdr.jrxml". I upload the letter to the repository but it won't load the subreport in to the resources folder. Should it load it there? I've tried running the report on the server but I get the same error I've been getting: Error opening input stream for URL: repo:ltr_hdr.jrxml.

jndh90 - 9 years 1 week ago

For any that are wanting a solution, this is what I ended up doing.  I created the header file first and saved it on my local machine.  I also loaded the file as a jrxml file to the repository.  On my report I add the header file as a subreport.  Load the report to the repository and it creates a resource with the subreport.  Then I log into Jasper server, search for the report in the repository, right click and edit.  I go to control & resources, click on the name of the subreport, this brings me to another page where I can select a file from the repository.  I search in the repository for the .jrxml file that I had loaded, save and submit.  This replaces the subreport in the resources under the report to the file that is stored directly on the repository and creates a linked file.  If I go back into iReports and look at the subreport under the reports resource folder there is an icon with a chain link next to the name of the subreport.  Now when I make a change to the file, it will update in my report.

jndh90's picture
13
Joined: Feb 27 2013 - 10:31am
Last seen: 5 years 3 months ago
Feedback