Prevent RDLC output at runtime?

generaljimgeneraljim 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.

Best Answer

Answers

  • RockWithNAVRockWithNAV Member Posts: 1,139
    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.
  • generaljimgeneraljim Member Posts: 8
    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.
Sign In or Register to comment.