Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Changing masterpage when exporting from Birt Viewer
kallem
I have two master pages in the report. One is for normal use and one is for Excel. While rendering (onRender script) the report report's first element MasterPage variable is set to point to the Excel specific master page if "xls" emitter is used. This works fine when report is run from the report designer or using api. My problem is with Birt Viewer.
In the Birt Viewer report shows as it should using normal master page but when exported to Excel it doesn't obey the Excel specific master page although it is set for the first element. I have put the MasterPage variable set in the onRender script as the Birt Viewer doesn't call onCreate when exporting. Am I just missing something obvious or how can I get conditional master page work with the Birt Viewer?
Using Birt 2.6.1.
Thanks in advance,
Kalle
Find more posts tagged with
Comments
CBR
The BIRT Viewer uses a different execution model then the preview in the Report Designer.
Did you change the master page using BIRT event handler?
Which event did you choose to change the master page?
kallem
Masterpage is set in the first element's <strong class='bbc'>onRender</strong> method. Setting is conditional and based on output format. First I tried to set it in the <strong class='bbc'>onCreate</strong> but it isn't called when export is executed from Birt Viewer.
CBR
Yes that's correct. WebViewer uses the run then render execution model.
Using the export functionality of WebViewer i had similar problems in the past.
Can you try to directly generate xls in webviewer without using the export button in a already generated report? Just to see if it works.
kallem
Is there an easy way to make Viewer to regerenate the report in different format? Or does it require changing Viewer code?
CBR
Just use the same URL. In URL you should find a fragment like __format=html or __format=pdf
change the fragment to __format=xls
If the url doesn't contain such a fragment add &__format=xls at the end of your url.
kallem
At the moment of export control is in Birt Viewer and it generates the url with e.g. __format=xls. As the report has already been generated Birt Viewer seems to use it for rendering only. Is it possible to reset viewer report state somehow upon export?
kallem
I was able to make a working solution for my case. My concern was only outputted page size and by default Excel emitter sets it to size of first master page. When processing exported report page size isn't applied at all when startPage method is called. So first master page rules.
So to get Excel specific master page active I could do that simply making sure it is the first master page. Although in the end I changed emitter a bit so that it checks whether report contains master page named Excel and uses that if it exists..
Before this I tried to change emitter's startPage method so that page size would get applied. This didn't work because when the export is launched from Birt Viewer page start gets wrong page. Page set in report element's onRender script didn't go throught. I didn't bother to see this any more for now.
As I get some spare time I will see if I can get page changing work somehow. Although with Excel emitter there exists a potential problem if master page is changed multiple times during report processing.