Prevent RDLC output at runtime?

generaljim
Member Posts: 8
I've got a report in 2016 that will either print a hard copy or output to Excel based on a checkbox in the Options tab presented to the user. The report layout has a body with a tablix, and a header. When I select output to Excel, I am able to prevent the data in the body from printing by simply doing a SKIP in the code behind the report. But it still prints one header. I don't see an easy way to prevent that header from printing. Is there a setting somewhere in the header that I can't find that says "if you don't find any data coming through, don't print the header section" or something like that? I tried putting the header information into the tablix within a row that has all columns merged and put into an inserted rectangle there, but since the Page Number is included, it won't save the report since that can only be used in a header or footer section. I can probably tell the customer that they will just have to live with it, but it would be nice to prevent.
0
Best Answer
-
I finally got the ability to test my solution, and it worked. For anyone following or wondering, I added a non-visible text box in the body, outside the tablix, and named that box ExcelFlag. The expression was the value of the Print to Excel flag set in the code. Then, for each of the fields in the header, I set the Visibility to =ReportItems!ExcelFlag.Value = "1" (1 being the setting for outputting to Excel). It still prints a page, but it's totally blank.5
Answers
-
Hey generaljim,
I believe whenever this type of requirement comes up we used to handle it with a FLAG only. Why dint you apply a visibility condition on the Tablix based on PRintExcel Flag that whenever its on VISIBILITY sets to off.Thanks
Blog - rockwithnav.wordpress.com/
Twitter - https://twitter.com/RockwithNav
Facebook - https://facebook.com/rockwithnav/0 -
Actually, that's how I got the tablix to not appear. I set the Visibility property of the tablix within the Body section to hide based on the Excel Output flag being "1". And that works like a champ. But in the Header section of the report, there's no such property that I can find. And since that flag isn't available at Header time, that's not going to work. I tried adding a hidden field in the tablix that is the flag and then using the ReportItems!<fieldname>.Value in the visibility property of each of the fields in the Header section, but since the tablix in the body is invisible, apparently the field never makes it into the body and so can't be referenced in the header. It's a Catch-22 type situation. And of course since I posted this yesterday, our IT group changed the development system so that anything I try now fails to execute. And they're in a time zone that is many hours different than me. So I can't try adding a new hidden always field outside the tablix in the Body to use instead of a hidden field within the tablix, but I'm not sure if that's going to work. It might be worth a shot. Hopefully I can actually try it tomorrow. I'll post here once I try it, but I'm thinking it's a 50% chance at best.0
-
I finally got the ability to test my solution, and it worked. For anyone following or wondering, I added a non-visible text box in the body, outside the tablix, and named that box ExcelFlag. The expression was the value of the Print to Excel flag set in the code. Then, for each of the fields in the header, I set the Visibility to =ReportItems!ExcelFlag.Value = "1" (1 being the setting for outputting to Excel). It still prints a page, but it's totally blank.5
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions