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)
Crosstab Page Break Problem in Word only
Scottc
Hi,
I'm trying to design a report that contains multiple tables which can have a variable number of columns but only two rows. I'm using a crosstab for this, but I'm having trouble with the page breaks in Word. I want to set it to include the entire crosstab on one page or the other. I set the page break inside to "avoid" for both the crosstab and the row area, but in Word I can still get one crosstab split across two pages. If I generate in pdf, the page break works as expected.
I've attached a simple report I created with the sample database that shows the problem. At the bottom of page 2, there is a crosstab for Belgium that is split onto two pages. How can I make BIRT move this whole crosstab down to page 3? If possible, I would also like it to keep the label "Belgium" on the same page as the Belgium crosstab.
Find more posts tagged with
Comments
mwilliams
Scott,
This doesn't seem to work when you output directly to DOC. Not even in 3.7.0. However, if you run in the viewer and then export to Word, it doesn't split any over the page break. So, if you're using URL's to call your reports when you deploy, you can use the frameset call rather than the run call and it should work more like the viewer export. Please log a bug for this at
http://www.birt-exchange.org/org/resources/bug-reporting/
Scottc
Micheal,<br />
<br />
Thanks for the quick reply. I've added my input to an existing bug <a class='bbc_url' href='
https://bugs.eclipse.org/bugs/show_bug.cgi?id=351064'>351064</a>
; that seems to be a similar problem to what I'm seeing.<br />
<br />
The sample report does look much better when exported to Word from the Viewer, but I'm not sure how to make that work with my actual report. I'm using a Spring POJO data source, which I access in BIRT using the steps described <a class='bbc_url' href='
http://birtworld.blogspot.com/2009/11/calling-spring-objects-from-birt.html'>here</a><br
/>
<br />
What it comes down to is I have to add the following code to my EngineConfig before I start the ReportEngine.<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>ApplicationContext sprCtx = ContextAccess.getApplicationContext();
config.getAppContext().put("spring",sprCtx);</pre>
<br />
I don't see any way to put the appropriate ApplicationContext in the EngineConfig if I'm using the Viewer. Is there a way to do this?<br />
<br />
Thanks so much for your help,<br />
Scott
mwilliams
The difference between the DOC output and exporting to Word from the viewer is essentially the DOC output just uses the RunAndRender task. The viewer uses them separately. So, if you're using the RunAndRender task in your java that calls the report design, try changing it to the separate tasks and that should run it more like the viewer. Maybe that will change the output for you. The viewer simply uses the BIRT API's to render the report, so anything it can do, you can do with code!
Scottc
Well, I tried separating the RunAndRender task into separate RunTask and RenderTask, but I still got the problem. Do you have any other ideas of how the Viewer works differently, or do I need to just dive into the code and see what differences I can find?
mwilliams
We can do an easy fix for this, I think. You say you have only 2 rows in each crosstab, right? The header and the data? If this is the case or if you have a fixed number of rows, no matter what the number is, you can force a page break manually based on the number of crosstabs or rows in your report. Since you're using an embedded crosstab, you've got a table with rows, so you can page break in the table after x number of rows by going to the property editor for the table and setting the page break interval to a number of rows that will fit on a page without splitting a row. That should do it for you without having to do much of anything.
Scottc
That would probably work if I knew where in the report my outer table was going to start. Unfortunately, in my actual report, I've got a bunch of other elements of varying length before I get down to the section with the outer table and the crosstabs. Since I don't know where the outer table will start on the page, I don't know how many rows can fit on that page, so I don't know what to set the page break interval to.
mwilliams
You could possibly count the rows before this certain table starts on a page and insert a manual page break if it happens before your row limit? This would be easy if the elements above the table had a fixed line height. It gets a little more difficult if the line height is variable, but can still be done. Other than that, it's probably going to be differences in the PDF vs DOC emitters, how they handle the "Avoid" page break. You might be able to download the source code and find the two emitters and edit the DOC to handle the avoid correctly, if you'd like to try that.
Scottc
Okay, it looks like there's not going to be an easy fix for this. From what I can see, I have three options, and they all seem pretty difficult.
1) As you say above, I could try to count the number of lines before my crosstab's outer table, and set a manual page break based on this information. However, the number of lines is going to be different in every individual report, and the height of individual report elements is not at all consistent or predetermined. I could probably come up with some sort of approximation using a report variable, but this could easily result in too much unused white space at the bottom of the page upsetting users, and any changes to the report going forward could break it. I can see this being a bear to maintain, so I would like to avoid it.
2) The other option you mention above, trying to fix the DOC emitter to handle the avoid correctly. The bugzilla bug I found for this, 351064, has been around for about a month, which makes me think that this is not a simple fix. Given that I have zero familiarity with the code right now, I would prefer to avoid this as well.
3) One other option I thought of based on our discussion above is trying to modify the default Viewer to somehow take in my Spring context, maybe as a parameter or something. If this could work, it would be the best solution, because I would get the extra benefit of having the full viewer functionality.
I think I'm going to try working on 3 first, but if that doesn't work I'll give 1 or 2 a shot. I'll post back when I know more about which approach will work.
Thanks again for all your help!
Scottc
Okay, so I finally figured out how to access my Spring beans in the default Viewer. After trying for a while to build and modify the Viewer code to take in my Spring context, I finally found Jason Weathersby's post <a class='bbc_url' href='
http://birtworld.blogspot.com/2009/11/more-on-birt-and-spring.html'>here</a>
; that contained an example of exactly what I wanted to do. It's much more complicated than my previous approach, since it involves exposing each of my beans via Spring remoting and maintaining two copies of an interface and a wrapper class for each one of them, but it's the only approach that I've found that works (the first approach he mentions in the post did not work for me).<br />
<br />
That being said, I still have one more formatting issue. I no longer have individual crosstabs split across two pages, but now I have large amounts of blank space at the end of each page. Again, the problem is only when I export the report to Word, not when I send it to PDF. There appears to be plenty of room in Word for one or two more crosstabs to fit on each page. You can see an example of this in the sample report I attached above.<br />
<br />
Does anyone know how to change the size of the pages generated by the Viewer so I can fix this?<br />
<br />
Thanks!