Solved

Creating a Table of Contents in a RDLC Report

Posted on 2009-07-12
21
1,336 Views
Last Modified: 2012-05-07
Hi, I'm using VB 2005, WinForms. I have a "Master Report" with multiple SubReports within it. I would like to create a  Table of Contents for my Master Report outlining each of my SubReports.  I'd also like for the Table of Contents to show page numbers of where each SubReport begins.

Is there a way to do that with a .rdlc report?

UPDATE (07/13/09): I was able to figure out that you can set up a series of Textboxes at the top of the report that act somewhat like a Table of Contents. You can show or hide them programmatically depending on whether the Subreports or sections are included or not.

What I need now is to figure out a way to *count* the pages of the PDF report once it's created. -- However, I don't think that can be done...

Thanks for your assistance,
Fulano
0
Comment
Question by:Mr_Fulano
  • 13
  • 7
21 Comments
 
LVL 48

Expert Comment

by:jpaulino
ID: 24878853

What I need now is to figure out a way to *count* the pages of the PDF report once it's created. -- However, I don't think that can be done...
The number of pages(total pages) of the report ?
0
 

Author Comment

by:Mr_Fulano
ID: 24883504
Hi JPaulino, thank for answering this - I was hoping you would : )

Yes...what I need is the total in the Master Report AND the number of pages for each SubReport. If I can do that, I can create somewhat of a Table of Contents.

If you know your report is 30 pages long and SubReport1 is 12 pages and SubReport2 is 18 pages, then you know that there are no blank pages. You also know that in the Table of Contents, the page location for Subreport1 is page (30 - (12+18)) and the page location of SubReport2 is page (30-18). Its not an absolutely perfect approach, but its a start and its better than nothing.

Hey, one more (unrelated) thing...take a look at this post. If you're going to write a new article on ReportViewer, you need to read this.

This is a thread on MSDN on a memory leak in ReportViewer:
http://social.msdn.microsoft.com/Forums/en-US/vsreportcontrols/thread/d21f8b56-3123-4aff-bf84-9cce727bc2ce

If you can help me work out a fix for a Table of Contents, maybe you could include that in your new article.

I've also learned a couple of interesting things about ReportViewer, but lets take one step at a time.

Thanks,
Fulano
0
 

Author Comment

by:Mr_Fulano
ID: 24883565
Here is an updated version of my formula. The on above is not correct:

 ((30 - (12+18))+1) and the page location of SubReport2 is page ((30-18)+1)

I'm working out a formula, I'll post it later if I get it right.

The key to this is being able to get a page count for each SubReport and the Master Report in total.

Thanks,
Fulano
0
 

Author Comment

by:Mr_Fulano
ID: 24883732
Hi JPaulino, here is the formula I would use:

-- MR = The total pages in the Master Report.
-- SR_n = The summation of pages for each SubReport in question *PLUS* all other SubReports *AFTER* the SubReport in question.
-- x = (This is your unknown) -- The starting page of the SubReport in question.

So my formula is:      x = (MR-(SR_n))+1  >> where the sum or all SRs = MR

OK, so lets test my formula:

If  we have a MR = 70 pages and it contains 4 SubReports with individual page counts of (12, 18, 15 and 25).  We know that (12, 18, 15 and 25) = 70, so we have no blank pages.

So, our Table of Contents would be:

SubReport 1................................x = (MR-(12+18+15+25))+1
SubReport 2................................x = (MR-(18+15+25))+1
SubReport 3................................x = (MR-(15+25))+1
SubReport 4................................x = (MR-(25))+1

The only glitch in the formula would be blank pages. If we get those, I don't know how to handle those yet...


0
 
LVL 48

Expert Comment

by:jpaulino
ID: 24885020
Ok, I will try something in the weekend. I don't really know if that's easy to implement, but I will try :)
0
 

Author Comment

by:Mr_Fulano
ID: 24888672
Do you need my help...?
0
 

Author Comment

by:Mr_Fulano
ID: 24888730
Here's a little bit of help based on some research I've done. The code below will give you the total number of pages in the report. However, it will not do that until the report is rendered, so you have to place this in the "Shown" event of the Form.

If we could do that for SubReports as well, and also render the Table of Contents last perhaps, that might work.

The two problems then would be, how do we get the T_of_C to the front of the document and most importantly, how do we pass the page values to the T_of_C.

ReportViewer1.LocalReport.GetTotalPages()

Thanks,
Fulano
0
 
LVL 48

Expert Comment

by:jpaulino
ID: 24888740
>> Do you need my help...? Just time to try it. I have started already with something but it's not really easy ... I let you know if I got something.
0
 
LVL 48

Expert Comment

by:jpaulino
ID: 24888819
Just a qestion ... how do you define the titles/pages that will be in the TOC ?
0
 

Author Comment

by:Mr_Fulano
ID: 24890299
Hi JPaulino, I assume that by "define" you mean how do I pass the Reports Title to the Table of Contents when you ask:

>>how do you define the titles/pages that will be in the TOC ?<<

