[转]ConsumeContainerWhitespace property to remove blank space in SSRS 2008 report

转自:http://beyondrelational.com/modules/2/blogs/115/posts/11153/consumecontainerwhitespace-property-to-remove-blank-space-in-ssrs-2008-report.aspx

While at starting with SSRS, everybody face the problem of unnecessary blank pages at end. Me and my friend Chirag (Blog) had faced this problem many times and got defects from QA in past for balnk pages.

In SSRS 2005, white spaces are automatically ignored. But in 2008 this behavior gets changed and by default whitespaces are not ignored.  But, There is Report property ConsumeContainerWhitespace which is set to False by default. We can remove blank space at end by setting ConsumeContainerWhitespace to true.

The logic to prevent the unnecessary pagebreak is 
- ReportBody width should be less then Pagesize(width) – Left Margin – Right Margin
- ReportBody height should be less then Pagesize(Height) – Top Margin – Bottom Margin – Header height – Footer height

Sometimes, report is as per these conditions and still we get blank pages.

Problem -1 If we have some space at the bottom or right side after Tablix, sometimes we get blank page at the end based on rows we get from dataset. In this case, We can get rid of that blank page by removing that un-necessary space at end.

Problem-2 In case of matrix report, we can’t remove that space (otherwise page header and footer items like page numbers are not aligned properly at bottom left) and we used to get bank page. We can see this in below example (Same report is attached herewith), 

Setp-1 Dataset Query

1.USE AdventureWorksDW
2.SELECT CountryName = dg.EnglishCountryRegionName
3., SalesAmount = SUM(fs.SalesAmount)
4.FROM dbo.FactInternetSales FS
5.INNER JOIN dbo.DimGeography dg on FS.SalesTerritoryKey = dg.SalesTerritoryKey
6.GROUP BY dg.EnglishCountryRegionName
7.ORDER BY dg.EnglishCountryRegionName

Step-2  Create matrix report with CounrtyName as columnGrouping value and set the column width to 25mm

Setp-3 Set following properties. 
Report Body Height:- 7in
Report Body Width:- 6in
Header and Footer  Height:  0.7in.
All four margins are of 1 in.
Report Height:- 11in
Report  Width:- 8.5in

Setp-4 Add a page-number in footer at bottom right.

Setp-5 Run a report and export to PDF.
We will get the blank page at end.

Step-6 Set ConsumeContainerWhitespace to true in report property as shown below.

ConsumeContainerWhitespace Property

Step-7 Run Report and export to PDF

Now, There will not be blank pages at end.

References
http://msdn.microsoft.com/en-us/library/ms143200.aspx

原文地址:https://www.cnblogs.com/msdynax/p/3949634.html