Web Analytics
Skip to main content

Andosi - Blog

Where we discuss The Art of Great System Design

Creating Customer Invoices using Sql Server Reporting Services 2008 R2

Bryan Prince

04 February 2011

Recently I was tasked with creating a customer facing invoice using Sql Server Reporting Services 2008 R2. This particular client had employed a technique using Page Headers and Footers that didn't upgrade properly once they moved to hosting their reports in SharePoint 2010 Integrated mode.

 
Because Page Headers and Page Footers are not allowed to have references to data fields, the main issue was with how to consistently place a totals section in a fixed position at the bottom of the page without using a Page Footer.
 
Making the task even more difficult was the fact that this report should generate all customer invoices at once. Page numbering had to be based on the individual invoice, not the total pages in the "report". Although SSRS 2008 R2 has introduced a new method to reset page numbers on a group, explained by Chris Hays here, I choose to generate my page numbers in SQL rather than in SSRS.
 
Each one of these techniques deserves a deep dive, but in general this report was accomplished by:
  • Using SQL Server window aggregate functions to both limit the number of invoice lines which should be presented on each page and to serve up the page numbers to be grouped upon and used in the display. Read this for more information: Aggregate Functions
  • Using one large cell of a table containing rectangles and a nested table for the order lines.
  • Fixing the report totals section at the proper location at the bottom of the report.
My idea was that I would limit the number of invoice line items to around 10 per page with my Sql generated page numbers. The report would be grouped by invoice number and page number. I would leave enough whitespace for those 10 lines to grow into therefore the information at the bottom of the report could be fixed just like a page footer.
 
I was having a difficult time initially getting this to work properly because the "footer" was getting pushed to the second page when the number of lines would grow. After some research, I discovered that the behavior for consuming whitespace has been changed in SSRS 2008 R2. See this article for details: Behavior Changes in Sql Server Reporting Services 2008 R2
 
Here is the important part:
 

Preserving White Space in a Report Body or Rectangle Container

Extra white space is no longer removed by default. When you render a report that had extra white space on the report body when viewed on the report design surface, the trailing white space after the last report item on the page is preserved. This may result in more pages for an existing report. To remove the white space, set the report property ConsumeContainerWhitespace to true.

 
Once I changed the ConsumerContainerWhitespace property to true, the report worked as I expected.
This blog has been relocated from http://mbsguru.blogspot.com/ with authorization.

More Blog Posts


Record Lock Trace Addon for Dynamics GP

Michael Johnson
Natively, Dynamics GP doesn't always do a good job of enabling users to resolve common issues on their own.  A classic example of this is the prompt displayed when attempting to access a record that is locked by another user.  By default, as a use...

Dynamics GP Custom Links - Shipment Tracking

Michael Johnson
I was recently reminded how useful Custom Links are in Dynamics GP.  This feature is very powerful for streamlining your processes but often goes underutilized. You can access the Custom Link Setup window in the Company section of the Administrati...