Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1498
  • Last Modified:

Creating a Table of Contents in a RDLC Report

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
Mr_Fulano
Asked:
Mr_Fulano
  • 13
  • 7
1 Solution
 
Jorge PaulinoIT Pro/DeveloperCommented:

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
 
Mr_FulanoAuthor Commented:
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
 
Mr_FulanoAuthor Commented:
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
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
Mr_FulanoAuthor Commented:
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
 
Jorge PaulinoIT Pro/DeveloperCommented:
Ok, I will try something in the weekend. I don't really know if that's easy to implement, but I will try :)
0
 
Mr_FulanoAuthor Commented:
Do you need my help...?
0
 
Mr_FulanoAuthor Commented:
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
 
Jorge PaulinoIT Pro/DeveloperCommented:
>> 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
 
Jorge PaulinoIT Pro/DeveloperCommented:
Just a qestion ... how do you define the titles/pages that will be in the TOC ?
0
 
Mr_FulanoAuthor Commented:
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
 
Mr_FulanoAuthor Commented:
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
 
Mr_FulanoAuthor Commented:
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
 
Jorge PaulinoIT Pro/DeveloperCommented:
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
 
Mr_FulanoAuthor Commented:
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
 
Mr_FulanoAuthor Commented:
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
 
Jorge PaulinoIT Pro/DeveloperCommented:
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
 
Mr_FulanoAuthor Commented:
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
 
Mr_FulanoAuthor Commented:
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
 
Jorge PaulinoIT Pro/DeveloperCommented:
I'm following there Mr Fulano
Thanks
0
 
Mr_FulanoAuthor Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 13
  • 7
Tackle projects and never again get stuck behind a technical roadblock.
Join Now