Thursday 11 December 2014


Using Template reports for faster RDLC report writing

When designing RDLC reports it is an advantage to have all the report controls which you often use close at hand. As many you know I give out my template reports when you attend one of my many RDLC Reporting Training classes, but after multiple requests I now also place these Template Reports on my public SkyDrive. If you want to use or modify them it is of course up to you, but these template reports increases my speed when I create RDLC reports, so maybe they can also help you become faster when designing RDLC reports.
Here is an image of my Portrait Letter template report for NAV 2013 R2:
image
Every time I design a new report I will get this report shown to me. To accomplish this I replaced the existing report.rdlc file found in the ReportLayout folder in the RTC folder.
As you see I have quite a few elements on this report. Notice that all elements are using the rules outlined in the Report UX Guidelines released by Microsoft now almost 2 years ago. A bunch of standard reports in NAV 2013 and NAV 2013 R2 have been designed after these guidelines. Please notice that the Report Guidelines says that you need to use textbox height of 10 pt. This is a unfortunately a mistake. If you use 10 pt. height in your textboxes AND 8 pt font size you will in some cases have the bottom of the letters: j, g and p cut of. To avoid this I’m now using 11pt. in height for all my cell heights, except the title which needs to be 20pt. in height and 14pt. font size. For font I’m using Segoe UI. Segoe UI, is the standard font use in Windows.
If you are curious about the guidelines for Windows read more here:
http://msdn.microsoft.com/library/windows/desktop/aa511440
And specific for the font Segoe UI, read here:
http://msdn.microsoft.com/library/windows/desktop/aa511440
In the Page Header I have the following textboxes:
1. Title which says INSERTTITLE. Title is unique to each report so you need to change this.
2. Company name. Here you need to insert Company name information. Since I cannot have data bound fields in my template report you will need to add this as well.
3. Execution Time. This field is not data bound, so you can just leave this field
4. Page Caption and PageNumber. Here PageNumber is not data bound while the PageCaption is, so you will need to add the PageCaption to your dataset and add this to this textbox. Notice that you will need to delete “INSERTPAGECAPTION” and create a new placeholder to add you new PageCaption from dataset, since I already have 2 Placeholders in this Textbox. If you don’t like this, just modify the template report, so it fit your needs.
5. Spacer. Just below the CompanyName I have a spacer which is 20pt in height as outlined in the Report UX Guidelines. In some standard reports this spacer has been removed after the report developer has designed the report, but I find it good practice to keep this, since it is much easier to keep this space between the header and body when you make modifications.
I often just open my Template report and copy the page header part over to an existing report where Page header is missing or not designed correct. Therefore I have place a rectangle around all my elements in the page header so it easy to copy the rectangle, since this will just include all of the above fields.
In the Body I have added the 3 different tablixes all with the correct dimensions according to the Report UX Guidelines. Correct height 11pt. for cell height, font set to Segoe UI, just like I have in my page header.
When I create RDLC report I constant need 1 or more of these Tablixes in my report. And having these tablixes setup correctly is a huge time saver for me. I.e. I have set the following up the Tablix used for list reports:
  • Correct font used
  • Correct Cell height used
  • Correct Padding used(Notice that I cheat and set everything to 0pt, and only add 5pt. as outlined in Guidelines when needed. The cost of having 5pt left padding and 5 right padding in document is using to much space in document reports )
  • Greenbar effect in the list(WhiteSmoke every second line)
  • Table created as 4 rows, Outlined in Guidelines here:http://msdn.microsoft.com/en-us/library/jj651611(v=nav.70).aspx
  • Again I’m cheating by adding hidden row in the table header. I do this to avoid Visual Studio adding default hardcoded captions to my report.
  • Added so all Header Table rows are repeated when detail rows spans more than one page. Not sure why this is not just standard in Visual Studio, and why this is so much hidden, and not just work in the Tablix menu, where these buttons don’t work at all, or I’m not smart enough to get them working. If you can get any these button working, I will invite the first person who will accomplish this to noma the world best restaurant situated in Denmark. I will not pay for your trip Denmark, only the restaurant :-) Watch the video, it is great fun. :-)
    So once again none of these buttons work in the Tablix property page in Visual Studio 2010, 2012 and 2013. The worked fine in Visual Studio 2008. Maybe the responsible guy for these buttons left Microsoft when Visual Studio 2008 was released… ;-)
image
Also in my template I have few code snippets I use:
  • Our bellowed SetData and GetData used in all standard document report. I have simplified the code to not use groups, since this concept was discontinue in NAV 2013 but unfortunately the code was not simplified. I rarely use the GetData and SetData in my document reports. Only real reason is when the customer request that the Page number is not in the top of page(Page Header) or bottom of the page(Page Footer), because it is impossible to get the page number in the Body of the report. So if this is a requirement I am forced to use SetData and GetData.
  • Divide by zero protection: 5 times I have now seen that doing Divide by Zero protection inside Expression not working, so it has now become best practice for me to do pass the 2 values to my Function DivideValues
Notice that I have also set the correct values in the Report Properties so margins are set correct based on the Report UX Guidelines. This also the main reason I have A4(Portrait), A4(Landscape), Letter(Portrait) and Letter(Landscape) .

No comments:

Post a Comment

Microsoft Dynamics NAV 2015 – Simplified Microsoft Dynamics NAV 2015 is much more simpler and easier for the end users to work more ef...