Home
Analytics
Need advice/guidance on building a generated table of content(TOC)
Lydia Ng
I'm currently doing a task on building a table of content(TOC) for the Report Generated. The data source is recorded in a temporary xml file.
The report template is done by using Eclipse Birt 2.5, it contains a lot of different kind of reports, thus it is done by using the report template library. Where it has a main Report, and it calls each different report from the report library template when needed.
However, when the report is generated, it does not have a Table Of Content to refer.
I'm a beginner in birt, since i only learnt how to use it last month. Can please give me a guide, on how to do the TOC, with the page number? Such that the TOC is generated separately from the generated report.
meaning that, when d report(Word Document-report) is generated, there'll be another file(word document-TOC) generated separately.
From what i know, BIRT currently still don't have this function yet. Am I right~?
Find more posts tagged with
Comments
mwilliams
One thing you could do would be to duplicate your first report, hide all of the elements, grab their the pageNumber variable for each and store it in a persistentGlobalVariable and recall them in a TOC that you've built at the end. That should do it. You definitely don't want them both in the same report? Why is this, if you don't mind me asking?
Lydia Ng
Thanks for the advice Guru, actually, it's not necessary to put them in different report. It's just an idea of doing it. Because, if we place the TOC together with the report in a particular file, we need to build it at the end. It would be nice if can generate report, then toc in separate doc. then combined the 2 files with toc as first file.
Anyway, it's ok also to build the TOC at the end.
My doubt now is How can we group the labels with the page numbers, as the reports are called dynamically by birt.
I've read one of the previous forum
http://www.birt-exchange.org/org/forum/index.php/topic/20685-generating-toc-in-word-doc/
, in that case, I think it's similar to mine, but, not the same, as the report I have is done by calling the report library template.
So, the method to do the TOC might be different~ Am I right~?
mwilliams
I don't know if there's a way to get the page numbers when you do the TOC in the front of the report. I'm sure there is an enhancement request out there already for this. Either doing it at the end or creating a second report with the TOC and joining the two files is probably going to be the way to do it. As far as your question about lining up the labels with the pageNumbers, I'm not sure I'm getting what you mean. Can you explain this a bit further?
Lydia Ng
Guru,
what I mean is something like this:-)
For example,
I have a report, named: annual_report.rptdesign,
with report library template: activity.rptlibrary, finance.rptlibrary, risk.rptlibrary etc.
When there're record for activity, finance, risk, each section will be displayed(set to be visible).
However, the header for activity, finance, risk are using Labels(not inside the dataset).
Then, my task is to do the TOC like below.
/**********************************************
Table Of Content for Annual Report
No.--Title
Page Number.
1. Activity
2
2. Finance
15
3. Risk
22
**********************************************/
My doubt is... How birt going to recognise/call out the header(activity, finance, risk) of the report and link it to the page number to be displayed in the table of content?
Is it possible to do like that~?
Should I do the TOC inside the library Template as well~?
^_^
mwilliams
If you just want a link to the label, you can use a bookmark on the labels you're using and use an "internal bookmark" hyperlink from the TOC you create to link to the label you have right above the table.
Lydia Ng
Hello Guru, in my task, the link to the label is not so important. The priority here is to build a TOC consisting the header/label/topic, and page number.
mwilliams
If you grab the page number in the script of each header/label/topic element and store it in a variable to recall at the end of the report, you should be able to have a TOC that you've made recall these values, regardless of what rptlibrary the items come from. If you know what's in your report and know what order you designed them in, you can set up the TOC at the end and put the page numbers associated with each element by recalling the variables you assigned.
Hopefully I'm answering your question better now. I think I had confused myself with the link thing before.
Lydia Ng
Hello Guru,
I think u had answered my question. I'll try it out first. If there're still any doubt, or any technical thing that i don't know how to do, I'll post it here again~
^_^ really thanks a lot for the guide. ^_^
Thanks a lot~
regards,
Lydia
mwilliams
Not a problem. Let me know if you have any other issues.
Lydia Ng
Hello Guru,
I wanted to ask, to grab the page number in the script of each header/label/topic element and store it in a variable to recall at the end of the report, is it grab it by using a GPV function?
How should i use it?
I've been trying, but, still don't have any clue...>_<"
regards,
Lydia
^_^
mwilliams
Lydia,
You could do it with persistentGlobalVariables or with a regular variable like in the attached report. Either way should be ok.
Lydia Ng
Hello Guru,
I've seen through your example.
May I know where is the reference of pageNumber under the onCreate? What i mean is, where do this pageNumber retrieve its number?
After I tried the example by applying the concept into my example, I can't really retrieve the correct page number under my report.
The way i did is by declaring under OnCreate at the header:
reportContext.setPersistentGlobalVariable("HeaderOne", "Header 1");
dataset1=pageNumber;
then, at the layout, i put inside a grid:
reportContext.getPersistentGlobalVariable("HeaderOne"); | dataset1
Can we do the page number by using declare count under initialize, then, count++ under onPageStart? the count is to count the page, when the page is generated...
However, this is only my rough idea, I don't really know how to link the count with my header/topic/label. Can you give me a guide here?
Initially, I'm using the GPV to retrieve(set, get) my label/header/topic at the end of my report.
Hope that u have a nice day~ ^_^
Regards,
Lydia
mwilliams
pageNumber is a variable used by BIRT to determine the pages. It is incremented when the onPageBreak event happens, so using your own variable and incrementing it is fine, but would just be a duplicate of this one. You can use persistentGlobalVariables or a standard variable initialized in your initialize script. Whatever works best. Let me know if I'm not answering your questions.
Lydia Ng
Hello Guru, ^_^
I've tried out the methods that is in your testReport, instead of using the increment one(coz it's confusing >_<"). Really thanks a lot~ ^_^ The page number can be shown out already.
However, there're a problem that I face now...>_<"
I put my dataset into a table. Once the table's record is too long that it will exceed one page, (if i set the page break interval to 30 - under page break tab) then, the page number retrieved in the end will be the wrong one.
If the table's record fits one page for every table, then the page number retrieved in the end will be the correct one.(where i set the page break interval to 10 - under page break tab)
Is there any way to fix this~?
This is because, if i set the page break interval limited to small amount of number, it will be a waste of paper when I want to print out the report.
regards,
Lydia~
mwilliams
Lydia,
Unfortunately, this is an issue currently. If the page breaks when the page break is not forced, the pagebreak methods don't get called correctly. I believe there is an improvement on this in 2.6.2, which will be released soon, I think.
Lydia Ng
Hello Guru,
I see... Anyway, the method u guided me really helps me a lot in learning BIRT.
thanks a lot for it.
Can I ask, is there anyway to do the page break by calling of some function? What I mean is, is it possible to write a script to check, if the table's length exceed the page size, then, it force will page break. Can this be done~?
Have a nice day~
regards,
Lydia
mwilliams
Lydia,
I don't know if there is any EXACT way of doing this, but you could potentially write a script that checks the length of the data in each row and tracks how many lines each row will take up. If you know how many lines that will fit on a page, you could then keep track of the lines so far per page and if the current row will take up too many lines, you could set the pageBreakBefore to "always" for that row to force a page break. Just an idea that may work for you.
Lydia Ng
Hello Guru,
Can give me an example, or some guide on the script to do that?
Firstly, I'd like to check whether the table's record exceeds 49 lines in a particular page. Next, when the line exceeds 49 lines, it will force the page to page break.
I'm sorry, as i'm not so good in scripting, and I've browse through some forum, and try to learn the scripting thing, but, I'm still kind of blurr...
So I need some guide on the scripting~
Hope that you can give me a clue, or sample on how to do it.
Have a nice day~
And thank you a lot for guiding me.
Regards,
Lydia
mwilliams
I can try to work on something to show kinda how to go about it. 2.6.2 was released if you can upgrade. It may solve your issues.
Lydia Ng
Hello Guru,
Actually, if I'd change to version 2.6, It needs to take time to do some research on the functions. This is because, we need to consider the compatibility of the reports to the new version.
Thus, I prefer to do research on the TOC in version 2.5.
Hope that u can guide me on some of the scripting thing. As, I'm not so good in here, and I can't really find any similar scripting on the :
1. Row counting and checking inside the table.
2. Force page break when the row limit is reached.
Hope that u can help me on this~
Wish that u have a nice day
Regards,
Lydia
mwilliams
Which release of version 2.5 are you using? 0, 1, or 2? I'll try to make something up in your exact version. Let me know.
Lydia Ng
Hello Guru,
The version that I'm using currently is 2.5.1.
regards,
Lydia
mwilliams
Lydia,
Take a look at the attached example. It shows a table that is manually page breaked based on a calculated line count and a TOC and a table without the manual page breaking and its TOC.
Hope this helps.
Lydia Ng
Hello guru,
Thanks a lot for the example u given to me... it does work.
I'm trying to do it based on my own example, however, I face some problem here, that i need your guide.
Can i know where do u get the "reportContext.getPersistentGlobalVariable("Classic Cars2")"?
how to retrieve the page number by using this?
do you declare/initialize it somewhere at the script? or i over looked it? :wacko:
as, i try to find inside scripting, i can't find any variable on Classic Cars2.
or Classic Cars1 and others.
Regards,
Lydia
mwilliams
Those are persistent global veriables I created in the group header script of each table. Sorry, I should have explained more. If you go to the outline of the report and scroll to the bottom, you can see everywhere where there is script. Let me know if you have any other questions.
Lydia Ng
Hello Guru,
Thanks for the information. I'll explore more first, if there are some more doubts, I'll post here again~ ^_^
Thanks a lot~
Have a nice day.
Regards,
Lydia
mwilliams
Sounds good! Good luck!