This is a multipart message in MIME format
--Xananews.1.2.3
I was given a 'sleazy hack' to do this in RS, it requires the report to
be run twice once so it can work out the page numbers, second time it
can use them in the table of contents. If the table is going at the end
you may be able to change to a run once version! Good luck!
I never said it would be easy!
I've attached the file, and copied it below for those viewing via web.
-- ------------------------------
Unfortunately, there's currently no good way to build a table of
contents.
And even adding defined execution order isn't going to help, since
pagination happens as a completely separate step from the rest of the
report. This is because you can request the same report with different
page
size/margin settings (and even an entirely different rendering target,
which
could radically change pagination). Under normal circumstances, we don't
want to force reexecution of the entire report just because you change
your
margins.
To handle table of contents type operations, we're going to (eventually)
have to implement an entirely new mode wherein we know that the body of
the
report contains references to page numbers, which will force the entire
report to reexecute if pagination information changes.
In the mean time, there's no general solution for the table of contents
problem.
But... Since you're doing this in a batch once a month, you may not
need a
fully general solution.
Without further ado, here's Sleazy Hack #792 ("Simulating Table of
Contents
in Batch Reporting Scenarios"):
1. Write a custom assembly containing a class that can write rows to a
TableOfContents table in your database.
Have shared methods for both initializing the TOC and writing a new
row
to the TOC.
Note: Don't forget to give it database permissions in the CAS file
when
you deploy it to your server.
See the documentation for details on custom assemblies.
2. In the Code section of the report, call the TOC initialization in
the
OnInit() event.
3. At the start of each section you want to appear in your TOC, put a
hidden textbox that contains the label you want to appear in your TOC.
4. In the page header, put a hidden textbox with something like the
following expression:
=Code.MyTOCClass.AddToTOC(Globals.PageNumber,ReportItems!Textbox1.Value
& ReportItems!Textbox2.Value & ReportItems!Textbox3.Value)
Texbox1, Textbox2 and Textbox3 are the names of the hidden textboxes
from step 3 (since only one will appear on any given page, the rest
will be
empty)
5. Add a dataset to your report which selects from the TableOfContents
table
6. Display the results of the TOC data set in a table at the end of
your
report*
7. Run the report twice. The first time will initialize the TOC. The
second time will use the values from the previous run.
* If you want it at the beginning, you'll either need to run the report
three times (the first to get some rows into the TOC table, the second
to
get the numbers populated correctly and the third to use those numbers)
or
you'll need to make sure the TOC table has the right number of rows to
begin
with (perhaps by not emptying it from the previous month) otherwise your
page numbers will be incorrect due to the TOC pushing things around.
This
isn't an issue if your TOC is only one page long and has PageBreakAtEnd,
however.
-- ----------------------------------------
[quoted text, click to view] Brian Bischof wrote:
> Crystal Reports can do it, but it has to put it at the last page (it
> generates the page numbers as it goes and accumulates them for
> display when finished printing the records). Not an ideal solution
> for a TOC.
>
>
> Brian Bischof
>
www.CrystalReportsBook.com >
>
>
> "Tobby Lee via SQLMonster.com" <forum@SQLMonster.com> wrote in message
> news:7601e8aa56a14beba11468cd61e2ac41@SQLMonster.com...
> > Thanks for your response Jeff. Do you know if Crystal Reports or
> > any other reporting solution can handle the task of creating a
> > Table of Contents and document Index?
> >
> > --
> > Message posted via
http://www.sqlmonster.com --Xananews.1.2.3
Content-Type: Application/Octet-Stream; name=Sleazy Hack #792.txt
Content-Transfer-Encoding: base64
VW5mb3J0dW5hdGVseSwgdGhlcmUncyBjdXJyZW50bHkgbm8gZ29vZCB3YXkgdG8gYnVpbGQgYSB0
YWJsZSBvZiBjb250ZW50cy4NCg0KQW5kIGV2ZW4gYWRkaW5nIGRlZmluZWQgZXhlY3V0aW9uIG9y
ZGVyIGlzbid0IGdvaW5nIHRvIGhlbHAsIHNpbmNlDQpwYWdpbmF0aW9uIGhhcHBlbnMgYXMgYSBj
b21wbGV0ZWx5IHNlcGFyYXRlIHN0ZXAgZnJvbSB0aGUgcmVzdCBvZiB0aGUNCnJlcG9ydC4gIFRo
aXMgaXMgYmVjYXVzZSB5b3UgY2FuIHJlcXVlc3QgdGhlIHNhbWUgcmVwb3J0IHdpdGggZGlmZmVy
ZW50IHBhZ2UNCnNpemUvbWFyZ2luIHNldHRpbmdzIChhbmQgZXZlbiBhbiBlbnRpcmVseSBkaWZm
ZXJlbnQgcmVuZGVyaW5nIHRhcmdldCwgd2hpY2gNCmNvdWxkIHJhZGljYWxseSBjaGFuZ2UgcGFn
aW5hdGlvbikuIFVuZGVyIG5vcm1hbCBjaXJjdW1zdGFuY2VzLCB3ZSBkb24ndA0Kd2FudCB0byBm
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