Wednesday, March 28, 2012

How To Determine Total Number of Pages at Runtime?

It's no secret that the number of pages in a rendered report varies depending on the format. I have no problem getting the total number of pages for reports rendered in image formats from the web service, but I can't figure out how to get the number of pages for reports rendered in HTML.

I've always been under the impression that the Report Manager that ships with SSRS uses the same web service (reportservice.asmx) and IT can get the number of HTML pages, so it has to be possible.

Does anyone know how to do it?

Bump.|||

I now have a goofy workaround in place that I'll outline here, but I'd still like to know the "right" way to get the total number of pages from the web service.

In case someone is interested, my workaround is:

1. Add a textbox to the footer with the expression:

"***pages: " & Globals!TotalPages & "***"

2. Set the color of the textbox to match the background color (white, in this case).

3. Convert the byte array returned from the ReportingService.Render method to a string.

4. Pick out the number of pages with:

reportText.Substring(reportText.LastIndexOf("***pages: ")+10, reportText.LastIndexOf("***")-reportText.LastIndexOf("***pages: ")-10)

Like I said, goofy, but it will have to do for now.|||

If you would like to see an even goofier workaround, with somewhat more flexibility and potential, you may want to read this thread:

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1807270&SiteID=1

>L<

No comments:

Post a Comment