Monday, March 12, 2012

How DO I Generate a Table Of Contents For a Report?

Hi!!!

Can anybody help me with the generation of Table of Contents for a report using SQL Server 2005 Reporting Services. Let me ellaborate. The scenerio is...i m having a report of lets say 500 pages grouped on employees, showing the performance of each employee between specific date range. Now if the manager prints the report of 500 pages he will be more intersted to jump directly to a perticular employee's page which means my printed report had to have a Table of Contents on my grouped criteria (which in this case is employee number). I would really appriciate if someone can suggest me a solution for this.

Any reason why all 500 pages have to be printed? If your manager can agree to viewing the information on line, your best option would be to use a document map. Not sure if you can print the information used to build the document map but I'm guessing your table of contents would at least begin with a document map. BTW, document map properties are an attribute of a group.|||Yes actually i had that option of Document Map in mind but the thing is, there are scenerios where lenghty reports are printed and taken to meetings with every person having its own copy of report and they have to discuss those reports along with directly taking notes/comments on the printed report for future reference. So its a sort of compulsion to have TOC with page number reference for printed reports so that they can quickly jump to any specific page for discussion. I appriciate your reply but do you have any ideas to get it done by any means may be through coding or any other way?|||

Anybody? Its really urgent.

Thanx.

|||There should be some simple work around for this thing if it does not have a built-in support for it? any ideas guys?|||

I have been working on this table of content thing for a week now. I have somehow found a solution for that. You can write an assembly containing a function which would take 2 paramenters the page number and your group name (Which needs to be on the table of contents) and write them to an xml file or a database table. Once you are done with the assembly you can reference that assembly in you rdl file and pass that the page number and the current group on the page to that function. You will have a complete table of contents in form of an xml or database table whatever you select. If you have any questions i can explain them in more details

I have done this so far and now only thing left is to display that TOC on the original report again. I m wroking on it... so far this is what i tried... i added my TOC data set to a new report and made my original report a sub report in that report. Now there are 2 issues. (1) The sub report wont show the page numbers. (2) I will have to run the subreport once before the main report so that it writes the TOC values to the xml file or table which can be accessed then in the main report. I think it can be done on windows form or a web form to call that subreport as an independent report somehow hidden from user, but i would be more interested to do all this stuff from the report if possible.

Thanx!

|||I started down this path, and found quite quickly that I cannot reference Globals.PageNumber() within the body...therefore, I cannot tell a function that "Strategy A is on page 5", etc... How did you solve this problem?

Thx,
Mojo

|||

I too would like to know if there is an easy way to add Table of Content.

The work around I use is, Right click on any groups / details area --> Nevigation tab --> Document map..Using drop down, choose the data element file that you wish to include in Table of Content.

The document map builds a nevigation menu on the left side pane of the report window.

|||

Its been a while since i did that, but lets try this,

Write your custom assembly with following code ..

using System;

using System.Collections.Generic;

using System.Text;

namespace ReportsCustomAssembly

{

public class CustomCode

{

public static int CurrPageNum;

public static int SavePage(int CurrPage )

{

CurrPageNum=CurrPage;

return CurrPageNum;

}

}

}

Build your assembly and add reference it in the report. Now in the page header add a text box and wirte expression =ReportsCustomAssembly.CustomCode.SavePage(Globals!PageNumber)

Now you have your page number stored in the static varible "CurrPageNum" defined in your custom assembly. You can reuse it in body or anywhere else in the report.

=ReportsCustomAssembly.CustomCode.CurrPageNum

I hope it should work, i remember vaugely this is somewhat i did, but lemme know if you face any problems i can go back and recheck how exactly i did that.

|||

I am afraid my friend, I haven't been able to find any solution at all which is straight forward. I expected it to be a straight forward thing too but didnt work that way.

I would highly recommend if the document map can be used as an alternative to the TOC in your case, you should use it, because it is much easier to use, provides you with interactive hyper links on the report and most of all if you export it to PDF or Excel it creates the the bookmarks equvilant to the document map you have on the report.

However in my specific scenerio i needed a TOC because my business requirement was to print out big reports starting with TOC right at the top.

No comments:

Post a Comment