I would assume that you could set a textbox called: tbxReportTitle1 and grab its text from that. In the Table of Contents you could say something like:


tbxReportTitle1.Text................................x = (MR-(12+18+15+25))+1
tbxReportTitle2.Text................................x = (MR-(18+15+25))+1
tbxReportTitle3.Text................................x = (MR-(15+25))+1
tbxReportTitle4.Text................................x = (MR-(25))+1


Not sure if that would work, but it is a good question!

We can always let the user define his/her own Title manually.

Thanks for the help,
Fulano
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:Mr_Fulano
ID: 24890750
Hi JPaulino, giving this some more thought... since you really don't know the  actual page numbers until the Master Report is rendered, you could always render the Table of Contents as a second report. -- So, you would first render the Master Report, gather its page numbers as parameters and then you would render the TofC and pass the parameters to it.

I know that we could do it in a regular Form, but that's a lot of wishful thinking when it comes to ReportViewer.

Please let me know if I can help in any other way...

Also, this would be a great article for you, if we get this accomplished...based on the research I've done on this subject, no one has done this and posted it to a web site - you would be a pioneer in the field of "Table of Content-ology!"  : )

Thanks for the help,
Fulano
 
0
 

Author Comment

by:Mr_Fulano
ID: 24922520
Hi JPaulino,

I know you're working on a solution to this problem, but I wanted to throw out another suggestion as food for thought....

I've designed a section on my report Form that will allow my users to create a dynamic table of contents within the Form itself, so they can know what the report will contain before they render it.  If I could set up some textboxes on my Master Report - just ahead of each section and then find their location, somewhat like a "Carrot" we might be able to find the page number of where the sections begin.

Maybe you can offer your thoughts when you get a chance...

Thanks,
Fulano
0
 
LVL 48

Expert Comment

by:jpaulino
ID: 24946411
The only way I see that this can work fine is to render the report to a pdf file and extract the correct pages / titles.
I'm trying to do something for that ... but time is short.
I will try to make some more processes this week.
0
 

Author Comment

by:Mr_Fulano
ID: 24947966
Hi JPaulino,

First and foremost, thank you for trying. I know this is really difficult and if it too much of a challenge, then perhaps we can let it go. I don't want to burden you too much with this since I know you're busy. However, if you think you can do it, that would be great. We'd both be winners here, because I would get my solution and you would have something "never before done" to post as an article.

If you share some of the code with me, I'll try and help.

Thanks,
Fulano
0
 

Author Comment

by:Mr_Fulano
ID: 25218530
Hi JPaulino, I've been doing A LOT of research into this matter (way too much)  and you're right, this is not a trivial thing. In summary, the problem is that the pagination in ReportViewer is calculated at the end of the report rendering cycle and RV cannot go back into the report's body to supply the report with page numbers.

However, there's some good news. I posted some comments on the Blog below, which belongs to Lisa Slater Nicholls, who is EXTREEMLY talented in this area. She is helping me develop a TOC that can be used with ReportViewer. She has a version for Server side reports, but now she's working on one for Local reports.

You might want to visit her site below and add a comment to her blog if you're interested in sharing your thoughts or you're interested in expressing your interest in this matter.

http://spacefold.com/lisa/category/Reporting.aspx

I think I'm going to leave this post open until she completes her work and then I'll post the solution here in case others have the same question.

Oh, I hear that ReportViewer  in VB2010 will be far improved, but I think those of us using VB 2005 or VB 2008 will be completely out of luck...we'll have to upgrade to 2010.

Thanks,
Fulano
0
 
LVL 48

Expert Comment

by:jpaulino
ID: 25268183
Hi Fulano,
I have also made a few test and it's not easy to implement that. I have not tried yet the ReportViewer in VB 2010, but I have already installed. I have to check the new features.
I will check the link and maybe you can have some help from Lisa. :)
0
 

Author Comment

by:Mr_Fulano
ID: 25268857
Hi JPaulino, good to hear from you. -- Based on my research, the ReportViewer in VB2010 is not new. Its the same old reader that came in 2005 and 2008. They will not be including the new ReportViewer until they issue SP2. That's when they plan to roll out a much more improved version, but from what I hear, it will only have improvements for Server side reporting not local reporting. So, we're still back to square one if that is really the case.

I'd be interested in hearing what your opinion is on the RV in your version of 2010.

Oh, BTW, you'll get the points for this question, I thought it be best to keep it open until we can conclusively say we can or cannot produce a TOC, which as of now is still up in the air.

Fulano
0
 

Author Comment

by:Mr_Fulano
ID: 25376153
OK JPaulino, here is the long awaited solution:

Lisa found a solution, and I'm still working through it, but I know you were interested too and wanted to share. Let me know what you think.

http://spacefold.com/lisa/category/Reporting.aspx

Fulano
0
 
LVL 48

Accepted Solution

by:
jpaulino earned 500 total points
ID: 25439229
I'm following there Mr Fulano
Thanks
0
 

Author Comment

by:Mr_Fulano
ID: 25444475
I think we can begin a new question if we need. I just wanted to give you a chance to review Lisa's work.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now